mirror of
https://github.com/deadc0de6/dotdrop.git
synced 2026-02-15 16:15:05 +00:00
add pyflakes and fix errors
This commit is contained in:
@@ -109,6 +109,5 @@ class Comparator:
|
|||||||
opts=self.diffopts, debug=self.debug)
|
opts=self.diffopts, debug=self.debug)
|
||||||
if header:
|
if header:
|
||||||
lshort = os.path.basename(left)
|
lshort = os.path.basename(left)
|
||||||
rshort = os.path.basename(right)
|
|
||||||
diff = '=> diff \"{}\":\n{}'.format(lshort, diff)
|
diff = '=> diff \"{}\":\n{}'.format(lshort, diff)
|
||||||
return diff
|
return diff
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ from dotdrop.dotfile import Dotfile
|
|||||||
from dotdrop.templategen import Templategen
|
from dotdrop.templategen import Templategen
|
||||||
from dotdrop.logger import Logger
|
from dotdrop.logger import Logger
|
||||||
from dotdrop.action import Action, Transform
|
from dotdrop.action import Action, Transform
|
||||||
from dotdrop.utils import *
|
from dotdrop.utils import strip_home, shell
|
||||||
from dotdrop.linktypes import LinkTypes
|
from dotdrop.linktypes import LinkTypes
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -173,7 +173,7 @@ def cmd_update(o):
|
|||||||
showpatch = o.update_showpatch
|
showpatch = o.update_showpatch
|
||||||
|
|
||||||
updater = Updater(o.dotpath, o.dotfiles, o.variables,
|
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)
|
ignore=ignore, showpatch=showpatch)
|
||||||
if not iskey:
|
if not iskey:
|
||||||
# update paths
|
# update paths
|
||||||
|
|||||||
@@ -12,8 +12,8 @@ class Dotfile:
|
|||||||
|
|
||||||
def __init__(self, key, dst, src,
|
def __init__(self, key, dst, src,
|
||||||
actions={}, trans_r=None, trans_w=None,
|
actions={}, trans_r=None, trans_w=None,
|
||||||
link=LinkTypes.NOLINK, cmpignore=[], noempty=False,
|
link=LinkTypes.NOLINK, cmpignore=[],
|
||||||
upignore=[]):
|
noempty=False, upignore=[]):
|
||||||
"""constructor
|
"""constructor
|
||||||
@key: dotfile key
|
@key: dotfile key
|
||||||
@dst: dotfile dst (in user's home usually)
|
@dst: dotfile dst (in user's home usually)
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
author: deadc0de6 (https://github.com/deadc0de6)
|
author: deadc0de6 (https://github.com/deadc0de6)
|
||||||
Copyright (c) 2017, deadc0de6
|
Copyright (c) 2017, deadc0de6
|
||||||
|
|
||||||
provides logging functions
|
provide logging functions
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
|||||||
@@ -157,6 +157,7 @@ class Options:
|
|||||||
# the dotfiles
|
# the dotfiles
|
||||||
self.dotfiles = self.conf.eval_dotfiles(self.profile, self.variables,
|
self.dotfiles = self.conf.eval_dotfiles(self.profile, self.variables,
|
||||||
debug=self.debug).copy()
|
debug=self.debug).copy()
|
||||||
|
# the profiles
|
||||||
self.profiles = self.conf.get_profiles()
|
self.profiles = self.conf.get_profiles()
|
||||||
|
|
||||||
def _print_attr(self):
|
def _print_attr(self):
|
||||||
|
|||||||
@@ -20,15 +20,14 @@ TILD = '~'
|
|||||||
|
|
||||||
class Updater:
|
class Updater:
|
||||||
|
|
||||||
def __init__(self, dotpath, dotfiles, variables, dry, safe,
|
def __init__(self, dotpath, dotfiles, variables, dry=False, safe=True,
|
||||||
iskey=False, debug=False, ignore=[], showpatch=False):
|
debug=False, ignore=[], showpatch=False):
|
||||||
"""constructor
|
"""constructor
|
||||||
@dotpath: path where dotfiles are stored
|
@dotpath: path where dotfiles are stored
|
||||||
@dotfiles: dotfiles for this profile
|
@dotfiles: dotfiles for this profile
|
||||||
@variables: dictionary of variables for the templates
|
@variables: dictionary of variables for the templates
|
||||||
@dry: simulate
|
@dry: simulate
|
||||||
@safe: ask for overwrite if True
|
@safe: ask for overwrite if True
|
||||||
@iskey: will the update be called on keys or path
|
|
||||||
@debug: enable debug
|
@debug: enable debug
|
||||||
@ignore: pattern to ignore when updating
|
@ignore: pattern to ignore when updating
|
||||||
@showpatch: show patch if dotfile to update is a template
|
@showpatch: show patch if dotfile to update is a template
|
||||||
@@ -38,7 +37,6 @@ class Updater:
|
|||||||
self.variables = variables
|
self.variables = variables
|
||||||
self.dry = dry
|
self.dry = dry
|
||||||
self.safe = safe
|
self.safe = safe
|
||||||
self.iskey = iskey
|
|
||||||
self.debug = debug
|
self.debug = debug
|
||||||
self.ignore = ignore
|
self.ignore = ignore
|
||||||
self.showpatch = showpatch
|
self.showpatch = showpatch
|
||||||
|
|||||||
@@ -10,8 +10,6 @@ import tempfile
|
|||||||
import os
|
import os
|
||||||
import uuid
|
import uuid
|
||||||
import shlex
|
import shlex
|
||||||
import functools
|
|
||||||
import operator
|
|
||||||
import fnmatch
|
import fnmatch
|
||||||
from shutil import rmtree
|
from shutil import rmtree
|
||||||
|
|
||||||
|
|||||||
@@ -2,3 +2,4 @@ pycodestyle; python_version >= '3.0'
|
|||||||
nose; python_version >= '3.0'
|
nose; python_version >= '3.0'
|
||||||
coverage; python_version >= '3.0'
|
coverage; python_version >= '3.0'
|
||||||
coveralls; python_version >= '3.0'
|
coveralls; python_version >= '3.0'
|
||||||
|
pyflakes; python_version >= '3.0'
|
||||||
|
|||||||
4
tests.sh
4
tests.sh
@@ -12,6 +12,10 @@ pycodestyle --ignore=W605 dotdrop/
|
|||||||
pycodestyle tests/
|
pycodestyle tests/
|
||||||
pycodestyle scripts/
|
pycodestyle scripts/
|
||||||
|
|
||||||
|
# pyflakes tests
|
||||||
|
pyflakes dotdrop/
|
||||||
|
pyflakes tests/
|
||||||
|
|
||||||
# retrieve the nosetests binary
|
# retrieve the nosetests binary
|
||||||
set +e
|
set +e
|
||||||
nosebin="nosetests"
|
nosebin="nosetests"
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import tempfile
|
|||||||
|
|
||||||
from dotdrop.options import Options
|
from dotdrop.options import Options
|
||||||
from dotdrop.linktypes import LinkTypes
|
from dotdrop.linktypes import LinkTypes
|
||||||
from dotdrop.utils import *
|
from dotdrop.utils import strip_home
|
||||||
|
|
||||||
TMPSUFFIX = '.dotdrop'
|
TMPSUFFIX = '.dotdrop'
|
||||||
|
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ class TestCompare(unittest.TestCase):
|
|||||||
comp = Comparator()
|
comp = Comparator()
|
||||||
results = {}
|
results = {}
|
||||||
for dotfile in dotfiles:
|
for dotfile in dotfiles:
|
||||||
|
path = os.path.expanduser(dotfile.dst)
|
||||||
ret, insttmp = inst.install_to_temp(t, tmp, dotfile.src,
|
ret, insttmp = inst.install_to_temp(t, tmp, dotfile.src,
|
||||||
dotfile.dst)
|
dotfile.dst)
|
||||||
if not ret:
|
if not ret:
|
||||||
@@ -42,7 +43,6 @@ class TestCompare(unittest.TestCase):
|
|||||||
continue
|
continue
|
||||||
diff = comp.compare(insttmp, dotfile.dst,
|
diff = comp.compare(insttmp, dotfile.dst,
|
||||||
ignore=['whatever', 'whatelse'])
|
ignore=['whatever', 'whatelse'])
|
||||||
path = os.path.expanduser(dotfile.dst)
|
|
||||||
results[path] = diff == ''
|
results[path] = diff == ''
|
||||||
return results
|
return results
|
||||||
|
|
||||||
|
|||||||
@@ -8,11 +8,9 @@ basic unittest for the config parser
|
|||||||
import unittest
|
import unittest
|
||||||
import os
|
import os
|
||||||
import yaml
|
import yaml
|
||||||
import tempfile
|
|
||||||
import shutil
|
|
||||||
|
|
||||||
from dotdrop.config import Cfg
|
from dotdrop.config import Cfg
|
||||||
from tests.helpers import *
|
from tests.helpers import get_tempdir, clean, create_fake_config
|
||||||
|
|
||||||
|
|
||||||
class TestConfig(unittest.TestCase):
|
class TestConfig(unittest.TestCase):
|
||||||
@@ -88,7 +86,6 @@ class TestConfig(unittest.TestCase):
|
|||||||
self.assertTrue(conf is not None)
|
self.assertTrue(conf is not None)
|
||||||
|
|
||||||
# test profile
|
# test profile
|
||||||
opts = conf.get_settings()
|
|
||||||
profiles = conf.get_profiles()
|
profiles = conf.get_profiles()
|
||||||
self.assertTrue(pf1key in profiles)
|
self.assertTrue(pf1key in profiles)
|
||||||
self.assertTrue(pf2key in profiles)
|
self.assertTrue(pf2key in profiles)
|
||||||
|
|||||||
@@ -13,9 +13,12 @@ from dotdrop.dotdrop import cmd_importer
|
|||||||
from dotdrop.dotdrop import cmd_list_profiles
|
from dotdrop.dotdrop import cmd_list_profiles
|
||||||
from dotdrop.dotdrop import cmd_list_files
|
from dotdrop.dotdrop import cmd_list_files
|
||||||
from dotdrop.dotdrop import cmd_update
|
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):
|
class TestImport(unittest.TestCase):
|
||||||
|
|||||||
@@ -7,15 +7,15 @@ basic unittest for the compare function
|
|||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
import os
|
import os
|
||||||
import yaml
|
|
||||||
|
|
||||||
from dotdrop.config import Cfg
|
|
||||||
from dotdrop.dotdrop import cmd_list_profiles
|
from dotdrop.dotdrop import cmd_list_profiles
|
||||||
from dotdrop.dotdrop import cmd_list_files
|
from dotdrop.dotdrop import cmd_list_files
|
||||||
from dotdrop.dotdrop import cmd_detail
|
from dotdrop.dotdrop import cmd_detail
|
||||||
from dotdrop.dotdrop import cmd_importer
|
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):
|
class TestListings(unittest.TestCase):
|
||||||
|
|||||||
Reference in New Issue
Block a user