aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--dotfiles/cli.py4
-rw-r--r--dotfiles/dotfile.py12
-rw-r--r--dotfiles/repository.py5
-rw-r--r--tests/conftest.py2
-rw-r--r--tests/test_dotfile.py6
5 files changed, 15 insertions, 14 deletions
diff --git a/dotfiles/cli.py b/dotfiles/cli.py
index a24e38d..a99d098 100644
--- a/dotfiles/cli.py
+++ b/dotfiles/cli.py
@@ -1,7 +1,9 @@
import click
from .exceptions import DotfileException
-from .repository import Repositories, DEFAULT_PATH, DEFAULT_REMOVE_LEADING_DOT
+from .repository import Repositories
+from .repository import PATH as DEFAULT_PATH
+from .repository import REMOVE_LEADING_DOT as DEFAULT_REMOVE_LEADING_DOT
def get_single_repo(repos):
diff --git a/dotfiles/dotfile.py b/dotfiles/dotfile.py
index b17822e..e539c68 100644
--- a/dotfiles/dotfile.py
+++ b/dotfiles/dotfile.py
@@ -13,8 +13,8 @@ class Dotfile(object):
"""
def __init__(self, name, target):
- self.name = name
- self.target = target
+ self.name = Path(name)
+ self.target = Path(target)
def __str__(self):
return str(self.name)
@@ -29,14 +29,14 @@ class Dotfile(object):
directory structure is expected to exist.
"""
def ensure(dir, debug):
- if not dir.check():
+ if not dir.is_dir():
if debug:
echo('MKDIR %s' % dir)
else:
- dir.ensure_dir()
+ dir.mkdir()
- ensure(py.path.local(self.name.dirname), debug)
- ensure(py.path.local(self.target.dirname), debug)
+ ensure(self.name.parent, debug)
+ ensure(self.target.parent, debug)
def _link(self, debug):
"""Create a symlink from name to target, no error checking."""
diff --git a/dotfiles/repository.py b/dotfiles/repository.py
index ac0be2c..9197c2a 100644
--- a/dotfiles/repository.py
+++ b/dotfiles/repository.py
@@ -26,8 +26,7 @@ class Repositories(object):
self.repos = []
for path in paths:
- path = Path(path).expanduser()
- self.repos.append(Repository(path, dot))
+ self.repos.append(Repository(path, remove_leading_dot=dot))
def __len__(self):
return len(self.repos)
@@ -49,7 +48,7 @@ class Repository(object):
homedir=HOMEDIR,
remove_leading_dot=REMOVE_LEADING_DOT,
ignore_patterns=IGNORE_PATTERNS):
- self.path = Path(path)
+ self.path = Path(path).expanduser()
self.homedir = Path(homedir)
self.remove_leading_dot = remove_leading_dot
self.ignore_patterns = ignore_patterns
diff --git a/tests/conftest.py b/tests/conftest.py
index 9e1d16a..f5beb21 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -8,7 +8,7 @@ from dotfiles.repository import Repository
def repo(request, tmpdir):
path = tmpdir.ensure_dir('repo')
home = tmpdir.ensure_dir(request.param)
- return Repository(path, homedir=home)
+ return Repository(path, home)
@pytest.fixture(scope='function')
diff --git a/tests/test_dotfile.py b/tests/test_dotfile.py
index 6f3eb4e..5672c53 100644
--- a/tests/test_dotfile.py
+++ b/tests/test_dotfile.py
@@ -1,9 +1,9 @@
import pytest
-import py.path
+from pathlib import Path
from dotfiles.dotfile import Dotfile
-from dotfiles.exceptions import \
- IsSymlink, NotASymlink, TargetExists, TargetMissing, Exists
+from dotfiles.exceptions import IsSymlink, NotASymlink, TargetExists, \
+ TargetMissing, Exists
def _make_dotfile(repo, name, target=None):