diff --git a/dotdrop/comparator.py b/dotdrop/comparator.py index 254a682..c930d3f 100644 --- a/dotdrop/comparator.py +++ b/dotdrop/comparator.py @@ -109,6 +109,5 @@ class Comparator: opts=self.diffopts, debug=self.debug) if header: lshort = os.path.basename(left) - rshort = os.path.basename(right) diff = '=> diff \"{}\":\n{}'.format(lshort, diff) return diff diff --git a/dotdrop/config.py b/dotdrop/config.py index c2cb09b..6c68718 100644 --- a/dotdrop/config.py +++ b/dotdrop/config.py @@ -14,7 +14,7 @@ from dotdrop.dotfile import Dotfile from dotdrop.templategen import Templategen from dotdrop.logger import Logger from dotdrop.action import Action, Transform -from dotdrop.utils import * +from dotdrop.utils import strip_home, shell from dotdrop.linktypes import LinkTypes diff --git a/dotdrop/dotdrop.py b/dotdrop/dotdrop.py index f2f0156..52ea58d 100644 --- a/dotdrop/dotdrop.py +++ b/dotdrop/dotdrop.py @@ -173,7 +173,7 @@ def cmd_update(o): showpatch = o.update_showpatch updater = Updater(o.dotpath, o.dotfiles, o.variables, - o.dry, o.safe, iskey=iskey, debug=o.debug, + dry=o.dry, safe=o.safe, debug=o.debug, ignore=ignore, showpatch=showpatch) if not iskey: # update paths diff --git a/dotdrop/dotfile.py b/dotdrop/dotfile.py index 0957690..2b3b090 100644 --- a/dotdrop/dotfile.py +++ b/dotdrop/dotfile.py @@ -12,8 +12,8 @@ class Dotfile: def __init__(self, key, dst, src, actions={}, trans_r=None, trans_w=None, - link=LinkTypes.NOLINK, cmpignore=[], noempty=False, - upignore=[]): + link=LinkTypes.NOLINK, cmpignore=[], + noempty=False, upignore=[]): """constructor @key: dotfile key @dst: dotfile dst (in user's home usually) diff --git a/dotdrop/logger.py b/dotdrop/logger.py index bccd30e..fec1e07 100644 --- a/dotdrop/logger.py +++ b/dotdrop/logger.py @@ -2,7 +2,7 @@ author: deadc0de6 (https://github.com/deadc0de6) Copyright (c) 2017, deadc0de6 -provides logging functions +provide logging functions """ import sys diff --git a/dotdrop/options.py b/dotdrop/options.py index b0319bf..5be5534 100644 --- a/dotdrop/options.py +++ b/dotdrop/options.py @@ -157,6 +157,7 @@ class Options: # the dotfiles self.dotfiles = self.conf.eval_dotfiles(self.profile, self.variables, debug=self.debug).copy() + # the profiles self.profiles = self.conf.get_profiles() def _print_attr(self): diff --git a/dotdrop/updater.py b/dotdrop/updater.py index cffdc35..030234e 100644 --- a/dotdrop/updater.py +++ b/dotdrop/updater.py @@ -20,15 +20,14 @@ TILD = '~' class Updater: - def __init__(self, dotpath, dotfiles, variables, dry, safe, - iskey=False, debug=False, ignore=[], showpatch=False): + def __init__(self, dotpath, dotfiles, variables, dry=False, safe=True, + debug=False, ignore=[], showpatch=False): """constructor @dotpath: path where dotfiles are stored @dotfiles: dotfiles for this profile @variables: dictionary of variables for the templates @dry: simulate @safe: ask for overwrite if True - @iskey: will the update be called on keys or path @debug: enable debug @ignore: pattern to ignore when updating @showpatch: show patch if dotfile to update is a template @@ -38,7 +37,6 @@ class Updater: self.variables = variables self.dry = dry self.safe = safe - self.iskey = iskey self.debug = debug self.ignore = ignore self.showpatch = showpatch diff --git a/dotdrop/utils.py b/dotdrop/utils.py index 55422a0..70b1a61 100644 --- a/dotdrop/utils.py +++ b/dotdrop/utils.py @@ -10,8 +10,6 @@ import tempfile import os import uuid import shlex -import functools -import operator import fnmatch from shutil import rmtree diff --git a/tests-requirements.txt b/tests-requirements.txt index 3aea72f..2172e29 100644 --- a/tests-requirements.txt +++ b/tests-requirements.txt @@ -2,3 +2,4 @@ pycodestyle; python_version >= '3.0' nose; python_version >= '3.0' coverage; python_version >= '3.0' coveralls; python_version >= '3.0' +pyflakes; python_version >= '3.0' diff --git a/tests.sh b/tests.sh index 7a58f99..96d5fe0 100755 --- a/tests.sh +++ b/tests.sh @@ -12,6 +12,10 @@ pycodestyle --ignore=W605 dotdrop/ pycodestyle tests/ pycodestyle scripts/ +# pyflakes tests +pyflakes dotdrop/ +pyflakes tests/ + # retrieve the nosetests binary set +e nosebin="nosetests" diff --git a/tests/helpers.py b/tests/helpers.py index 4a8f195..aadf9b8 100644 --- a/tests/helpers.py +++ b/tests/helpers.py @@ -12,7 +12,7 @@ import tempfile from dotdrop.options import Options from dotdrop.linktypes import LinkTypes -from dotdrop.utils import * +from dotdrop.utils import strip_home TMPSUFFIX = '.dotdrop' diff --git a/tests/test_compare.py b/tests/test_compare.py index cfed415..567bf92 100644 --- a/tests/test_compare.py +++ b/tests/test_compare.py @@ -35,6 +35,7 @@ class TestCompare(unittest.TestCase): comp = Comparator() results = {} for dotfile in dotfiles: + path = os.path.expanduser(dotfile.dst) ret, insttmp = inst.install_to_temp(t, tmp, dotfile.src, dotfile.dst) if not ret: @@ -42,7 +43,6 @@ class TestCompare(unittest.TestCase): continue diff = comp.compare(insttmp, dotfile.dst, ignore=['whatever', 'whatelse']) - path = os.path.expanduser(dotfile.dst) results[path] = diff == '' return results diff --git a/tests/test_config.py b/tests/test_config.py index 567d091..460d6c7 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -8,11 +8,9 @@ basic unittest for the config parser import unittest import os import yaml -import tempfile -import shutil from dotdrop.config import Cfg -from tests.helpers import * +from tests.helpers import get_tempdir, clean, create_fake_config class TestConfig(unittest.TestCase): @@ -88,7 +86,6 @@ class TestConfig(unittest.TestCase): self.assertTrue(conf is not None) # test profile - opts = conf.get_settings() profiles = conf.get_profiles() self.assertTrue(pf1key in profiles) self.assertTrue(pf2key in profiles) diff --git a/tests/test_import.py b/tests/test_import.py index fd51769..57b370b 100644 --- a/tests/test_import.py +++ b/tests/test_import.py @@ -13,9 +13,12 @@ from dotdrop.dotdrop import cmd_importer from dotdrop.dotdrop import cmd_list_profiles from dotdrop.dotdrop import cmd_list_files from dotdrop.dotdrop import cmd_update -from dotdrop.config import Cfg +from dotdrop.linktypes import LinkTypes -from tests.helpers import * +from tests.helpers import get_path_strip_version, edit_content, \ + load_options, create_random_file, \ + clean, get_string, get_dotfile_from_yaml, \ + get_tempdir, create_fake_config, create_dir class TestImport(unittest.TestCase): diff --git a/tests/test_listings.py b/tests/test_listings.py index e9022c9..e07c5a5 100644 --- a/tests/test_listings.py +++ b/tests/test_listings.py @@ -7,15 +7,15 @@ basic unittest for the compare function import unittest import os -import yaml -from dotdrop.config import Cfg from dotdrop.dotdrop import cmd_list_profiles from dotdrop.dotdrop import cmd_list_files from dotdrop.dotdrop import cmd_detail from dotdrop.dotdrop import cmd_importer -from tests.helpers import * +from tests.helpers import create_dir, get_string, get_tempdir, \ + create_random_file, load_options, \ + create_fake_config, clean class TestListings(unittest.TestCase):