mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-10 15:28:34 +01:00
deps: use self.url instead of self.path
Signed-off-by: Ruslan Kuprieiev <[email protected]>
This commit is contained in:
+15
-11
@@ -23,23 +23,23 @@ class DependencyBase(object):
|
||||
def __init__(self, stage, path):
|
||||
self.stage = stage
|
||||
self.project = stage.project
|
||||
self.path = path
|
||||
self.url = path
|
||||
|
||||
def __repr__(self):
|
||||
return "{class_name}: '{path}'".format(
|
||||
return "{class_name}: '{url}'".format(
|
||||
class_name=type(self).__name__,
|
||||
path=(self.path or 'No path')
|
||||
url=(self.url or 'No url')
|
||||
)
|
||||
|
||||
def __str__(self):
|
||||
return self.path
|
||||
return self.url
|
||||
|
||||
@classmethod
|
||||
def match(cls, url):
|
||||
return re.match(cls.REGEX, url)
|
||||
|
||||
def group(self, name):
|
||||
match = self.match(self.path)
|
||||
match = self.match(self.url)
|
||||
if not match:
|
||||
return None
|
||||
return match.group(name)
|
||||
@@ -48,6 +48,14 @@ class DependencyBase(object):
|
||||
def supported(cls, url):
|
||||
return cls.match(url) is not None
|
||||
|
||||
@property
|
||||
def scheme(self):
|
||||
return self.path_info['scheme']
|
||||
|
||||
@property
|
||||
def path(self):
|
||||
return self.path_info['path']
|
||||
|
||||
@property
|
||||
def sep(self):
|
||||
return '/'
|
||||
@@ -62,18 +70,14 @@ class DependencyBase(object):
|
||||
def status(self):
|
||||
if self.changed():
|
||||
# FIXME better msgs
|
||||
if self.path_info['scheme'] == 'local':
|
||||
p = self.rel_path
|
||||
else:
|
||||
p = self.path
|
||||
return {p: 'changed'}
|
||||
return {str(self): 'changed'}
|
||||
return {}
|
||||
|
||||
def save(self):
|
||||
raise NotImplementedError
|
||||
|
||||
def dumpd(self):
|
||||
return {self.PARAM_PATH: self.path}
|
||||
return {self.PARAM_PATH: self.url}
|
||||
|
||||
def download(self, to_info):
|
||||
self.remote.download([self.path_info], [to_info])
|
||||
|
||||
+10
-8
@@ -19,8 +19,7 @@ class DependencyLOCAL(DependencyBase):
|
||||
IsNotFileOrDirError = DependencyIsNotFileOrDirError
|
||||
|
||||
def __init__(self, stage, path, info=None, remote=None):
|
||||
self.stage = stage
|
||||
self.project = stage.project
|
||||
super(DependencyLOCAL, self).__init__(stage, path)
|
||||
self.info = info
|
||||
if remote is not None:
|
||||
self.remote = remote
|
||||
@@ -28,15 +27,18 @@ class DependencyLOCAL(DependencyBase):
|
||||
self.remote = RemoteLOCAL(stage.project, {})
|
||||
|
||||
if remote:
|
||||
path = os.path.join(remote.prefix, urlparse(path).path.lstrip('/'))
|
||||
p = os.path.join(remote.prefix,
|
||||
urlparse(self.url).path.lstrip('/'))
|
||||
else:
|
||||
p = path
|
||||
|
||||
if not os.path.isabs(path):
|
||||
path = self.remote.to_ospath(path)
|
||||
path = os.path.join(stage.cwd, path)
|
||||
self.path = os.path.abspath(os.path.normpath(path))
|
||||
if not os.path.isabs(p):
|
||||
p = self.remote.to_ospath(p)
|
||||
p = os.path.join(stage.cwd, p)
|
||||
p = os.path.abspath(os.path.normpath(p))
|
||||
|
||||
self.path_info = {'scheme': 'local',
|
||||
'path': self.path}
|
||||
'path': p}
|
||||
|
||||
def __str__(self):
|
||||
return self.rel_path
|
||||
|
||||
@@ -24,7 +24,7 @@ class DependencySSH(DependencyBase):
|
||||
path = posixpath.join(remote.prefix,
|
||||
urlparse(path).path.lstrip('/'))
|
||||
else:
|
||||
path = self.match(self.path).group('path')
|
||||
path = self.match(self.url).group('path')
|
||||
|
||||
self.path_info = {'scheme': 'ssh',
|
||||
'host': host,
|
||||
|
||||
+1
-1
@@ -127,7 +127,7 @@ class OutputLOCAL(DependencyLOCAL):
|
||||
self.project.scm.ignore_remove(self.path)
|
||||
|
||||
self.remote.move(self.path_info, out.path_info)
|
||||
self.path = out.path
|
||||
self.url = out.url
|
||||
self.path_info = out.path_info
|
||||
self.save()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user