本文整理汇总了Python中msgpack.version方法的典型用法代码示例。如果您正苦于以下问题:Python msgpack.version方法的具体用法?Python msgpack.version怎么用?Python msgpack.version使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类msgpack
的用法示例。
在下文中一共展示了msgpack.version方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __load_symbols
# 需要导入模块: import msgpack [as 别名]
# 或者: from msgpack import version [as 别名]
def __load_symbols(self, data):
self.symbols = data["symbols"]
if self.version >= 1.9:
self.demangled = data["demangled"]
for name, ad in self.demangled.items():
self.reverse_demangled[ad] = name
if self.version <= 1.4 and self.version != -1:
for name, a in self.symbols.items():
self.reverse_symbols[a[0]] = name
self.symbols[name] = a[0]
self.mem.add(a[0], 1, a[1])
return
for name, ad in self.symbols.items():
self.reverse_symbols[ad] = name
self.symbols[name] = ad
示例2: items_to_csv
# 需要导入模块: import msgpack [as 别名]
# 或者: from msgpack import version [as 别名]
def items_to_csv(source, output):
struct_fmt = 'IIII'
struct_len = struct.calcsize(struct_fmt)
struct_unpack = struct.Struct(struct_fmt).unpack_from
writer = csv.writer(output)
writer.writerow(("item_id", "coverage_id", "model_data", "group_id"))
while True:
data = source.read(struct_len)
if not data:
break
item_id, coverage_id, group_id, model_data_len = struct_unpack(data)
# https://github.com/msgpack/msgpack-python#major-breaking-changes-in-msgpack-10
if msgpack.version >= (1,0,0):
model_data = msgpack.unpackb(source.read(model_data_len), raw=False)
writer.writerow((item_id, coverage_id, model_data, group_id))
else:
model_data = msgpack.unpackb(source.read(model_data_len))
writer.writerow((item_id, coverage_id, model_data.decode('utf-8'), group_id))
示例3: __init__
# 需要导入模块: import msgpack [as 别名]
# 或者: from msgpack import version [as 别名]
def __init__(self):
self.__init_vars()
if msgpack.version < (0, 4, 6):
warning("your version of msgpack is less than 0.4.6")
示例4: __init_vars
# 需要导入模块: import msgpack [as 别名]
# 或者: from msgpack import version [as 别名]
def __init_vars(self):
self.history = []
self.symbols = {} # name -> addr
self.demangled = {} # name -> addr
self.user_inline_comments = {}
self.internal_inline_comments = {}
self.user_previous_comments = {}
self.internal_previous_comments = {}
self.jmptables = {}
self.mips_gp = 0
self.modified = False
self.loaded = False
self.mem = None # see lib.memory
# func address ->
# [ end addr,
# flags,
# dict vars_off -> [type, name],
# func_id,
# dict inst.address -> vars_off,
# frame_size,
# args_restore,
# ]
self.functions = {}
self.func_id = {} # id -> func address
self.xrefs = {} # addr -> list addr
# For big data (arrays/strings) we save all addresses with an xrefs
self.data_sub_xrefs = {} # data_address -> {addresses_with_xrefs: True}
self.imports = {} # ad -> flags
self.immediates = {} # insn_ad -> immediate result
self.inverted_cond = {} # addr -> arbitrary_value
self.raw_base = 0
self.raw_type = None
self.raw_is_big_endian = None
# Computed variables
self.func_id_counter = 0
self.end_functions = {}
self.reverse_symbols = {} # addr -> name
self.reverse_demangled = {} # addr -> name
self.version = VERSION
示例5: load
# 需要导入模块: import msgpack [as 别名]
# 或者: from msgpack import version [as 别名]
def load(self, filename):
gc.disable()
self.path = filename
if os.path.exists(self.path):
info("open database %s" % self.path)
fd = open(self.path, "rb")
data = fd.read()
if data.startswith(b"ZLIB"):
data = zlib.decompress(data[4:])
data = msgpack.unpackb(data, encoding="utf-8")
fd.close()
self.__load_meta(data)
if self.version == LAST_COMPATIBLE:
warning("the database version is old, some information may be missing")
elif self.version < LAST_COMPATIBLE:
die("the database is too old")
self.__load_memory(data)
self.__load_symbols(data)
self.__load_jmptables(data)
self.__load_comments(data)
self.__load_functions(data)
self.__load_history(data)
self.__load_xrefs(data)
self.__load_imports(data)
self.__load_immediates(data)
self.__load_inverted_cond(data)
self.loaded = True
gc.enable()
示例6: save
# 需要导入模块: import msgpack [as 别名]
# 或者: from msgpack import version [as 别名]
def save(self, history):
data = {
"version": VERSION,
"symbols": self.symbols,
"demangled": self.demangled,
"history": history,
"user_inline_comments": self.user_inline_comments,
"internal_inline_comments": self.internal_inline_comments,
"user_previous_comments": self.user_previous_comments,
"internal_previous_comments": self.internal_previous_comments,
"jmptables": [],
"mips_gp": self.mips_gp,
"mem": self.mem.mm,
"functions": self.functions,
"func_id_counter": self.func_id_counter,
"func_id": self.func_id,
"xrefs": self.xrefs,
"data_sub_xrefs": self.data_sub_xrefs,
"raw_base": self.raw_base,
"raw_type": self.raw_type,
"raw_is_big_endian": self.raw_is_big_endian,
"imports": self.imports,
"immediates": self.immediates,
"inverted_cond": self.inverted_cond,
}
for j in self.jmptables.values():
o = {
"inst_addr": j.inst_addr,
"table_addr": j.table_addr,
"table": j.table,
"name": j.name,
}
data["jmptables"].append(o)
fd = open(self.path, "wb+")
fd.write(b"ZLIB")
fd.write(zlib.compress(msgpack.packb(data, use_bin_type=True)))
fd.close()
示例7: __load_imports
# 需要导入模块: import msgpack [as 别名]
# 或者: from msgpack import version [as 别名]
def __load_imports(self, data):
self.imports = data["imports"]
if self.version <= 2.7:
for ad in self.imports:
# TODO ?? check separatly pe/elf
name = self.reverse_symbols[ad]
if name in NORETURN_ELF or name in NORETURN_PE:
self.imports[ad] = FUNC_FLAG_NORETURN
示例8: get_tf_version_tuple
# 需要导入模块: import msgpack [as 别名]
# 或者: from msgpack import version [as 别名]
def get_tf_version_tuple():
"""
Return TensorFlow version as a 2-element tuple (for comparison).
"""
return tuple(map(int, tf.__version__.split('.')[:2]))