<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def bagToXML(bagPath, ark_naan=None):
 """ Given a path to a bag, read stuff about it and make an XML file """

    # This is so .DEFAULT_ARK_NAAN can be modified
    # at runtime.
    if ark_naan is None:
        ark_naan = DEFAULT_ARK_NAAN
    bagInfoPath = os.path.join(bagPath, "bag-info.txt")
    bagTags = getBagTags(bagInfoPath)
    if 'Payload-Oxum' not in bagTags:
        bagTags['Payload-Oxum'] = getOxum(os.path.join(bagPath, "data"))
    oxumParts = bagTags['Payload-Oxum'].split(".", 1)
    bagName = "ark:/%d/%s" % (ark_naan, os.path.split(bagPath)[1])
    bagSize = oxumParts[0]
    bagFileCount = oxumParts[1]
    bagitString = open(os.path.join(bagPath, "bagit.txt"), "r").read()
    bagitLines = bagitString.split("\n")
    versionLine = bagitLines[0].strip()
    bagVersion = versionLine.split(None, 1)[1]
    bagXML = etree.Element(BAG + "codaXML", nsmap=BAG_NSMAP)
    name = etree.SubElement(bagXML, BAG + "name")
    name.text = bagName
    fileCount = etree.SubElement(bagXML, BAG + "fileCount")
    fileCount.text = bagFileCount
    payLoadSize = etree.SubElement(bagXML, BAG + "payloadSize")
    payLoadSize.text = bagSize
    bagitVersion = etree.SubElement(bagXML, BAG + "bagitVersion")
    bagitVersion.text = bagVersion
    etree.SubElement(bagXML, BAG + "lastStatus")
    etree.SubElement(bagXML, BAG + "lastVerified")
    if 'Bagging-Date' in bagTags:
        baggingDate = etree.SubElement(bagXML, BAG + "baggingDate")
        baggingDate.text = bagTags['Bagging-Date']
    bagInfo = etree.SubElement(bagXML, BAG + "bagInfo")
    for tag, content in bagTags.items():
        item = etree.SubElement(bagInfo, BAG + "item")
        itemName = etree.SubElement(item, BAG + "name")
        itemName.text = tag
        itemBody = etree.SubElement(item, BAG + "body")
        itemBody.text = content
    return bagXML, bagName