本文整理汇总了Python中datalad.support.annexrepo.AnnexRepo.get_file_key方法的典型用法代码示例。如果您正苦于以下问题:Python AnnexRepo.get_file_key方法的具体用法?Python AnnexRepo.get_file_key怎么用?Python AnnexRepo.get_file_key使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类datalad.support.annexrepo.AnnexRepo
的用法示例。
在下文中一共展示了AnnexRepo.get_file_key方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ok_file_under_git
# 需要导入模块: from datalad.support.annexrepo import AnnexRepo [as 别名]
# 或者: from datalad.support.annexrepo.AnnexRepo import get_file_key [as 别名]
def ok_file_under_git(path, filename, annexed=False):
repo = AnnexRepo(path)
assert(filename in repo.get_indexed_files()) # file is known to Git
try:
repo.get_file_key(filename)
in_annex = True
except FileNotInAnnexError as e:
in_annex = False
assert(annexed == in_annex)
示例2: test_get_contentlocation
# 需要导入模块: from datalad.support.annexrepo import AnnexRepo [as 别名]
# 或者: from datalad.support.annexrepo.AnnexRepo import get_file_key [as 别名]
def test_get_contentlocation(tdir):
repo = AnnexRepo(tdir, create=True, init=True)
repo.add('file.dat')
repo.commit('added file.dat')
key = repo.get_file_key('file.dat')
cr = AnnexCustomRemote(tdir)
key_path = cr.get_contentlocation(key, absolute=False)
assert not isabs(key_path)
key_path_abs = cr.get_contentlocation(key, absolute=True)
assert isabs(key_path_abs)
assert cr._contentlocations == {key: key_path}
repo.drop('file.dat', options=['--force'])
assert not cr.get_contentlocation(key, absolute=True)
示例3: test_AnnexRepo_get_file_key
# 需要导入模块: from datalad.support.annexrepo import AnnexRepo [as 别名]
# 或者: from datalad.support.annexrepo.AnnexRepo import get_file_key [as 别名]
def test_AnnexRepo_get_file_key(src, annex_path):
ar = AnnexRepo(annex_path, src)
# test-annex.dat should return the correct key:
assert_equal(ar.get_file_key("test-annex.dat"), 'SHA256E-s4--181210f8f9c779c26da1d9b2075bde0127302ee0e3fca38c9a83f5b1dd8e5d3b.dat')
# test.dat is actually in git
# should raise Exception; also test for polymorphism
assert_raises(IOError, ar.get_file_key, "test.dat")
assert_raises(FileNotInAnnexError, ar.get_file_key, "test.dat")
assert_raises(FileInGitError, ar.get_file_key, "test.dat")
# filenotpresent.wtf doesn't even exist
assert_raises(IOError, ar.get_file_key, "filenotpresent.wtf")
示例4: test_AnnexRepo_annex_add
# 需要导入模块: from datalad.support.annexrepo import AnnexRepo [as 别名]
# 或者: from datalad.support.annexrepo.AnnexRepo import get_file_key [as 别名]
def test_AnnexRepo_annex_add(src, annex_path):
ar = AnnexRepo(annex_path, src)
filename = 'file_to_annex.dat'
filename_abs = os.path.join(annex_path, filename)
f = open(filename_abs, 'w')
f.write("What to write?")
f.close()
ar.annex_add(filename)
if not ar.is_direct_mode():
assert_true(os.path.islink(filename_abs), "Annexed file is not a link.")
else:
assert_false(os.path.islink(filename_abs), "Annexed file is link in direct mode.")
key = ar.get_file_key(filename)
assert_false(key == '')