Skip to content

Commit

Permalink
repo: set message from raise for NotDvcRepoError
Browse files Browse the repository at this point in the history
  • Loading branch information
skshetry committed Feb 10, 2020
1 parent 55cb677 commit 648785d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 15 deletions.
13 changes: 1 addition & 12 deletions dvc/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,18 +112,7 @@ def __init__(self, path):


class NotDvcRepoError(DvcException):
"""Thrown if a directory is not a DVC repo.
Args:
root (str): path to the directory.
"""

def __init__(self, root, msg=None):
msg = msg or (
"you are not inside of a DVC repository "
"(checked up to mount point '{}')"
)
super().__init__(msg.format(root))
"""Thrown if a directory is not a DVC repo"""


class DvcParserError(DvcException):
Expand Down
11 changes: 8 additions & 3 deletions dvc/repo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,10 @@ def __repr__(self):

@classmethod
def find_root(cls, root=None):
root_dir = os.path.abspath(os.path.realpath(root or os.getcwd()))
root_dir = os.path.realpath(root or os.curdir)

if not os.path.isdir(root_dir):
raise NotDvcRepoError(root, msg="folder {} does not exist")
raise NotDvcRepoError("directory '{}' does not exist".format(root))

while True:
dvc_dir = os.path.join(root_dir, cls.DVC_DIR)
Expand All @@ -141,7 +141,12 @@ def find_root(cls, root=None):
if os.path.ismount(root_dir):
break
root_dir = os.path.dirname(root_dir)
raise NotDvcRepoError(root_dir)

message = (
"you are not inside of a DVC repository "
"(checked up to mount point '{}')"
).format(root_dir)
raise NotDvcRepoError(message)

@classmethod
def find_dvc_dir(cls, root=None):
Expand Down

0 comments on commit 648785d

Please sign in to comment.