Make some minor improvements to the xml reader
This commit is contained in:
@@ -347,8 +347,8 @@ class ProjectXMLReader:
|
||||
# Deprecated Nodes
|
||||
if self._version < HEX_VERSION:
|
||||
for xVal in xItem:
|
||||
if xVal.tag == "name":
|
||||
name["active"] = checkBool(xVal.attrib.get("exported"), name["active"])
|
||||
if xVal.tag == "name" and "exported" in xVal.attrib:
|
||||
name["active"] = checkBool(xVal.attrib.get("exported"), False)
|
||||
|
||||
projContent.append({
|
||||
"name": itemName,
|
||||
@@ -365,16 +365,19 @@ class ProjectXMLReader:
|
||||
logger.debug("Parsing <content> section (legacy format)")
|
||||
|
||||
# Create maps to look up name -> key for status and importance
|
||||
statusMap = {entry["name"]: key for key, entry in projData.itemStatus.items()}
|
||||
importMap = {entry["name"]: key for key, entry in projData.itemImport.items()}
|
||||
statusMap = {entry.get("name"): key for key, entry in projData.itemStatus.items()}
|
||||
importMap = {entry.get("name"): key for key, entry in projData.itemImport.items()}
|
||||
|
||||
for xItem in xSection:
|
||||
if xItem.tag != "item":
|
||||
logger.warning("Ignored item <root/content/%s> in XML", xItem.tag)
|
||||
continue
|
||||
|
||||
item = {}
|
||||
meta = {}
|
||||
name = {}
|
||||
itemName = ""
|
||||
|
||||
if xItem.tag == "item":
|
||||
item["handle"] = checkStringNone(xItem.attrib.get("handle", None), None)
|
||||
item["parent"] = checkStringNone(xItem.attrib.get("parent", None), None)
|
||||
item["root"] = None # Value was added in 1.4
|
||||
@@ -395,7 +398,7 @@ class ProjectXMLReader:
|
||||
item["layout"] = checkString(xVal.text, "")
|
||||
elif xVal.tag == "expanded":
|
||||
meta["expanded"] = checkBool(xVal.text, False)
|
||||
elif xVal.tag == "exported": # Renamed to active in 1.4
|
||||
elif xVal.tag == "exported": # Renamed to active in 1.5
|
||||
name["active"] = checkBool(xVal.text, False)
|
||||
elif xVal.tag == "charCount":
|
||||
meta["charCount"] = checkInt(xVal.text, 0)
|
||||
@@ -420,7 +423,7 @@ class ProjectXMLReader:
|
||||
):
|
||||
item["layout"] = "DOCUMENT"
|
||||
|
||||
# The trast type was removed in 1.4
|
||||
# The trash type was removed in 1.4
|
||||
if item.get("type", "") == "TRASH":
|
||||
item["type"] = "ROOT"
|
||||
|
||||
@@ -431,9 +434,6 @@ class ProjectXMLReader:
|
||||
"nameAttr": name,
|
||||
})
|
||||
|
||||
else:
|
||||
logger.warning("Ignored <root/content/%s> in XML", xItem.tag)
|
||||
|
||||
return
|
||||
|
||||
def _parseStatusImport(self, xItem, sObject):
|
||||
@@ -463,7 +463,7 @@ class ProjectXMLReader:
|
||||
"""Parse a dictionary stored with key as the tag and the value
|
||||
as the text porperty.
|
||||
"""
|
||||
return {n.tag: checkString(n.text, "") for n in xItem}
|
||||
return {xNode.tag: checkString(xNode.text, "") for xNode in xItem}
|
||||
|
||||
# END Class ProjectXMLReader
|
||||
|
||||
|
||||
Reference in New Issue
Block a user