当前位置: 首页>>代码示例>>Python>>正文


Python AnnexRepo.get_file_key方法代码示例

本文整理汇总了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)
开发者ID:WurstWorks,项目名称:datalad,代码行数:11,代码来源:utils.py

示例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)
开发者ID:hanke,项目名称:datalad,代码行数:16,代码来源:test_base.py

示例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")
开发者ID:jgors,项目名称:datalad,代码行数:17,代码来源:test_annexrepo.py

示例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 == '')
开发者ID:jgors,项目名称:datalad,代码行数:18,代码来源:test_annexrepo.py


注:本文中的datalad.support.annexrepo.AnnexRepo.get_file_key方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。