本文整理汇总了Python中dulwich.pack.PackData.from_file方法的典型用法代码示例。如果您正苦于以下问题:Python PackData.from_file方法的具体用法?Python PackData.from_file怎么用?Python PackData.from_file使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dulwich.pack.PackData
的用法示例。
在下文中一共展示了PackData.from_file方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setUp
# 需要导入模块: from dulwich.pack import PackData [as 别名]
# 或者: from dulwich.pack.PackData import from_file [as 别名]
def setUp(self):
conf = swift.load_conf(file=StringIO(config_file % def_config_file))
sos = swift.SwiftObjectStore(FakeSwiftConnector("fakerepo", conf=conf))
commit_amount = 10
self.commits = create_commits(length=commit_amount, marker="m")
data = [(d.type_num, d.as_raw_string()) for d in self.commits]
f = StringIO()
fi = StringIO()
expected = build_pack(f, data, store=sos)
entries = [(sha, ofs, checksum) for ofs, _, _, sha, checksum in expected]
self.pack_data = PackData.from_file(file=f, size=None)
write_pack_index_v2(fi, entries, self.pack_data.calculate_checksum())
fi.seek(0)
self.pack_index = load_pack_index_file("", fi)
示例2: data_loader
# 需要导入模块: from dulwich.pack import PackData [as 别名]
# 或者: from dulwich.pack.PackData import from_file [as 别名]
def data_loader():
# read and writable temporary file
pack_tmpfile = tempfile.NamedTemporaryFile()
# download into temporary file
log.debug('Downloading pack %s into %s' % (path, pack_tmpfile))
pack_key = self.bucket.new_key('%s.pack' % path)
# store
pack_key.get_contents_to_file(pack_tmpfile)
log.debug('Filesize is %d' % pack_key.size)
log.debug('Rewinding...')
pack_tmpfile.flush()
pack_tmpfile.seek(0)
return PackData.from_file(pack_tmpfile, pack_key.size)
示例3: test_from_file
# 需要导入模块: from dulwich.pack import PackData [as 别名]
# 或者: from dulwich.pack.PackData import from_file [as 别名]
def test_from_file(self):
path = os.path.join(self.datadir, "pack-%s.pack" % pack1_sha)
PackData.from_file(open(path), os.path.getsize(path))
示例4: commit
# 需要导入模块: from dulwich.pack import PackData [as 别名]
# 或者: from dulwich.pack.PackData import from_file [as 别名]
def commit():
p = PackData.from_file(StringIO(f.getvalue()), f.tell())
f.close()
for obj in PackInflater.for_pack_data(p):
self._data[obj.id] = obj
示例5: commit
# 需要导入模块: from dulwich.pack import PackData [as 别名]
# 或者: from dulwich.pack.PackData import from_file [as 别名]
def commit():
p = PackData.from_file(BytesIO(f.getvalue()), f.tell())
f.close()
for obj in PackInflater.for_pack_data(p, self.get_raw):
self.add_object(obj)
示例6: store
# 需要导入模块: from dulwich.pack import PackData [as 别名]
# 或者: from dulwich.pack.PackData import from_file [as 别名]
def store():
p = PackData.from_file(StringIO(fileContents.getvalue()), fileContents.tell())
for obj in PackInflater.for_pack_data(p):
self.add_object(obj)
示例7: test_from_file
# 需要导入模块: from dulwich.pack import PackData [as 别名]
# 或者: from dulwich.pack.PackData import from_file [as 别名]
def test_from_file(self):
path = os.path.join(self.datadir,
'pack-%s.pack' % pack1_sha.decode('ascii'))
with open(path, 'rb') as f:
PackData.from_file(f, os.path.getsize(path))
示例8: test_from_file
# 需要导入模块: from dulwich.pack import PackData [as 别名]
# 或者: from dulwich.pack.PackData import from_file [as 别名]
def test_from_file(self):
path = os.path.join(self.datadir, 'pack-%s.pack' % str(pack1_sha))
with PackData.from_file(open(path, 'rb'), os.path.getsize(path)) as p:
pass
示例9: test_from_file
# 需要导入模块: from dulwich.pack import PackData [as 别名]
# 或者: from dulwich.pack.PackData import from_file [as 别名]
def test_from_file(self):
path = os.path.join(self.datadir, b'pack-' + pack1_sha + b'.pack')
with open(path, 'rb') as f:
PackData.from_file(f, os.path.getsize(path))