def _parse(self, stream, context, path): obj = ListContainer() try: while True: obj.append(self.subcon._parse(stream, context, path)) except (StopFieldError, StreamError): pass except Exception: raise return obj
def save_to_packet(self): lc = ListContainer() for item in chain(*self.metalist): if item is None: lc.append(Container(primary=-1)) else: lc.append(Container(primary=item.primary, secondary=item.secondary, count=item.quantity)) packet = make_packet("inventory", wid=self.wid, length=len(lc), items=lc) return packet
def save_to_packet(self): lc = ListContainer() for item in chain(self.crafted, self.crafting, self.armor, self.storage, self.holdables): if item is None: lc.append(Container(primary=-1)) else: lc.append(Container(primary=item[0], secondary=item[1], count=item[2])) packet = make_packet("inventory", name=self.identifier, length=len(lc), items=lc) return packet
def save_to_packet(self): lc = ListContainer() for item in chain(self.crafted, self.crafting, self.armor, self.storage, self.holdables): if item is None: lc.append(Container(primary=-1)) else: lc.append(Container(primary=item.primary, secondary=item.secondary, count=item.quantity)) packet = make_packet("inventory", wid=0, length=len(lc), items=lc) return packet
def save_to_packet(self): lc = ListContainer() for item in self.items: if item is None: lc.append(Container(id=-1)) else: lc.append(Container(id=item[0], damage=item[1], count=item[2])) packet = make_packet("inventory", unknown1=self.unknown1, length=len(lc), items=lc) return packet
def as_bytes(self): return _constructs.CertificateURL.build( Container(type=self.type, url_and_hash_list=ListContainer( Container( length=len(url_and_hash.url), url=url_and_hash.url, padding=url_and_hash.padding, sha1_hash=url_and_hash.sha1_hash, ) for url_and_hash in self.url_and_hash_list)))
def save_to_packet(self, wid=None): # XXX This is a horrible place for this kind of silliness. Inventories # don't need to know or care about WIDs. Use a partial and fill this # out in inherited classes. if wid is not None: self.wid = wid lc = ListContainer() for item in chain(self.crafted, self.crafting, self.armor, self.storage, self.holdables): if item is None: lc.append(Container(primary=-1)) else: lc.append(Container(primary=item.primary, secondary=item.secondary, count=item.quantity)) packet = make_packet("inventory", wid=self.wid, length=len(lc), items=lc) return packet
def _parse(self, stream, context, path): bins_ = context.BinaryTypeEnums d = { BinaryTypeEnumeration.PrimitiveArray: PrimitiveTypeEnumeration, BinaryTypeEnumeration.Primitive: PrimitiveTypeEnumeration, BinaryTypeEnumeration.Class: ClassTypeInfo, BinaryTypeEnumeration.SystemClass: LengthPrefixedString } ret = [] for b in bins_: p = d.get(b, None) if p is None: continue ret.append(p._parse(stream, context, path)) return ListContainer(ret)
def as_bytes(self): return _constructs.CertificateRequest.build( Container( certificate_types=Container( length=len(self.certificate_types), certificate_types=[ cert_type.value for cert_type in self.certificate_types ]), supported_signature_algorithms=ListContainer( Container(hash=algorithm.hash, signature=algorithm.signature) for algorithm in self.supported_signature_algorithms), certificate_authorities=Container( length=len(self.certificate_authorities), certificate_authorities=self.certificate_authorities)))
def _parse(self, stream, context, path): allClses = self._allClses if not self._relativeToId: types_ = context.MemberTypeInfo.BinaryTypeEnums infos = context.MemberTypeInfo.Infos allClses[context.ClassInfo.ObjectId] = (types_,infos) else: types_, infos = allClses[context.MetadataId] hasExtraInfos = ( BinaryTypeEnumeration.PrimitiveArray, BinaryTypeEnumeration.Primitive, BinaryTypeEnumeration.Class, BinaryTypeEnumeration.SystemClass) ret = [] idxInfos = 0 for ty in types_: info = None if ty in hasExtraInfos: info = infos[idxInfos] idxInfos += 1 ret.append(self.parse_value(ty, info, stream, context, path)) return ListContainer(ret)
def save_to_packet(self): lc = ListContainer() for item in chain(self.crafted, self.crafting, self.armor, self.storage, self.holdables): if item is None: lc.append(Container(primary=-1)) else: lc.append( Container(primary=item.primary, secondary=item.secondary, count=item.quantity)) packet = make_packet("inventory", name=self.identifier, length=len(lc), items=lc) return packet
def _parse(self, stream, context, path): count = context.ClassInfo.MemberCount print("count") for i in range(count): ret.append(Record._parse(stream, contextn, path)) return ListContainer(ret)