Moved remote_config_exists into RemoteConfig

This commit is contained in:
Mayur Kularni
2019-12-09 14:14:49 +05:30
parent 5b9daea2b3
commit b271368845
2 changed files with 17 additions and 18 deletions
+2 -18
View File
@@ -8,7 +8,7 @@ from funcy import retry
from dvc.exceptions import NoRemoteInExternalRepoError
from dvc.remote import RemoteConfig
from dvc.config import NoRemoteError, ConfigError
from dvc.config import NoRemoteError
from dvc.exceptions import NoOutputInExternalRepoError
from dvc.exceptions import OutputNotFoundError
from dvc.utils.fs import remove
@@ -73,7 +73,7 @@ def _external_repo(url=None, rev=None, cache_dir=None):
# add default remote pointing to the original repo's cache location
if os.path.isdir(url):
rconfig = RemoteConfig(repo.config)
if not _remote_config_exists(rconfig):
if not rconfig.remote_config_exists():
original_repo = Repo(url)
rconfig.add(
"upstream",
@@ -127,19 +127,3 @@ def _clone_repo(url, path):
git = Git.clone(url, path)
git.close()
def _remote_config_exists(rconfig):
"""
Checks if default remote config is present.
Args:
rconfig: a remote config
Returns:
True if the remote config exists, else False
"""
try:
default = rconfig.get_default()
except ConfigError:
default = None
return bool(default)
+15
View File
@@ -156,3 +156,18 @@ class RemoteConfig(object):
return self.config.get(
Config.SECTION_CORE, Config.SECTION_CORE_REMOTE, level=level
)
def remote_config_exists(self):
"""
Checks if default remote config is present.
Args:
rconfig: a remote config
Returns:
True if the remote config exists, else False
"""
try:
default = self.get_default()
except ConfigError:
default = None
return bool(default)