diff -r 933fbe9a5e2c -r 866fb3ab8778 xmlclass/xmlclass.py --- a/xmlclass/xmlclass.py Fri Oct 13 13:17:42 2017 +0300 +++ b/xmlclass/xmlclass.py Mon Oct 16 17:20:31 2017 +0300 @@ -83,12 +83,12 @@ def SetOffset(self, offset): if offset == "Z": - self.__offset = timedelta(minutes=0) + self.__offset = datetime.timedelta(minutes=0) self.__name = "UTC" else: sign = {"-": -1, "+": 1}[offset[0]] hours, minutes = [int(val) for val in offset[1:].split(":")] - self.__offset = timedelta(minutes=sign * (hours * 60 + minutes)) + self.__offset = datetime.timedelta(minutes=sign * (hours * 60 + minutes)) self.__name = "" def utcoffset(self, dt): @@ -98,7 +98,7 @@ return self.__name def dst(self, dt): - return ZERO + return datetime.timedelta(0) [ @@ -600,7 +600,7 @@ "extract": ExtractTag, "generate": GenerateTag, "initial": lambda: None, - "check": lambda x: x is None or infos["minOccurs"] == 0 and value + "check": lambda x: x is None or infos["minOccurs"] == 0 and x } @@ -634,15 +634,15 @@ def GetContentInfos(name, choices): for choice_infos in choices: - if choices_infos["type"] == "sequence": - for element_infos in choices_infos["elements"]: + if choice_infos["type"] == "sequence": + for element_infos in choice_infos["elements"]: if element_infos["type"] == CHOICE: if GetContentInfos(name, element_infos["choices"]): - return choices_infos + return choice_infos elif element_infos["name"] == name: - return choices_infos + return choice_infos elif choice_infos["name"] == name: - return choices_infos + return choice_infos return None @@ -743,7 +743,7 @@ namespace, childname = DecomposeQualifiedName(child.nodeName) infos = factory.GetQualifiedNameInfos(childname, namespace) if infos["type"] != SYNTAXELEMENT: - raise ValueError("\"%s\" can't be a member child!" % name) + raise ValueError("\"%s\" can't be a member child!" % childname) if element_name in infos["extract"]: children.append(infos["extract"][element_name](factory, child)) else: @@ -849,7 +849,7 @@ elements = group["choices"] for element in elements: if element["name"] == parts[1]: - return part[1], part[0] + return parts[1], parts[0] if not canbenone: raise ValueError("Unknown element \"%s\" for any defined namespaces!" % name) elif namespace in self.Namespaces: