diff options
-rw-r--r-- | .gitignore | 3 | ||||
-rw-r--r-- | AUTHORS.rst | 1 | ||||
-rw-r--r-- | HISTORY.rst | 8 | ||||
-rw-r--r-- | README.rst | 2 | ||||
-rw-r--r-- | dotfiles/cli.py | 2 | ||||
-rw-r--r-- | dotfiles/core.py | 27 | ||||
-rwxr-xr-x | setup.py | 8 | ||||
-rwxr-xr-x | test_dotfiles.py | 4 |
8 files changed, 39 insertions, 16 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0d1a15e --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +*.pyc +*.pyo +__pycache__/ diff --git a/AUTHORS.rst b/AUTHORS.rst index 2d33bcb..aa0ecaa 100644 --- a/AUTHORS.rst +++ b/AUTHORS.rst @@ -13,3 +13,4 @@ Patches and Suggestions - Remco Wendt <remco@maykinmedia.nl> - Sebastian Rahlf - Reinout van Rees <reinout@vanrees.org> +- Daniel Harding diff --git a/HISTORY.rst b/HISTORY.rst index 78da6ac..cf407a8 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -1,6 +1,14 @@ History ------- +0.5.3 ++++++ + +* Update remaining references to 'unmanaged' +* Allow ~ in configuration file external targets +* Make source compatible with Python 3 +* Add specific Python version trove classifiers + 0.5.2 +++++ @@ -30,7 +30,7 @@ Interface Remove dotfile(s) from the repository. ``-s, --sync`` - Update dotfile symlinks. You can overwrite unmanaged files with ``-f`` or + Update dotfile symlinks. You can overwrite colliding files with ``-f`` or ``--force``. ``-m, --move`` diff --git a/dotfiles/cli.py b/dotfiles/cli.py index 1de9f1c..c14c0e8 100644 --- a/dotfiles/cli.py +++ b/dotfiles/cli.py @@ -59,7 +59,7 @@ def add_global_flags(parser): parser.add_option("-f", "--force", action="store_true", dest="force", default=False, - help="ignore unmanaged dotfiles (use with --sync)") + help="overwrite colliding dotfiles (use with --sync)") parser.add_option("-R", "--repo", type="string", dest="repository", diff --git a/dotfiles/core.py b/dotfiles/core.py index 76a354d..26ff48a 100644 --- a/dotfiles/core.py +++ b/dotfiles/core.py @@ -12,7 +12,7 @@ import shutil import fnmatch -__version__ = '0.5.2' +__version__ = '0.5.3' __author__ = 'Jon Bernard' __license__ = 'ISC' @@ -30,14 +30,15 @@ class Dotfile(object): if not os.path.lexists(self.name): self.status = 'missing' elif os.path.realpath(self.name) != self.target: - self.status = 'unmanaged' + self.status = 'unsynced' def sync(self, force): if self.status == 'missing': os.symlink(self.target, self.name) - elif self.status == 'unmanaged': + elif self.status == 'unsynced': if not force: - print "Skipping \"%s\", use --force to override" % self.basename + print("Skipping \"%s\", use --force to override" + % self.basename) return if os.path.isdir(self.name) and not os.path.islink(self.name): shutil.rmtree(self.name) @@ -47,17 +48,17 @@ class Dotfile(object): def add(self): if self.status == 'missing': - print "Skipping \"%s\", file not found" % self.basename + print("Skipping \"%s\", file not found" % self.basename) return if self.status == '': - print "Skipping \"%s\", already managed" % self.basename + print("Skipping \"%s\", already managed" % self.basename) return shutil.move(self.name, self.target) os.symlink(self.target, self.name) def remove(self): if self.status != '': - print "Skipping \"%s\", file is %s" % (self.basename, self.status) + print("Skipping \"%s\", file is %s" % (self.basename, self.status)) return os.remove(self.name) shutil.move(self.target, self.name) @@ -74,8 +75,9 @@ class Dotfiles(object): def __init__(self, **kwargs): # Map args from kwargs to instance-local variables - map(lambda k, v: (k in self.__attrs__) and setattr(self, k, v), - kwargs.iterkeys(), kwargs.itervalues()) + for k, v in kwargs.items(): + if k in self.__attrs__: + setattr(self, k, v) self._load() @@ -96,7 +98,8 @@ class Dotfiles(object): os.path.join(self.repository, dotfile), self.homedir)) for dotfile in self.externals.keys(): - self.dotfiles.append(Dotfile(dotfile, self.externals[dotfile], + self.dotfiles.append(Dotfile(dotfile, + os.path.expanduser(self.externals[dotfile]), self.homedir)) def _fqpn(self, dotfile): @@ -110,7 +113,7 @@ class Dotfiles(object): for dotfile in sorted(self.dotfiles, key=lambda dotfile: dotfile.name): if dotfile.status or verbose: - print dotfile + print(dotfile) def check(self): """List only unsynced and/or missing dotfiles.""" @@ -141,7 +144,7 @@ class Dotfiles(object): if os.path.basename(file).startswith('.'): getattr(Dotfile(file, self._fqpn(file), self.homedir), action)() else: - print "Skipping \"%s\", not a dotfile" % file + print("Skipping \"%s\", not a dotfile" % file) def move(self, target): """Move the repository to another location.""" @@ -40,6 +40,14 @@ setup(name='dotfiles', 'License :: OSI Approved :: ISC License (ISCL)' 'Natural Language :: English', 'Programming Language :: Python', + 'Programming Language :: Python :: 2', + 'Programming Language :: Python :: 2.5', + 'Programming Language :: Python :: 2.6', + 'Programming Language :: Python :: 2.7', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.0', + 'Programming Language :: Python :: 3.1', + 'Programming Language :: Python :: 3.2', ), scripts=['bin/dotfiles'], ) diff --git a/test_dotfiles.py b/test_dotfiles.py index f9b6b46..b892003 100755 --- a/test_dotfiles.py +++ b/test_dotfiles.py @@ -12,7 +12,7 @@ from dotfiles import core def touch(fname, times=None): - with file(fname, 'a'): + with open(fname, 'a'): os.utime(fname, times) @@ -85,7 +85,7 @@ class DotfilesTestCase(unittest.TestCase): os.path.join(self.homedir, '.bashrc'), os.path.join(target, 'bashrc')) - def test_sync_unmanaged_directory_symlink(self): + def test_force_sync_directory_symlink(self): """Test a forced sync on a directory symlink. A bug was reported where a user wanted to replace a dotfile repository |