示例#1
0
文件: helpers.py 项目: yask123/merge
 def test_bigint(self):
     self.assert_equal(int_to_bigint(0), 0)
     self.assert_equal(int_to_bigint(2**63-1), 2**63-1)
     self.assert_equal(int_to_bigint(-2**63+1), -2**63+1)
     self.assert_equal(int_to_bigint(2**63), b'\x00\x00\x00\x00\x00\x00\x00\x80\x00')
     self.assert_equal(int_to_bigint(-2**63), b'\x00\x00\x00\x00\x00\x00\x00\x80\xff')
     self.assert_equal(bigint_to_int(int_to_bigint(-2**70)), -2**70)
     self.assert_equal(bigint_to_int(int_to_bigint(2**70)), 2**70)
示例#2
0
 def test_bigint(self):
     self.assert_equal(int_to_bigint(0), 0)
     self.assert_equal(int_to_bigint(2**63 - 1), 2**63 - 1)
     self.assert_equal(int_to_bigint(-2**63 + 1), -2**63 + 1)
     self.assert_equal(int_to_bigint(2**63),
                       b'\x00\x00\x00\x00\x00\x00\x00\x80\x00')
     self.assert_equal(int_to_bigint(-2**63),
                       b'\x00\x00\x00\x00\x00\x00\x00\x80\xff')
     self.assert_equal(bigint_to_int(int_to_bigint(-2**70)), -2**70)
     self.assert_equal(bigint_to_int(int_to_bigint(2**70)), 2**70)
示例#3
0
文件: archive.py 项目: aykit/borg
 def process_stdin(self, path, cache):
     uid, gid = 0, 0
     fd = sys.stdin.buffer  # binary
     chunks = []
     for chunk in self.chunker.chunkify(fd):
         chunks.append(cache.add_chunk(self.key.id_hash(chunk), chunk, self.stats))
     self.stats.nfiles += 1
     item = {
         b'path': path,
         b'chunks': chunks,
         b'mode': 0o100660,  # regular file, ug=rw
         b'uid': uid, b'user': uid2user(uid),
         b'gid': gid, b'group': gid2group(gid),
         b'mtime': int_to_bigint(int(time.time()) * 1000000000)
     }
     self.add_item(item)
示例#4
0
文件: archive.py 项目: aykit/borg
 def stat_attrs(self, st, path):
     item = {
         b'mode': st.st_mode,
         b'uid': st.st_uid, b'user': uid2user(st.st_uid),
         b'gid': st.st_gid, b'group': gid2group(st.st_gid),
         b'mtime': int_to_bigint(st_mtime_ns(st))
     }
     if self.numeric_owner:
         item[b'user'] = item[b'group'] = None
     xattrs = xattr.get_all(path, follow_symlinks=False)
     if xattrs:
         item[b'xattrs'] = StableDict(xattrs)
     if has_lchflags and st.st_flags:
         item[b'bsdflags'] = st.st_flags
     acl_get(path, item, st, self.numeric_owner)
     return item
示例#5
0
 def stat_attrs(self, st, path):
     item = {
         b'mode': st.st_mode,
         b'uid': st.st_uid, b'user': uid2user(st.st_uid),
         b'gid': st.st_gid, b'group': gid2group(st.st_gid),
         b'mtime': int_to_bigint(st_mtime_ns(st))
     }
     if self.numeric_owner:
         item[b'user'] = item[b'group'] = None
     xattrs = xattr.get_all(path, follow_symlinks=False)
     if xattrs:
         item[b'xattrs'] = StableDict(xattrs)
     if has_lchflags and st.st_flags:
         item[b'bsdflags'] = st.st_flags
     item[b'acl'] = acl_get(path, item, self.numeric_owner)
     return item