36,15 → 36,11 |
return struct.calcsize(self._format_) |
|
def pack(self): |
args = [] |
for variable in self._args_: |
if (isinstance(self.__dict__[variable], list)): |
for item in self.__dict__[variable]: |
args.append(item) |
else: |
args.append(self.__dict__[variable]) |
list = [] |
for variable in self._list_: |
list.append(self.__dict__[variable]) |
|
return struct.pack(self._format_, *args) |
return struct.pack(self._format_, *list) |
|
def create(definition): |
"Create structure object" |
58,7 → 54,7 |
"network:": lambda: "!" |
}[tokens[0]]() |
inst = Struct() |
args = [] |
list = [] |
|
# Member tags |
comment = False |
82,7 → 78,7 |
format += variable |
|
inst.__dict__[subtokens[0]] = None |
args.append(subtokens[0]) |
list.append(subtokens[0]) |
|
variable = None |
continue |
106,5 → 102,5 |
}[token]() |
|
inst.__dict__['_format_'] = format |
inst.__dict__['_args_'] = args |
inst.__dict__['_list_'] = list |
return inst |