From 2837c58f4a1b6441f9ecfe2cae89bd4a96e850db Mon Sep 17 00:00:00 2001 From: Jon Bernard Date: Sat, 21 Feb 2015 23:08:22 -0500 Subject: Fix outstanding flake8 issues --- dotfiles/cli.py | 3 ++- dotfiles/core.py | 23 ++++++++++++++--------- setup.py | 9 +++++---- tests/test_basic.py | 33 ++++++++++++++++----------------- 4 files changed, 37 insertions(+), 31 deletions(-) diff --git a/dotfiles/cli.py b/dotfiles/cli.py index 89966cc..1ea86bf 100644 --- a/dotfiles/cli.py +++ b/dotfiles/cli.py @@ -91,7 +91,8 @@ def add_global_flags(parser): parser.add_option("-n", "--no-dot-prefix", action="store_true", default=False, - help="don't prefix symlinks in target directory with a '.'") + help="don't prefix symlinks in target directory " + + "with a '.'") def add_action_group(parser): diff --git a/dotfiles/core.py b/dotfiles/core.py index 42ae5bc..a0c3a40 100644 --- a/dotfiles/core.py +++ b/dotfiles/core.py @@ -59,7 +59,7 @@ class Dotfile(object): elif self.status == 'unsynced': if not force: print("Skipping \"%s\", use --force to override" - % self.basename) + % self.basename) return if os.path.isdir(self.name) and not os.path.islink(self.name): self._rmtree(self.name) @@ -159,23 +159,27 @@ class Dotfiles(object): else: add_dot = False if self.no_dot_prefix else not bool(sub_dir) self.dotfiles.append(Dotfile(dotfile[len(self.prefix):], - os.path.join(src_dir, dotfile), dst_dir, - add_dot=add_dot, dry_run=self.dry_run)) + os.path.join(src_dir, dotfile), + dst_dir, add_dot=add_dot, + dry_run=self.dry_run)) # Externals are top-level only if not sub_dir: for dotfile in self.externals.keys(): - self.dotfiles.append(Dotfile(dotfile, - os.path.expanduser(self.externals[dotfile]), - dst_dir, add_dot=not bool(sub_dir), dry_run=self.dry_run)) + self.dotfiles.append( + Dotfile(dotfile, + os.path.expanduser(self.externals[dotfile]), + dst_dir, add_dot=not bool(sub_dir), + dry_run=self.dry_run)) def _fqpn(self, dotfile, pkg_name=None): """Return the fully qualified path to a dotfile.""" if pkg_name is None: return os.path.join(self.repository, - self.prefix + os.path.basename(dotfile).strip('.')) + self.prefix + + os.path.basename(dotfile).strip('.')) return os.path.join(self.repository, self.prefix + pkg_name, - os.path.basename(dotfile)) + os.path.basename(dotfile)) def list(self, verbose=True): """List the contents of this repository.""" @@ -233,7 +237,8 @@ class Dotfiles(object): else: home = self.homedir target = self._fqpn(file) - if action == 'add' and os.path.split(target)[1] in self.packages: + if (action == 'add' and + os.path.split(target)[1] in self.packages): print("Skipping \"%s\", packages not yet supported" % file) return if sub_dir.startswith('.') or file_name.startswith('.'): diff --git a/setup.py b/setup.py index 4e841c7..8546eca 100644 --- a/setup.py +++ b/setup.py @@ -14,10 +14,11 @@ setup( open('HISTORY.rst').read()), license='ISC', packages=['dotfiles'], - entry_points = ''' - [console_scripts] - dotfiles=dotfiles.cli:main - ''', + entry_points={ + 'console_scripts': [ + 'dotfiles=dotfiles.cli:main', + ], + }, classifiers=[ 'Programming Language :: Python', 'Programming Language :: Python :: 3', diff --git a/tests/test_basic.py b/tests/test_basic.py index 41d1c0e..ad6a7ab 100644 --- a/tests/test_basic.py +++ b/tests/test_basic.py @@ -58,8 +58,8 @@ class DotfilesTestCase(unittest.TestCase): dotfiles.sync(force=True) self.assertPathEqual( - os.path.join(self.homedir, '.lastpass'), - '/tmp') + os.path.join(self.homedir, '.lastpass'), + '/tmp') def test_dispatch(self): """Test that the force option is handed on to the sync method.""" @@ -137,7 +137,8 @@ class DotfilesTestCase(unittest.TestCase): os.path.join(self.repository, 'vim')) def test_glob_ignore_pattern(self): - """ Test that the use of glob pattern matching works in the ignores list. + """ Test that the use of glob pattern matching works in the ignores + list. The following repo dir exists: @@ -150,7 +151,8 @@ class DotfilesTestCase(unittest.TestCase): vimrc.swp install.sh - Using the glob pattern dotfiles should have the following sync result in home: + Using the glob pattern dotfiles should have the following sync result + in home: .myscript.py -> Dotfiles/myscript.py .bashrc -> Dotfiles/bashrc @@ -224,7 +226,7 @@ class DotfilesTestCase(unittest.TestCase): self.assertTrue(os.path.isdir(join(self.homedir, '.package'))) for src, dst in zip(files, symlinks): self.assertTrue(is_link_to(join(self.homedir, dst), - join(self.repository, src))) + join(self.repository, src))) check_all(files, symlinks) # Add files to the repository @@ -312,7 +314,6 @@ class DotfilesTestCase(unittest.TestCase): self.assertFalse(os.path.exists( os.path.join(self.homedir, dotfile))) - def test_missing_remove(self): """Test removing a dotfile that's been removed from the repository.""" @@ -337,7 +338,6 @@ class DotfilesTestCase(unittest.TestCase): self.assertFalse(os.path.exists( os.path.join(self.homedir, '.testdotfile'))) - def test_add_package(self): """ Test adding a package that isn't already in the repository @@ -345,7 +345,7 @@ class DotfilesTestCase(unittest.TestCase): """ package_dir = os.path.join(self.homedir, - '.%s/%s' % ('config', 'gtk-3.0')) + '.%s/%s' % ('config', 'gtk-3.0')) os.makedirs(package_dir) touch('%s/testfile' % package_dir) @@ -389,7 +389,7 @@ class DotfilesTestCase(unittest.TestCase): """ package_dir = os.path.join(self.homedir, - '.%s/%s' % ('config', 'gtk-3.0')) + '.%s/%s' % ('config', 'gtk-3.0')) os.makedirs(package_dir) touch('%s/testfile' % package_dir) @@ -405,7 +405,6 @@ class DotfilesTestCase(unittest.TestCase): self.assertTrue(os.path.islink( os.path.join(self.homedir, '.config/gtk-3.0'))) - @pytest.mark.xfail() def test_package_and_prefix(self): """Test syncing a package when using a non-default prefix.""" @@ -415,13 +414,13 @@ class DotfilesTestCase(unittest.TestCase): touch('%s/testfile' % package_dir) dotfiles = Dotfiles(homedir=self.homedir, - path=self.repository, - prefix='.', - ignore=[], - externals={}, - packages=['.config'], - dry_run=False, - quiet=True) + path=self.repository, + prefix='.', + ignore=[], + externals={}, + packages=['.config'], + dry_run=False, + quiet=True) dotfiles.sync() -- cgit v1.2.3