aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Jon Bernard <jbernard@tuxion.com> 2016-07-18 15:48:18 -0400
committerGravatar Jon Bernard <jbernard@tuxion.com> 2016-07-18 15:48:18 -0400
commitbb3d64e7c64420e5d1e05779beebe2bed3956b51 (patch)
tree2f66c360473b7497331411c437cbc1f66167e752
parentaf991f612a54d347deb5449aec273012c2c059df (diff)
downloaddotfiles-bb3d64e7c64420e5d1e05779beebe2bed3956b51.tar.gz
dotfiles-bb3d64e7c64420e5d1e05779beebe2bed3956b51.tar.bz2
dotfiles-bb3d64e7c64420e5d1e05779beebe2bed3956b51.zip
Move repositories class into repository file
-rw-r--r--dotfiles/cli.py31
-rw-r--r--dotfiles/repository.py26
2 files changed, 27 insertions, 30 deletions
diff --git a/dotfiles/cli.py b/dotfiles/cli.py
index 5a0dbf4..f8181ad 100644
--- a/dotfiles/cli.py
+++ b/dotfiles/cli.py
@@ -1,21 +1,11 @@
-import os
-import copy
import click
-import py.path
try:
import ConfigParser as configparser
except ImportError:
import configparser
-from .repository import Repository
from .exceptions import DotfileException
-
-
-DEFAULT_DOT = False
-DEFAULT_REPO = os.path.expanduser('~/Dotfiles')
-DEFAULT_IGNORE_PATTERNS = ['README*', '.git', '.hg', '*~']
-
CONTEXT_SETTINGS = dict(auto_envvar_prefix='DOTFILES',
help_option_names=['-h', '--help'])
@@ -73,26 +63,7 @@ class Config(object):
return self._get_setting('ignore_patterns')
-class Repositories(object):
-
- def __init__(self, paths, dot):
- config = Config(paths)
-
- self.repos = []
- # for path in eval(config.settings['repositories']):
- for path in config.repositories:
- # will this ever change, why is this in the loop?
- ignore_patterns = config.ignore_patterns
- self.repos.append(
- Repository(py.path.local(path, expanduser=True),
- ignore_patterns=ignore_patterns,
- preserve_leading_dot=dot))
-
- def __len__(self):
- return len(self.repos)
-
- def __getitem__(self, index):
- return self.repos[index]
+from .repository import Repositories, DEFAULT_PATH, DEFAULT_REMOVE_LEADING_DOT
def get_single_repo(repos):
diff --git a/dotfiles/repository.py b/dotfiles/repository.py
index 836e0b5..79b85b5 100644
--- a/dotfiles/repository.py
+++ b/dotfiles/repository.py
@@ -6,6 +6,32 @@ from .dotfile import Dotfile
from .exceptions import DotfileException, TargetIgnored
from .exceptions import NotRootedInHome, InRepository, IsDirectory
+DEFAULT_PATH = '~/Dotfiles'
+DEFAULT_REMOVE_LEADING_DOT = True
+DEFAULT_IGNORE_PATTERNS = ['.git', 'README*', '*~']
+DEFAULT_HOMEDIR = py.path.local('~/', expanduser=True)
+
+
+class Repositories(object):
+ """An iterable collection of repository objects."""
+
+ def __init__(self, paths, dot):
+ if not paths:
+ paths = [DEFAULT_PATH]
+ if dot is None:
+ dot = DEFAULT_REMOVE_LEADING_DOT
+
+ self.repos = []
+ for path in paths:
+ path = py.path.local(path, expanduser=True)
+ self.repos.append(Repository(path, dot))
+
+ def __len__(self):
+ return len(self.repos)
+
+ def __getitem__(self, index):
+ return self.repos[index]
+
class Repository(object):
"""A repository is a directory that contains dotfiles.