"""Tagify module."""

import xml.etree.ElementTree as ET
import xml.dom.minidom


def givexml(indict={}):
    """
    Receive a dict-ish object and spit XML
    (removed lxml dependency despite my love for lxml)
    """
    top = ET.Element('Tags')

    comment = ET.Comment('Generated by mkvimdb')
    top.append(comment)

    tag = ET.SubElement(top, 'Tag')
    target = ET.SubElement(tag, 'Targets')
    targettype = ET.SubElement(target, 'TargetTypeValue')
    targettype.text = '50'
    for movietag in indict.keys():
        simple = ET.SubElement(tag, 'Simple')
        simplename = ET.SubElement(simple, 'Name')
        simplename.text = str(movietag)
        simplestring = ET.SubElement(simple, 'String')
        simplestring.text = str(indict[movietag])

    outxml = xml.dom.minidom.parseString(ET.tostring(top))
    return(outxml.toprettyxml())
