20 from .binary1
import *
24 attribute_type_dict = {}
26 for name
in list(xml2.attribute_type_dict.keys()):
27 attribute_type_dict[name] = next_type
28 next_type = next_type + 1
33 gen = GenerateBinary2()
34 return gen.encode(obj)
37 def encode_attribute(self, name, value):
39 type = attribute_type_dict.get(name, 0)
41 return encode_pos_int(type) + self.
encode(value)[1:]
42 return GenerateBinary1.encode_attribute(self, name, value)
44 def encode_map(self, obj):
45 str_list = [encode_pos_int(map_type) + encode_pos_int(len(obj))]
46 for name, value
in list(obj.items()):
47 if name!=discard_name:
49 return string.join(str_list,
"")
def encode_float(self, value): mant, exp = frexp(value) mant = long(mant *2L**20) exp = exp - 20 if m...
def encode_attribute(self, name, value)