mirror of
https://github.com/deadc0de6/dotdrop.git
synced 2026-02-04 12:46:44 +00:00
add pyflakes and fix errors
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
author: deadc0de6 (https://github.com/deadc0de6)
|
||||
Copyright (c) 2017, deadc0de6
|
||||
|
||||
provides logging functions
|
||||
provide logging functions
|
||||
"""
|
||||
|
||||
import sys
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -10,8 +10,6 @@ import tempfile
|
||||
import os
|
||||
import uuid
|
||||
import shlex
|
||||
import functools
|
||||
import operator
|
||||
import fnmatch
|
||||
from shutil import rmtree
|
||||
|
||||
|
||||
@@ -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'
|
||||
|
||||
4
tests.sh
4
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"
|
||||
|
||||
@@ -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'
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user