(self)
| 90 | __repr__ = __str__ |
| 91 | |
| 92 | def get_code(self): |
| 93 | code = """ |
| 94 | |
| 95 | class {0}(object): |
| 96 | |
| 97 | ''' |
| 98 | {0} structure autogenerated from xml |
| 99 | ''' |
| 100 | |
| 101 | """.format(self.name) |
| 102 | |
| 103 | code += " ua_types = [\n" |
| 104 | for field in self.fields: |
| 105 | prefix = "ListOf" if field.array else "" |
| 106 | uatype = prefix + field.uatype |
| 107 | if uatype == "ListOfChar": |
| 108 | uatype = "String" |
| 109 | code += " ('{}', '{}'),\n".format(field.name, uatype) |
| 110 | |
| 111 | code += " ]" |
| 112 | code += """ |
| 113 | def __str__(self): |
| 114 | vals = [name + ": " + str(val) for name, val in self.__dict__.items()] |
| 115 | return self.__class__.__name__ + "(" + ", ".join(vals) + ")" |
| 116 | |
| 117 | __repr__ = __str__ |
| 118 | |
| 119 | def __init__(self): |
| 120 | """ |
| 121 | if not self.fields: |
| 122 | code += " pass" |
| 123 | for field in self.fields: |
| 124 | code += " self.{} = {}\n".format(field.name, field.value) |
| 125 | return code |
| 126 | |
| 127 | |
| 128 | class Field(object): |
no outgoing calls
no test coverage detected