Esempio n. 1
0
 def create(cls, object_iter, base_dir, object_count = None, zlib_compression = zlib.Z_BEST_SPEED):
     """Create a new on-disk entity comprised of a properly named pack file and a properly named
     and corresponding index file. The pack contains all OStream objects contained in object iter.
     :param base_dir: directory which is to contain the files
     :return: PackEntity instance initialized with the new pack
     :note: for more information on the other parameters see the write_pack method"""
     pack_fd, pack_path = tempfile.mkstemp('', 'pack', base_dir)
     index_fd, index_path = tempfile.mkstemp('', 'index', base_dir)
     pack_write = lambda d: os.write(pack_fd, d)
     index_write = lambda d: os.write(index_fd, d)
     
     pack_binsha, index_binsha = cls.write_pack(object_iter, pack_write, index_write, object_count, zlib_compression)
     os.close(pack_fd)
     os.close(index_fd)
     
     fmt = "pack-%s.%s"
     new_pack_path = os.path.join(base_dir, fmt % (bin_to_hex(pack_binsha), 'pack'))
     new_index_path = os.path.join(base_dir, fmt % (bin_to_hex(pack_binsha), 'idx'))
     os.rename(pack_path, new_pack_path)
     os.rename(index_path, new_index_path)
     
     return cls(new_pack_path)
Esempio n. 2
0
	def hexsha(self):
		""":return: our sha, hex encoded, 40 bytes"""
		return bin_to_hex(self[0])
Esempio n. 3
0
	def hexsha(self):
		return bin_to_hex(self[0])
Esempio n. 4
0
 def hexsha(self):
     return bin_to_hex(self[0])
Esempio n. 5
0
 def hexsha(self):
     """:return: our sha, hex encoded, 40 bytes"""
     return bin_to_hex(self[0])
Esempio n. 6
0
def mul(a, b):
    a = util.hex_to_dec(a)
    b = util.hex_to_dec(b)
    c = util.bin_to_hex(str(GF256(a) * GF256(b))[8:16])
    return c