本文整理汇总了Python中datalad.support.annexrepo.AnnexRepo.is_direct_mode方法的典型用法代码示例。如果您正苦于以下问题:Python AnnexRepo.is_direct_mode方法的具体用法?Python AnnexRepo.is_direct_mode怎么用?Python AnnexRepo.is_direct_mode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类datalad.support.annexrepo.AnnexRepo
的用法示例。
在下文中一共展示了AnnexRepo.is_direct_mode方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_direct_cfg
# 需要导入模块: from datalad.support.annexrepo import AnnexRepo [as 别名]
# 或者: from datalad.support.annexrepo.AnnexRepo import is_direct_mode [as 别名]
def test_direct_cfg(path1, path2, path3, path4):
with patch.dict('os.environ', {'DATALAD_REPO_DIRECT': 'True'}):
# create annex repo in direct mode:
with swallow_logs(new_level=logging.DEBUG) as cml:
ar = AnnexRepo(path1, create=True)
cml.assert_logged("Switching to direct mode",
regex=False, level='DEBUG')
ok_(ar.is_direct_mode())
# but don't if repo version is 6 (actually, 6 or above):
with swallow_logs(new_level=logging.WARNING) as cml:
ar = AnnexRepo(path2, create=True, version=6)
ok_(not ar.is_direct_mode())
cml.assert_logged("direct mode not available", regex=False,
level='WARNING')
# explicit parameter `direct` has priority:
ar = AnnexRepo(path3, create=True, direct=False)
if not ar.is_crippled_fs(): # otherwise forced direct mode
ok_(not ar.is_direct_mode())
# don't touch existing repo:
ar = AnnexRepo(path2, create=True)
if not ar.is_crippled_fs(): # otherwise forced direct mode
ok_(not ar.is_direct_mode())
# make sure, value is relevant:
with patch.dict('os.environ', {'DATALAD_REPO_DIRECT': '0'}):
# don't use direct mode
ar = AnnexRepo(path4, create=True)
if not ar.is_crippled_fs(): # otherwise forced direct mode
ok_(not ar.is_direct_mode())
示例2: test_AnnexRepo_set_direct_mode
# 需要导入模块: from datalad.support.annexrepo import AnnexRepo [as 别名]
# 或者: from datalad.support.annexrepo.AnnexRepo import is_direct_mode [as 别名]
def test_AnnexRepo_set_direct_mode(src, dst):
ar = AnnexRepo(dst, src)
ar.set_direct_mode(True)
assert_true(ar.is_direct_mode(), "Switching to direct mode failed.")
if ar.is_crippled_fs():
assert_raises(CommandNotAvailableError, ar.set_direct_mode, False)
assert_true(ar.is_direct_mode(), "Indirect mode on crippled fs detected. Shouldn't be possible.")
else:
ar.set_direct_mode(False)
assert_false(ar.is_direct_mode(), "Switching to indirect mode failed.")
示例3: test_direct_cfg
# 需要导入模块: from datalad.support.annexrepo import AnnexRepo [as 别名]
# 或者: from datalad.support.annexrepo.AnnexRepo import is_direct_mode [as 别名]
def test_direct_cfg(path1, path2):
# and if repo already exists and we have env var - we fail too
# Adding backend so we get some commit into the repo
ar = AnnexRepo(path1, create=True, backend='MD5E')
del ar; AnnexRepo._unique_instances.clear() # fight flyweight
for path in (path1, path2):
with patch.dict('os.environ', {'DATALAD_REPO_DIRECT': 'True'}):
# try to create annex repo in direct mode as see how it fails
with assert_raises(DirectModeNoLongerSupportedError) as cme:
AnnexRepo(path, create=True)
assert_in("no longer supported by DataLad", str(cme.exception)) # we have generic part
assert_in("datalad.repo.direct configuration", str(cme.exception)) # situation specific part
# assert not op.exists(path2) # that we didn't create it - we do!
# fixing for that would be too cumbersome since we first call GitRepo.__init__
# with create
ar = AnnexRepo(path1)
# check if we somehow didn't reset the flag
assert not ar.is_direct_mode()
if ar.config.obtain("datalad.repo.version") >= 6:
raise SkipTest("Created repo not v5, cannot test detection of direct mode repos")
# and if repo existed before and was in direct mode, we fail too
# Since direct= option was deprecated entirely, we use protected method now
ar._set_direct_mode(True)
assert ar.is_direct_mode()
del ar # but we would need to disable somehow the flywheel
with patch.dict('os.environ', {'DATALAD_REPO_DIRECT': 'True'}):
with assert_raises(DirectModeNoLongerSupportedError) as cme:
AnnexRepo(path1, create=False)
# TODO: RM DIRECT decide what should we here -- should we test/blow?
# ATM both tests below just pass
ar2 = AnnexRepo(path2, create=True)
# happily can do it since it doesn't need a worktree to do the clone
ar2.add_submodule('sub1', url=path1)
ar2sub1 = AnnexRepo(op.join(path2, 'sub1'))
# but now let's convert that sub1 to direct mode
assert not ar2sub1.is_direct_mode()
ar2sub1._set_direct_mode(True)
assert ar2sub1.is_direct_mode()
del ar2; del ar2sub1; AnnexRepo._unique_instances.clear() # fight flyweight
ar2 = AnnexRepo(path2)
ar2.get_submodules()
# And what if we are trying to add pre-cloned repo in direct mode?
ar2sub2 = AnnexRepo.clone(path1, op.join(path2, 'sub2'))
ar2sub2._set_direct_mode(True)
del ar2sub2; AnnexRepo._unique_instances.clear() # fight flyweight
ar2.add('sub2')
示例4: test_AnnexRepo_is_direct_mode
# 需要导入模块: from datalad.support.annexrepo import AnnexRepo [as 别名]
# 或者: from datalad.support.annexrepo.AnnexRepo import is_direct_mode [as 别名]
def test_AnnexRepo_is_direct_mode(path):
ar = AnnexRepo(path)
dm = ar.is_direct_mode()
if on_windows:
assert_true(dm, "AnnexRepo.is_direct_mode() returned false on windows.")
else:
assert_false(dm, "AnnexRepo.is_direct_mode() returned true on non-windows")
示例5: test_AnnexRepo_annex_add
# 需要导入模块: from datalad.support.annexrepo import AnnexRepo [as 别名]
# 或者: from datalad.support.annexrepo.AnnexRepo import is_direct_mode [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 == '')