diff options
-rw-r--r-- | dotfiles/core.py | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/dotfiles/core.py b/dotfiles/core.py index e3d4a9b..84b383e 100644 --- a/dotfiles/core.py +++ b/dotfiles/core.py @@ -1,12 +1,3 @@ -# -*- coding: utf-8 -*- - -""" -dotfiles.core -~~~~~~~~~~~~~ - -This module provides the basic functionality of dotfiles. -""" - import os import os.path import shutil @@ -112,15 +103,28 @@ class Dotfile(object): class Dotfiles(object): """A Dotfiles Repository.""" - __attrs__ = ['homedir', 'repository', 'prefix', 'ignore', 'externals', - 'packages', 'dry_run'] + defaults = { + 'prefix': '', + 'packages': set(), + 'externals': dict(), + 'ignore': set(['.dotfilesrc']), + 'homedir': os.path.expanduser('~/'), + 'path': os.path.expanduser('~/Dotfiles'), + } def __init__(self, **kwargs): - # Map args from kwargs to instance-local variables - for k, v in kwargs.items(): - if k in self.__attrs__: - setattr(self, k, v) + # merge provided arguments with defaults into configuration + configuration = {key: kwargs.get(key, self.defaults[key]) + for key in self.defaults} + + # map configuration items to instance-local variables + for k, v in configuration.items(): + setattr(self, k, v) + + # FIXME: compatibility shims, remove these + self.dry_run = False + self.repository = self.path self._load() |