コード例 #1
0
    def _getDomains(self):
        domains = []
        for domain in self.xml.getElementsByTagName("domain"):
            tmp = Domain()

            for attributeName, attributeValue in domain.attributes.items():
                if attributeName.lower() == "name":
                    tmp.name = attributeValue
                elif attributeName.lower() == "description":
                    tmp.description = attributeValue
                elif attributeName.lower() == "type":
                    tmp.type = attributeValue
                    tmp.type_id = postgres_utils.get_type_in_postgres(tmp)
                elif attributeName.lower() == "align":
                    tmp.align = attributeValue
                elif attributeName.lower() == "width":
                    tmp.width = attributeValue
                elif attributeName.lower() == "precision":
                    tmp.precision = attributeValue
                elif attributeName.lower() == "props":
                    for prop in attributeValue.split(", "):
                        if prop == "show_null":
                            tmp.show_null = True
                        elif prop == "summable":
                            tmp.summable = True
                        elif prop == "case_sensitive":
                            tmp.case_sensitive = True
                        elif prop == "show_lead_nulls":
                            tmp.show_lead_nulls = True
                        elif prop == "thousands_separator":
                            tmp.thousands_separator = True
                        else:
                            raise ValueError(
                                "Invalid format of props string: {}".format(
                                    attributeValue))
                elif attributeName.lower() == "char_length":
                    tmp.char_length = attributeValue
                elif attributeName.lower() == "length":
                    tmp.length = attributeValue
                elif attributeName.lower() == "scale":
                    tmp.scale = attributeValue
                else:
                    raise ValueError(
                        "Incorrect attribute name \"{}\" in tag \"{}\" ".
                        format(attributeName, domain.nodeName))

            domains.append(tmp)
        return domains