Python msgpack.version() Examples
The following are 9
code examples of msgpack.version().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
msgpack
, or try the search function
.
Example #1
Source File: database.py From plasma with GNU General Public License v3.0 | 6 votes |
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
Example #2
Source File: complex_items_to_csv.py From OasisLMF with BSD 3-Clause "New" or "Revised" License | 6 votes |
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))
Example #3
Source File: database.py From plasma with GNU General Public License v3.0 | 5 votes |
def __init__(self): self.__init_vars() if msgpack.version < (0, 4, 6): warning("your version of msgpack is less than 0.4.6")
Example #4
Source File: database.py From plasma with GNU General Public License v3.0 | 5 votes |
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
Example #5
Source File: database.py From plasma with GNU General Public License v3.0 | 5 votes |
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()
Example #6
Source File: database.py From plasma with GNU General Public License v3.0 | 5 votes |
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()
Example #7
Source File: database.py From plasma with GNU General Public License v3.0 | 5 votes |
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
Example #8
Source File: common.py From ADL with MIT License | 5 votes |
def get_tf_version_tuple(): """ Return TensorFlow version as a 2-element tuple (for comparison). """ return tuple(map(int, tf.__version__.split('.')[:2]))
Example #9
Source File: common.py From tensorpack with Apache License 2.0 | 5 votes |
def get_tf_version_tuple(): """ Return TensorFlow version as a 2-element tuple (for comparison). """ return tuple(map(int, tf.__version__.split('.')[:2]))