From 49c22cb139b84aeaf02f767503893ae922b7d957 Mon Sep 17 00:00:00 2001 From: Ruslan Kuprieiev Date: Wed, 19 Sep 2018 21:40:00 +0300 Subject: [PATCH] local: use is_local property Signed-off-by: Ruslan Kuprieiev --- dvc/dependency/local.py | 8 +++++++- dvc/output/local.py | 4 ---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/dvc/dependency/local.py b/dvc/dependency/local.py index 3ff164121..74b44b86b 100644 --- a/dvc/dependency/local.py +++ b/dvc/dependency/local.py @@ -41,6 +41,12 @@ class DependencyLOCAL(DependencyBase): def __str__(self): return self.rel_path + @property + def is_local(self): + assert os.path.isabs(self.path) + assert os.path.isabs(self.project.root_dir) + return self.path.startswith(self.project.root_dir) + @property def sep(self): return os.sep @@ -71,7 +77,7 @@ class DependencyLOCAL(DependencyBase): self.info = self.remote.save_info(self.path_info) def dumpd(self): - if self.path.startswith(self.stage.project.root_dir): + if self.is_local: path = self.remote.unixpath(os.path.relpath(self.path, self.stage.cwd)) else: diff --git a/dvc/output/local.py b/dvc/output/local.py index f23958530..7955eb3ac 100644 --- a/dvc/output/local.py +++ b/dvc/output/local.py @@ -40,10 +40,6 @@ class OutputLOCAL(DependencyLOCAL): def cache(self): return self.project.cache.local.get(self.md5) - @property - def is_local(self): - return self.path.startswith(self.project.root_dir) - def dumpd(self): ret = super(OutputLOCAL, self).dumpd() ret[self.PARAM_CACHE] = self.use_cache