aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVirgil Dupras <hsoft@hardcoded.net>2018-08-14 11:14:09 -0400
committerVirgil Dupras <hsoft@hardcoded.net>2018-08-14 11:14:09 -0400
commit23368d93037c7134847e99ff9772e2e2fbc9daa3 (patch)
tree74e5ecb11b744d2b576b1a5da4fb6895246fe6c3
parentRemove gentoolkit.deprecated (diff)
downloadgentoolkit-23368d93037c7134847e99ff9772e2e2fbc9daa3.tar.gz
gentoolkit-23368d93037c7134847e99ff9772e2e2fbc9daa3.tar.bz2
gentoolkit-23368d93037c7134847e99ff9772e2e2fbc9daa3.zip
Add (and fix) flake8 checks in tox
Add config in tox to run flake8 checks. For now, only "F*" errors are checked (errors reported by pyflakes). pep8 style checks are ignored for now. This is accompanied by changes in the code that are necessary to silence these errors. Most of them were about unused imports, but also unsed referenced and even undefined ones (meaning that this code path was broken, gotta increase test coverage). This setup will replace pylint which reports way too many errors to be usable (see next commit).
-rw-r--r--pym/gentoolkit/base.py5
-rw-r--r--pym/gentoolkit/dependencies.py3
-rw-r--r--pym/gentoolkit/eclean/cli.py2
-rw-r--r--pym/gentoolkit/eclean/exclude.py5
-rw-r--r--pym/gentoolkit/eclean/output.py7
-rw-r--r--pym/gentoolkit/eclean/pkgindex.py12
-rw-r--r--pym/gentoolkit/eclean/search.py4
-rw-r--r--pym/gentoolkit/enalyze/__init__.py2
-rw-r--r--pym/gentoolkit/enalyze/analyze.py10
-rw-r--r--pym/gentoolkit/enalyze/lib.py4
-rw-r--r--pym/gentoolkit/enalyze/output.py1
-rw-r--r--pym/gentoolkit/enalyze/rebuild.py4
-rw-r--r--pym/gentoolkit/equery/__init__.py1
-rw-r--r--pym/gentoolkit/equery/changes.py1
-rw-r--r--pym/gentoolkit/equery/has.py4
-rw-r--r--pym/gentoolkit/equery/list_.py2
-rw-r--r--pym/gentoolkit/equery/meta.py1
-rw-r--r--pym/gentoolkit/equery/uses.py3
-rw-r--r--pym/gentoolkit/equery/which.py2
-rw-r--r--pym/gentoolkit/eshowkw/keywords_content.py2
-rw-r--r--pym/gentoolkit/eshowkw/keywords_header.py11
-rw-r--r--pym/gentoolkit/flag.py2
-rw-r--r--pym/gentoolkit/formatters.py3
-rw-r--r--pym/gentoolkit/glsa/__init__.py5
-rw-r--r--pym/gentoolkit/helpers.py4
-rw-r--r--pym/gentoolkit/module_base.py3
-rw-r--r--pym/gentoolkit/package.py2
-rw-r--r--pym/gentoolkit/pprinter.py1
-rw-r--r--pym/gentoolkit/revdep_rebuild/analyse.py2
-rw-r--r--pym/gentoolkit/revdep_rebuild/cache.py4
-rw-r--r--pym/gentoolkit/revdep_rebuild/collect.py4
-rw-r--r--pym/gentoolkit/revdep_rebuild/settings.py4
-rw-r--r--pym/gentoolkit/test/eclean/creator.py10
-rw-r--r--pym/gentoolkit/test/eclean/distsupport.py11
-rwxr-xr-xpym/gentoolkit/test/eclean/test_clean.py241
-rwxr-xr-xpym/gentoolkit/test/eclean/test_search.py6
-rw-r--r--pym/gentoolkit/test/test_atom.py2
-rw-r--r--pym/gentoolkit/test/test_cpv.py2
-rw-r--r--pym/gentoolkit/test/test_helpers.py59
-rw-r--r--pym/gentoolkit/test/test_keyword.py3
-rw-r--r--tox.ini13
41 files changed, 215 insertions, 252 deletions
diff --git a/pym/gentoolkit/base.py b/pym/gentoolkit/base.py
index 7803d2d..bc08561 100644
--- a/pym/gentoolkit/base.py
+++ b/pym/gentoolkit/base.py
@@ -13,15 +13,10 @@ from __future__ import print_function
__docformat__ = 'epytext'
-import errno
import os
import sys
-import time
-from getopt import gnu_getopt, GetoptError
import gentoolkit
-from gentoolkit import errors
-#from gentoolkit.textwrap_ import TextWrapper
import gentoolkit.pprinter as pp
from gentoolkit.formatters import format_options
diff --git a/pym/gentoolkit/dependencies.py b/pym/gentoolkit/dependencies.py
index 3019a54..117342a 100644
--- a/pym/gentoolkit/dependencies.py
+++ b/pym/gentoolkit/dependencies.py
@@ -18,7 +18,6 @@ from portage.dep import paren_reduce
from gentoolkit import errors
from gentoolkit.atom import Atom
-from gentoolkit.cpv import CPV
from gentoolkit.helpers import uniqify
from gentoolkit.query import Query
@@ -165,7 +164,7 @@ class Dependencies(Query):
if depth < max_depth or max_depth == 0:
# result is passed in and added to directly
# so rdeps is disposable
- rdeps = pkgdep.deps.graph_depends(
+ rdeps = pkgdep.deps.graph_depends( # noqa
max_depth=max_depth,
printer_fn=printer_fn,
# The rest of these are only used internally:
diff --git a/pym/gentoolkit/eclean/cli.py b/pym/gentoolkit/eclean/cli.py
index 7ffb596..1d2f52b 100644
--- a/pym/gentoolkit/eclean/cli.py
+++ b/pym/gentoolkit/eclean/cli.py
@@ -23,7 +23,7 @@ import time
import getopt
import portage
-from portage.output import white, yellow, turquoise, green, teal, red
+from portage.output import white, yellow, turquoise, green
import gentoolkit.pprinter as pp
from gentoolkit.eclean.search import (DistfilesSearch,
diff --git a/pym/gentoolkit/eclean/exclude.py b/pym/gentoolkit/eclean/exclude.py
index 513346d..0d2d0c4 100644
--- a/pym/gentoolkit/eclean/exclude.py
+++ b/pym/gentoolkit/eclean/exclude.py
@@ -13,9 +13,8 @@ if sys.hexversion < 0x3000000:
from io import open
import re
import portage
-from portage import _encodings, _unicode_decode, _unicode_encode
+from portage import _encodings, _unicode_encode
-from gentoolkit.pprinter import warn
# Misc. shortcuts to some portage stuff:
listdir = portage.listdir
@@ -84,7 +83,7 @@ def parseExcludeFile(filepath, output):
}
output("Parsing Exclude file: " + filepath)
try:
- file_ = open(_unicode_encode(filepath,
+ file_ = open(_unicode_encode(filepath,
encoding=_encodings['fs']), mode="r", encoding=_encodings['content'])
except IOError:
raise ParseExcludeFileException("Could not open exclusion file: " +
diff --git a/pym/gentoolkit/eclean/output.py b/pym/gentoolkit/eclean/output.py
index d40f3bc..93662d6 100644
--- a/pym/gentoolkit/eclean/output.py
+++ b/pym/gentoolkit/eclean/output.py
@@ -8,9 +8,8 @@ from __future__ import print_function
import sys
-import portage
-from portage.output import *
-from gentoolkit.pprinter import cpv, number, emph
+from portage.output import blue, yellow, teal, green, red
+from gentoolkit.pprinter import cpv, number
class OutputControl(object):
@@ -90,13 +89,11 @@ class OutputControl(object):
if color == None:
color = self.numbers
units = [" G"," M"," K"," B"]
- approx = 0
# by using 1000 as the changeover, the integer portion
# of the number will never be more than 3 digits long
# but the true base 2 value of 1024 is used for the actual
# calulation to maintain better accuracy.
while len(units) and size >= 1000:
- approx = 1
size = size / 1024.0
units.pop()
sizestr = "%.1f" %(round(size,1)) + units[-1]
diff --git a/pym/gentoolkit/eclean/pkgindex.py b/pym/gentoolkit/eclean/pkgindex.py
index 108e1ef..584a5bc 100644
--- a/pym/gentoolkit/eclean/pkgindex.py
+++ b/pym/gentoolkit/eclean/pkgindex.py
@@ -36,10 +36,12 @@ class PkgIndex(object):
@sets: self.binhost to BinhostHandler class
@rtype: boolean
"""
+ # About noqa below: I don't understand how this code can run at all.
+ # TODO: verify soundness
try:
- self.emaint_control = Modules()
+ self.emaint_control = Modules() # noqa
self.binhost = self.emaint_control._get_class('binhost')
- except InvalidModuleName as er:
+ except InvalidModuleName as er: # noqa
print( pp.error("Error importing emaint binhost module"), file=sys.stderr)
print( pp.error("Original error: " + er), file=sys.stderr)
except:
@@ -51,8 +53,8 @@ class PkgIndex(object):
"""Import the emaint modules and report the success/fail of them
"""
try:
- from emaint.module import Modules
- from emaint.main import TaskHandler
+ from emaint.module import Modules # noqa
+ from emaint.main import TaskHandler # noqa
except ImportError as e:
return False
return True
@@ -63,7 +65,7 @@ class PkgIndex(object):
go = self._load_modules()
if go:
if self.get_emaint_binhost():
- self.taskmaster = TaskHandler(show_progress_bar=True)
+ self.taskmaster = TaskHandler(show_progress_bar=True) # noqa
tasks = [self.binhost]
self.taskmaster.run_tasks(tasks)
diff --git a/pym/gentoolkit/eclean/search.py b/pym/gentoolkit/eclean/search.py
index b9d111a..ce455a3 100644
--- a/pym/gentoolkit/eclean/search.py
+++ b/pym/gentoolkit/eclean/search.py
@@ -8,14 +8,12 @@ from __future__ import print_function
import os
-import re
import stat
import sys
from functools import partial
import portage
-import gentoolkit
import gentoolkit.pprinter as pp
from gentoolkit.eclean.exclude import (exclDictMatchCP, exclDictExpand,
exclDictExpandPkgname, exclMatchFilename)
@@ -264,7 +262,7 @@ class DistfilesSearch(object):
while uris:
uri = uris.pop()
if uris and uris[-1] == "->":
- operator = uris.pop()
+ operator = uris.pop() # noqa
file = uris.pop()
else:
file = os.path.basename(uri)
diff --git a/pym/gentoolkit/enalyze/__init__.py b/pym/gentoolkit/enalyze/__init__.py
index 0b24e7d..6e9652d 100644
--- a/pym/gentoolkit/enalyze/__init__.py
+++ b/pym/gentoolkit/enalyze/__init__.py
@@ -34,7 +34,6 @@ MODULE_INFO = {
import errno
import sys
-import time
from getopt import getopt, GetoptError
import portage
@@ -44,7 +43,6 @@ from gentoolkit import errors
from gentoolkit import pprinter as pp
from gentoolkit.base import (initialize_configuration, split_arguments,
parse_global_options, print_help)
-from gentoolkit.formatters import format_options
NAME_MAP = {
diff --git a/pym/gentoolkit/enalyze/analyze.py b/pym/gentoolkit/enalyze/analyze.py
index 86f0987..1d3d9c0 100644
--- a/pym/gentoolkit/enalyze/analyze.py
+++ b/pym/gentoolkit/enalyze/analyze.py
@@ -10,8 +10,6 @@ what packages according to the Installed package database"""
from __future__ import print_function
-import sys
-
import gentoolkit
from gentoolkit.module_base import ModuleBase
from gentoolkit import pprinter as pp
@@ -298,10 +296,10 @@ class Analyse(ModuleBase):
flag_keys = sorted(flag_users)
if self.options["verbose"]:
print(" Flag System #pkgs cat/pkg-ver")
- blankline = nl
+ #blankline = nl
elif not self.options['quiet']:
print(" Flag System #pkgs")
- blankline = lambda: None
+ #blankline = lambda: None
for flag in flag_keys:
flag_pos = flag_users[flag]["+"]
if len(flag_pos):
@@ -442,10 +440,10 @@ class Analyse(ModuleBase):
if self.options["verbose"]:
print(" cat/pkg-ver USE Flags")
# "app-emulation/emul-linux-x86-sdl-20100915 ...."
- blankline = nl
+ #blankline = nl
elif not self.options['quiet']:
print(" cat/pkg-ver USE Flags")
- blankline = lambda: None
+ #blankline = lambda: None
for cpv in cpvs:
(flag_plus, flag_neg, unset) = flags.analyse_cpv(cpv)
if self.options["unset"]:
diff --git a/pym/gentoolkit/enalyze/lib.py b/pym/gentoolkit/enalyze/lib.py
index de306f0..8580bb7 100644
--- a/pym/gentoolkit/enalyze/lib.py
+++ b/pym/gentoolkit/enalyze/lib.py
@@ -8,12 +8,10 @@
"""Provides support functions to enalyze modules"""
-import sys
-
from gentoolkit import errors
from gentoolkit.keyword import reduce_keywords
from gentoolkit.flag import (reduce_flags, get_flags, get_all_cpv_use,
- filter_flags, get_installed_use, get_iuse, defaulted_flags)
+ filter_flags, get_installed_use, defaulted_flags)
#from gentoolkit.package import Package
import portage
diff --git a/pym/gentoolkit/enalyze/output.py b/pym/gentoolkit/enalyze/output.py
index 01a9b98..fd7affa 100644
--- a/pym/gentoolkit/enalyze/output.py
+++ b/pym/gentoolkit/enalyze/output.py
@@ -12,7 +12,6 @@ from __future__ import print_function
import time
-import gentoolkit
from gentoolkit import pprinter as pp
from gentoolkit.formatters import CpvValueWrapper
from gentoolkit.cpv import split_cpv
diff --git a/pym/gentoolkit/enalyze/rebuild.py b/pym/gentoolkit/enalyze/rebuild.py
index 53fded4..d6ccef9 100644
--- a/pym/gentoolkit/enalyze/rebuild.py
+++ b/pym/gentoolkit/enalyze/rebuild.py
@@ -23,13 +23,13 @@ from gentoolkit.module_base import ModuleBase
from gentoolkit import pprinter as pp
from gentoolkit.enalyze.lib import (get_installed_use, get_flags, FlagAnalyzer,
KeywordAnalyser)
-from gentoolkit.flag import reduce_flags
from gentoolkit.enalyze.output import RebuildPrinter
from gentoolkit.atom import Atom
+from gentoolkit.package import Package
import portage
-from portage import _encodings, _unicode_decode, _unicode_encode
+from portage import _encodings, _unicode_encode
def cpv_all_diff_use(
cpvs=None,
diff --git a/pym/gentoolkit/equery/__init__.py b/pym/gentoolkit/equery/__init__.py
index 7f20103..f33cca5 100644
--- a/pym/gentoolkit/equery/__init__.py
+++ b/pym/gentoolkit/equery/__init__.py
@@ -29,7 +29,6 @@ from getopt import getopt, GetoptError
import portage
-import gentoolkit
from gentoolkit import CONFIG
from gentoolkit import errors
from gentoolkit import pprinter as pp
diff --git a/pym/gentoolkit/equery/changes.py b/pym/gentoolkit/equery/changes.py
index 0083d95..92e81b5 100644
--- a/pym/gentoolkit/equery/changes.py
+++ b/pym/gentoolkit/equery/changes.py
@@ -19,7 +19,6 @@ import os
from getopt import gnu_getopt, GetoptError
import gentoolkit.pprinter as pp
-from gentoolkit import errors
from gentoolkit.atom import Atom
from gentoolkit.equery import format_options, mod_usage
from gentoolkit.helpers import ChangeLog
diff --git a/pym/gentoolkit/equery/has.py b/pym/gentoolkit/equery/has.py
index 180f7f0..37e4d3f 100644
--- a/pym/gentoolkit/equery/has.py
+++ b/pym/gentoolkit/equery/has.py
@@ -17,12 +17,10 @@ __docformat__ = 'epytext'
import sys
from getopt import gnu_getopt, GetoptError
-from portage import auxdbkeys
-
import gentoolkit.pprinter as pp
from gentoolkit import errors
from gentoolkit.equery import format_options, mod_usage, CONFIG
-from gentoolkit.package import PackageFormatter, FORMAT_TMPL_VARS
+from gentoolkit.package import PackageFormatter
from gentoolkit.query import Query
# =======
diff --git a/pym/gentoolkit/equery/list_.py b/pym/gentoolkit/equery/list_.py
index 214f49b..c547ac3 100644
--- a/pym/gentoolkit/equery/list_.py
+++ b/pym/gentoolkit/equery/list_.py
@@ -17,11 +17,9 @@ __docformat__ = 'epytext'
import sys
from getopt import gnu_getopt, GetoptError
-import gentoolkit
import gentoolkit.pprinter as pp
from gentoolkit import errors
from gentoolkit.equery import format_options, mod_usage, CONFIG
-from gentoolkit.helpers import get_installed_cpvs
from gentoolkit.helpers import get_bintree_cpvs
from gentoolkit.package import PackageFormatter, FORMAT_TMPL_VARS
from gentoolkit.query import Query
diff --git a/pym/gentoolkit/equery/meta.py b/pym/gentoolkit/equery/meta.py
index e9f5cea..81da14b 100644
--- a/pym/gentoolkit/equery/meta.py
+++ b/pym/gentoolkit/equery/meta.py
@@ -18,7 +18,6 @@ import re
import os
import sys
from getopt import gnu_getopt, GetoptError
-from functools import partial
import gentoolkit.pprinter as pp
from gentoolkit import errors
diff --git a/pym/gentoolkit/equery/uses.py b/pym/gentoolkit/equery/uses.py
index a8f13dc..e565b0d 100644
--- a/pym/gentoolkit/equery/uses.py
+++ b/pym/gentoolkit/equery/uses.py
@@ -24,12 +24,11 @@ from getopt import gnu_getopt, GetoptError
from glob import glob
from portage import settings
-from portage import _encodings, _unicode_decode, _unicode_encode
+from portage import _encodings, _unicode_encode
import gentoolkit.pprinter as pp
from gentoolkit import errors
from gentoolkit.equery import format_options, mod_usage, CONFIG
-from gentoolkit.helpers import uniqify
from gentoolkit.textwrap_ import TextWrapper
from gentoolkit.query import Query
from gentoolkit.flag import get_flags, reduce_flags
diff --git a/pym/gentoolkit/equery/which.py b/pym/gentoolkit/equery/which.py
index 137e52a..a071801 100644
--- a/pym/gentoolkit/equery/which.py
+++ b/pym/gentoolkit/equery/which.py
@@ -28,7 +28,7 @@ from gentoolkit import errors
from gentoolkit.equery import format_options, mod_usage
from gentoolkit.query import Query
-from portage import _encodings, _unicode_decode, _unicode_encode
+from portage import _encodings, _unicode_encode
# =======
# Globals
diff --git a/pym/gentoolkit/eshowkw/keywords_content.py b/pym/gentoolkit/eshowkw/keywords_content.py
index 18926b4..786e8b9 100644
--- a/pym/gentoolkit/eshowkw/keywords_content.py
+++ b/pym/gentoolkit/eshowkw/keywords_content.py
@@ -166,8 +166,6 @@ class keywords_content:
Sort packages queried based on version and slot
%% pn , repo, slot, eapi, keywords
"""
- from operator import itemgetter
-
if len(package_content) > 1:
ver_map = {}
for cpv in package_content:
diff --git a/pym/gentoolkit/eshowkw/keywords_header.py b/pym/gentoolkit/eshowkw/keywords_header.py
index 6557f60..ab9117e 100644
--- a/pym/gentoolkit/eshowkw/keywords_header.py
+++ b/pym/gentoolkit/eshowkw/keywords_header.py
@@ -2,6 +2,8 @@
# Copyright 2001-2018 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
+from __future__ import print_function
+
__all__ = ['keywords_header']
import portage
@@ -9,12 +11,17 @@ import os
import sys
if sys.hexversion < 0x3000000:
from io import open
-from portage import _encodings, _unicode_decode, _unicode_encode
+from portage import _encodings, _unicode_encode
from portage import settings as ports
-from portage.output import colorize
from gentoolkit.eshowkw.display_pretty import colorize_string
from gentoolkit.eshowkw.display_pretty import align_string
+# Copied from ekeyword
+def warning(msg):
+ """Write |msg| as a warning to stderr"""
+ print('warning: %s' % msg, file=sys.stderr)
+
+
# Copied from ekeyword, modified to support arch vs ~arch status
def load_profile_data(portdir=None, repo='gentoo'):
"""Load the list of known arches from the tree
diff --git a/pym/gentoolkit/flag.py b/pym/gentoolkit/flag.py
index d92d904..90a931a 100644
--- a/pym/gentoolkit/flag.py
+++ b/pym/gentoolkit/flag.py
@@ -20,8 +20,6 @@ __all__ = (
)
-import sys
-
import portage
diff --git a/pym/gentoolkit/formatters.py b/pym/gentoolkit/formatters.py
index c0a1747..98010dc 100644
--- a/pym/gentoolkit/formatters.py
+++ b/pym/gentoolkit/formatters.py
@@ -6,7 +6,6 @@
#
# $Header$
-import errno
import sys
import time
@@ -69,7 +68,7 @@ def format_filetype(path, fdesc, show_type=False, show_md5=False,
ftype = "sym"
stamp = format_timestamp(fdesc[1])
tgt = fdesc[2].split()[0]
- if CONFIG["piping"]:
+ if gentoolkit.CONFIG["piping"]:
fpath = path
else:
fpath = pp.path_symlink(path + " -> " + tgt)
diff --git a/pym/gentoolkit/glsa/__init__.py b/pym/gentoolkit/glsa/__init__.py
index 03e685c..db71025 100644
--- a/pym/gentoolkit/glsa/__init__.py
+++ b/pym/gentoolkit/glsa/__init__.py
@@ -37,11 +37,11 @@ if sys.version_info[0:2] < (2,3):
try:
import portage
- from portage import _encodings, _unicode_decode, _unicode_encode
+ from portage import _encodings, _unicode_encode
except ImportError:
sys.path.insert(0, "/usr/lib/portage/pym")
import portage
- from portage import _encodings, _unicode_decode, _unicode_encode
+ from portage import _encodings, _unicode_encode
# Note: the space for rgt and rlt is important !!
@@ -406,7 +406,6 @@ def getMinUpgrade(vulnerableList, unaffectedList, minimize=True):
@return: the lowest unaffected version that is greater than
the installed version.
"""
- rValue = ""
v_installed = reduce(operator.add, [match(v, "vartree") for v in vulnerableList], [])
u_installed = reduce(operator.add, [match(u, "vartree") for u in unaffectedList], [])
diff --git a/pym/gentoolkit/helpers.py b/pym/gentoolkit/helpers.py
index 8d25393..8993fed 100644
--- a/pym/gentoolkit/helpers.py
+++ b/pym/gentoolkit/helpers.py
@@ -34,7 +34,7 @@ from functools import partial
from itertools import chain
import portage
-from portage import _encodings, _unicode_decode, _unicode_encode
+from portage import _encodings, _unicode_encode
from gentoolkit import pprinter as pp
from gentoolkit import errors
@@ -197,7 +197,7 @@ class ChangeLog(object):
result = []
partial_entries = []
- with open(_unicode_encode(self.changelog_path,
+ with open(_unicode_encode(self.changelog_path,
encoding=_encodings['fs'], errors="replace"),
encoding=_encodings['content']) as log:
for line in log:
diff --git a/pym/gentoolkit/module_base.py b/pym/gentoolkit/module_base.py
index 5182218..e5d79e4 100644
--- a/pym/gentoolkit/module_base.py
+++ b/pym/gentoolkit/module_base.py
@@ -14,15 +14,12 @@ from __future__ import print_function
__docformat__ = 'epytext'
-import errno
import sys
-import time
from getopt import gnu_getopt, GetoptError
import gentoolkit.pprinter as pp
from gentoolkit.formatters import format_options
from gentoolkit.base import mod_usage
-from gentoolkit import CONFIG
class ModuleBase(object):
"""E-app base module class to parse module options print module help, etc.."""
diff --git a/pym/gentoolkit/package.py b/pym/gentoolkit/package.py
index 149ca74..bdeba17 100644
--- a/pym/gentoolkit/package.py
+++ b/pym/gentoolkit/package.py
@@ -46,7 +46,7 @@ from string import Template
import portage
from portage.util import LazyItemsDict
-from portage import _encodings, _unicode_decode, _unicode_encode
+from portage import _encodings, _unicode_encode
import gentoolkit.pprinter as pp
from gentoolkit import errors
diff --git a/pym/gentoolkit/pprinter.py b/pym/gentoolkit/pprinter.py
index fc68444..83f4859 100644
--- a/pym/gentoolkit/pprinter.py
+++ b/pym/gentoolkit/pprinter.py
@@ -15,7 +15,6 @@ __all__ = (
'emph',
'error',
'globaloption',
- 'installedflag',
'localoption',
'number',
'path',
diff --git a/pym/gentoolkit/revdep_rebuild/analyse.py b/pym/gentoolkit/revdep_rebuild/analyse.py
index 44243f6..7ddd5e9 100644
--- a/pym/gentoolkit/revdep_rebuild/analyse.py
+++ b/pym/gentoolkit/revdep_rebuild/analyse.py
@@ -11,7 +11,7 @@ import sys
if sys.hexversion < 0x3000000:
from io import open
-from portage import _encodings, _unicode_decode, _unicode_encode
+from portage import _encodings, _unicode_encode
from portage.output import bold, blue, yellow, green
from .stuff import scan
diff --git a/pym/gentoolkit/revdep_rebuild/cache.py b/pym/gentoolkit/revdep_rebuild/cache.py
index e92e7cd..ec9f168 100644
--- a/pym/gentoolkit/revdep_rebuild/cache.py
+++ b/pym/gentoolkit/revdep_rebuild/cache.py
@@ -10,11 +10,11 @@ import time
import sys
if sys.hexversion < 0x3000000:
from io import open
- _unicode = unicode
+ _unicode = unicode # noqa
else:
_unicode = str
-from portage import _encodings, _unicode_decode, _unicode_encode
+from portage import _encodings, _unicode_encode
from portage.output import red
from .settings import DEFAULTS
diff --git a/pym/gentoolkit/revdep_rebuild/collect.py b/pym/gentoolkit/revdep_rebuild/collect.py
index 82cec7b..9b81183 100644
--- a/pym/gentoolkit/revdep_rebuild/collect.py
+++ b/pym/gentoolkit/revdep_rebuild/collect.py
@@ -13,13 +13,13 @@ if sys.hexversion < 0x3000000:
from io import open
import portage
-from portage import _encodings, _unicode_decode, _unicode_encode
+from portage import _encodings, _unicode_encode
from portage.output import blue, yellow
from .settings import parse_revdep_config
if sys.hexversion < 0x3000000:
- _basestring = basestring
+ _basestring = basestring # noqa
else:
_basestring = str
diff --git a/pym/gentoolkit/revdep_rebuild/settings.py b/pym/gentoolkit/revdep_rebuild/settings.py
index 9a00f45..81e9c64 100644
--- a/pym/gentoolkit/revdep_rebuild/settings.py
+++ b/pym/gentoolkit/revdep_rebuild/settings.py
@@ -13,12 +13,12 @@ import re
import glob
import portage
-from portage import _encodings, _unicode_decode, _unicode_encode
+from portage import _encodings, _unicode_encode
if sys.version_info[0] >= 3:
_unicode = str
else:
- _unicode = unicode
+ _unicode = unicode # noqa
portage_root = _unicode(portage.root)
diff --git a/pym/gentoolkit/test/eclean/creator.py b/pym/gentoolkit/test/eclean/creator.py
index 63bffd1..de50426 100644
--- a/pym/gentoolkit/test/eclean/creator.py
+++ b/pym/gentoolkit/test/eclean/creator.py
@@ -17,7 +17,7 @@ import shutil
import random
import gentoolkit.pprinter as pp
-from portage import _encodings, _unicode_decode, _unicode_encode
+from portage import _encodings, _unicode_encode
__version__= "0.0.1"
__author__ = "Brian Dolbec"
@@ -97,7 +97,7 @@ def make_symlinks(path, links, targets):
and need to be in the same index order as links
"""
for i in range(len(links)):
- os.symlink(os.path.join(path,target[i]),
+ os.symlink(os.path.join(path,targets[i]),
os.path.join(path, links[i]))
@@ -236,11 +236,9 @@ class TestDirCreation(object):
make_dist(self.options['target_path'], self.distfile_list, self.dist_clean)
# add some symlinks to it
path = os.path.join(self.options['target_path'], 'distfiles')
- make_symlinks(path, distfile_symlink,
- dist_clean['symlink-test-1.2.3.tar.bz2'])
+ make_symlinks(path, self.distfile_symlink,
+ self.dist_clean['symlink-test-1.2.3.tar.bz2'])
# create the packages dir and populate it
path = os.path.join(self.options['target_path'], 'packages')
make_pkgs(path, self.package_dict, self.pkg_clean)
self.targets_init = True
-
- #def get_
diff --git a/pym/gentoolkit/test/eclean/distsupport.py b/pym/gentoolkit/test/eclean/distsupport.py
index e9ab8a1..7b444d2 100644
--- a/pym/gentoolkit/test/eclean/distsupport.py
+++ b/pym/gentoolkit/test/eclean/distsupport.py
@@ -10,8 +10,7 @@ from __future__ import print_function
import re
import os
-import unittest
-from tempfile import NamedTemporaryFile, mkdtemp
+from tempfile import mkdtemp
import subprocess
import portage
@@ -156,9 +155,6 @@ PROPS = {
'dev-libs/libisofs-0.6.26': {
"SRC_URI": 'http://files.libburnia-project.org/releases/libisofs-0.6.26.tar.gz',
"RESTRICT": ''},
- 'app-portage/portage-utils-0.3.1': {
- "SRC_URI": 'mirror://gentoo/portage-utils-0.3.1.tar.bz2',
- "RESTRICT": ''},
'app-portage/gentoolkit-0.3.0_rc8-r1': {
"SRC_URI": 'mirror://gentoo/gentoolkit-0.3.0_rc8.tar.gz http://dev.gentoo.org/~fuzzyray/distfiles/gentoolkit-0.3.0_rc8.tar.gz',
"RESTRICT": ''},
@@ -171,9 +167,6 @@ PROPS = {
'app-portage/gentoolkit-0.2.4.5': {
"SRC_URI": 'mirror://gentoo/gentoolkit-0.2.4.5.tar.gz http://dev.gentoo.org/~fuzzyray/distfiles/gentoolkit-0.2.4.5.tar.gz',
"RESTRICT": ''},
- 'app-portage/portage-utils-0.2.1': {
- "SRC_URI": 'mirror://gentoo/portage-utils-0.2.1.tar.bz2',
- "RESTRICT": ''},
'app-portage/gentoolkit-0.3.0_rc8': {
"SRC_URI": 'mirror://gentoo/gentoolkit-0.3.0_rc8.tar.gz http://dev.gentoo.org/~fuzzyray/distfiles/gentoolkit-0.3.0_rc8.tar.gz',
"RESTRICT": ''},
@@ -460,7 +453,7 @@ class TestDisfiles(object):
dir = os.path.dirname(os.path.abspath(__file__))
file = os.path.join(dir,"testdistfiles.tar.gz")
command = "tar -xpf %s -C %s" %(file, self.tmpdir)
- retcode = subprocess.call(command, shell=True)
+ subprocess.call(command, shell=True)
# create a symlink as part of the test files
#print()
self.target_symlink = "symlink-1.0.0.tar.gz"
diff --git a/pym/gentoolkit/test/eclean/test_clean.py b/pym/gentoolkit/test/eclean/test_clean.py
index 36b6281..0fc9469 100755
--- a/pym/gentoolkit/test/eclean/test_clean.py
+++ b/pym/gentoolkit/test/eclean/test_clean.py
@@ -12,137 +12,138 @@ __version__= "0.0.1"
__author__ = "Brian Dolbec"
__email__ = "brian.dolbec@gmail.com"
-from getopt import gnu_getopt, GetoptError
+# Whole unit commented out for being broken
+# from getopt import gnu_getopt, GetoptError
-import unittest
-import os
-import sys
+# import unittest
+# import os
+# import sys
-import gentoolkit.pprinter as pp
+# import gentoolkit.pprinter as pp
-from gentoolkit.eclean.clean import CleanUp
+# from gentoolkit.eclean.clean import CleanUp
-class Controllers(object):
- """Contains controller methods for use in testing
- the clean module methods"""
+# class Controllers(object):
+# """Contains controller methods for use in testing
+# the clean module methods"""
- def __init__(self):
- self.gathered_data = []
- self.authorize = True
- self.authorize_list = []
- self.authorize_index = 0
+# def __init__(self):
+# self.gathered_data = []
+# self.authorize = True
+# self.authorize_list = []
+# self.authorize_index = 0
- def authorize_all_controller(self, size, key, clean_list):
- """data gatherering controller.
+# def authorize_all_controller(self, size, key, clean_list):
+# """data gatherering controller.
- @rtype: Boolean
- @returns: self.authorize which controls the cleaning method
- """
- self.gathered_data.append([size, key, clean_list])
- return self.authorize
+# @rtype: Boolean
+# @returns: self.authorize which controls the cleaning method
+# """
+# self.gathered_data.append([size, key, clean_list])
+# return self.authorize
- def authorize_list_controller(self, size, key, clean_list):
- """data gathering and controller which
- authorizes acoring to a pre-determined list
+# def authorize_list_controller(self, size, key, clean_list):
+# """data gathering and controller which
+# authorizes acoring to a pre-determined list
- @rtype: Boolean
- @return self.authorize_list[self.authorize_index]"""
- self.gathered_data.append([size, key, clean_list])
- index = self.authorize_index
- self.authorize_index =+ 1
- return self.authorize_list[index]
+# @rtype: Boolean
+# @return self.authorize_list[self.authorize_index]"""
+# self.gathered_data.append([size, key, clean_list])
+# index = self.authorize_index
+# self.authorize_index =+ 1
+# return self.authorize_list[index]
-#class TestCleanUp(unittest.TestCase):
-# """Test module for the various CleanUp class methods
-#
-# @param options: dict of module options
-# @param testdata: dict. of path and test parameters
-# as created by the TestDirCreation class"""
-#
-# def __init__(self, options, testdata):
-# self.options = options
-# self.tesdata = testdata
-#
-#
-# def test_symlink_clean():
-# """Tests the symbolic link portion of the distfiles
-# cleaning"""
-# pass
-#
-#
-# def test_dist_clean():
-# """Test the distfiles cleaning"""
-# pass
-#
-#
-# def test_pkg_clean():
-# """Test the packages cleaning"""
-# pass
-#
-#
-# def test_pretend_clean():
-# """Test the pretend_clean output"""
-# controlller = Controllers().authorize_all_controller
-# clean = CleanUp(controller)
-# clean.pretend_clean(self.dist_clean)
-# data = controller.gathered_data
-
-
-
-def useage():
- """output run options"""
- print("Useage: test_clean [OPTONS] path=test-dir")
- print(" where test-dir is the location to create and populate")
- print("the testing distfiles and packages directories.")
- print("All tests in this module test only the clean.py module functions")
- print()
- print("OPTIONS:")
- print(" -a, --all run all tests")
- print(" -c, --clean clean up any previous test dirs & files")
- print(" -D, --distfiles run the distfiles cleaning test")
- print(" -k, --keep-dirs keep the test directories and files after the test")
- print(" -p, --pretend run the test in pretend mode only")
- print(" -P, --packages run the packages cleaning test")
- print(" -S, --symlinks run the symlinks test")
- print(" --path the location to create the temporary distfiles")
- print(" and packages directories that will be test cleaned")
- print(" --version test module version")
- print()
-
-
-def parse_opts():
- """Parse the options dict
-
- @return options: dictionary of module options"""
- try:
- opts, args = getopt(sys.argv[1:], 'acDkpPS', ["version",
- "help", "path=", "all", "distfiles", "packages",
- "pretend", "symlinks", "keep-dirs", "clean"])
- #print opts
- #print args
- except GetoptError as e:
- print(e.msg, file=sys.stderr)
- usage()
- sys.exit(1)
-
-
-
-def main(cmdline=False):
- """parse options and run the tests"""
-
- if cmdline:
- options = parse_opts()
-
-
-if __name__ == "__main__":
- """actually call main() if launched as a script"""
- try:
- main(True)
- except KeyboardInterrupt:
- print("Aborted.")
- sys.exit(130)
- sys.exit(0)
+# class TestCleanUp(unittest.TestCase):
+# """Test module for the various CleanUp class methods
+
+# @param options: dict of module options
+# @param testdata: dict. of path and test parameters
+# as created by the TestDirCreation class"""
+
+# def __init__(self, options, testdata):
+# self.options = options
+# self.tesdata = testdata
+
+
+# def test_symlink_clean():
+# """Tests the symbolic link portion of the distfiles
+# cleaning"""
+# pass
+
+
+# def test_dist_clean():
+# """Test the distfiles cleaning"""
+# pass
+
+
+# def test_pkg_clean():
+# """Test the packages cleaning"""
+# pass
+
+
+# def test_pretend_clean():
+# """Test the pretend_clean output"""
+# controlller = Controllers().authorize_all_controller
+# clean = CleanUp(controller)
+# clean.pretend_clean(self.dist_clean)
+# data = controller.gathered_data
+
+
+
+# def useage():
+# """output run options"""
+# print("Useage: test_clean [OPTONS] path=test-dir")
+# print(" where test-dir is the location to create and populate")
+# print("the testing distfiles and packages directories.")
+# print("All tests in this module test only the clean.py module functions")
+# print()
+# print("OPTIONS:")
+# print(" -a, --all run all tests")
+# print(" -c, --clean clean up any previous test dirs & files")
+# print(" -D, --distfiles run the distfiles cleaning test")
+# print(" -k, --keep-dirs keep the test directories and files after the test")
+# print(" -p, --pretend run the test in pretend mode only")
+# print(" -P, --packages run the packages cleaning test")
+# print(" -S, --symlinks run the symlinks test")
+# print(" --path the location to create the temporary distfiles")
+# print(" and packages directories that will be test cleaned")
+# print(" --version test module version")
+# print()
+
+
+# def parse_opts():
+# """Parse the options dict
+
+# @return options: dictionary of module options"""
+# try:
+# opts, args = getopt(sys.argv[1:], 'acDkpPS', ["version",
+# "help", "path=", "all", "distfiles", "packages",
+# "pretend", "symlinks", "keep-dirs", "clean"])
+# #print opts
+# #print args
+# except GetoptError as e:
+# print(e.msg, file=sys.stderr)
+# usage()
+# sys.exit(1)
+
+
+
+# def main(cmdline=False):
+# """parse options and run the tests"""
+
+# if cmdline:
+# options = parse_opts()
+
+
+# if __name__ == "__main__":
+# """actually call main() if launched as a script"""
+# try:
+# main(True)
+# except KeyboardInterrupt:
+# print("Aborted.")
+# sys.exit(130)
+# sys.exit(0)
diff --git a/pym/gentoolkit/test/eclean/test_search.py b/pym/gentoolkit/test/eclean/test_search.py
index 7e27f9e..1720688 100755
--- a/pym/gentoolkit/test/eclean/test_search.py
+++ b/pym/gentoolkit/test/eclean/test_search.py
@@ -12,11 +12,13 @@
from __future__ import print_function
-from tempfile import NamedTemporaryFile, mkdtemp
import unittest
import re
+import os
-from gentoolkit.test.eclean.distsupport import *
+from gentoolkit.test.eclean.distsupport import (
+ FILES, TestDisfiles, OutputSimulator, Dbapi, CPVS, CPVS2, CPVS3, PROPS,
+ PKGS, CLEAN_ME, get_props)
import gentoolkit.eclean.search as search
from gentoolkit.eclean.search import DistfilesSearch
from gentoolkit.eclean.exclude import parseExcludeFile
diff --git a/pym/gentoolkit/test/test_atom.py b/pym/gentoolkit/test/test_atom.py
index abafce3..1adb221 100644
--- a/pym/gentoolkit/test/test_atom.py
+++ b/pym/gentoolkit/test/test_atom.py
@@ -7,7 +7,7 @@
import unittest
-from gentoolkit.atom import *
+from gentoolkit.atom import Atom
from gentoolkit.test import cmp
"""Atom test suite (verbatim) from pkgcore."""
diff --git a/pym/gentoolkit/test/test_cpv.py b/pym/gentoolkit/test/test_cpv.py
index b4de959..fe51a78 100644
--- a/pym/gentoolkit/test/test_cpv.py
+++ b/pym/gentoolkit/test/test_cpv.py
@@ -8,7 +8,7 @@
import unittest
-from gentoolkit.cpv import *
+from gentoolkit.cpv import CPV, compare_strs
from gentoolkit.test import cmp
class TestGentoolkitCPV(unittest.TestCase):
diff --git a/pym/gentoolkit/test/test_helpers.py b/pym/gentoolkit/test/test_helpers.py
index 729f3dd..81b9edf 100644
--- a/pym/gentoolkit/test/test_helpers.py
+++ b/pym/gentoolkit/test/test_helpers.py
@@ -2,10 +2,6 @@ import os
import unittest
import warnings
from tempfile import NamedTemporaryFile, mktemp
-try:
- from test import test_support
-except ImportError:
- from test import support as test_support
from gentoolkit import helpers
@@ -18,42 +14,43 @@ class TestChangeLog(unittest.TestCase):
def tearDown(self):
pass
- def test_split_changelog(self):
- changelog = """
-*portage-2.1.6.2 (20 Dec 2008)
+# Commented out for being useless
+# def test_split_changelog(self):
+# changelog = """
+# *portage-2.1.6.2 (20 Dec 2008)
- 20 Dec 2008; Zac Medico <zmedico@gentoo.org> +portage-2.1.6.2.ebuild:
- 2.1.6.2 bump. This fixes bug #251591 (repoman inherit.autotools false
- positives) and bug #251616 (performance issue in build log search regex
- makes emerge appear to hang). Bug #216231 tracks all bugs fixed since
- 2.1.4.x.
+# 20 Dec 2008; Zac Medico <zmedico@gentoo.org> +portage-2.1.6.2.ebuild:
+# 2.1.6.2 bump. This fixes bug #251591 (repoman inherit.autotools false
+# positives) and bug #251616 (performance issue in build log search regex
+# makes emerge appear to hang). Bug #216231 tracks all bugs fixed since
+# 2.1.4.x.
- 20 Dec 2008; Zac Medico <zmedico@gentoo.org> -portage-2.1.6.ebuild,
- -portage-2.1.6.1.ebuild, -portage-2.2_rc17.ebuild:
- Remove old versions.
+# 20 Dec 2008; Zac Medico <zmedico@gentoo.org> -portage-2.1.6.ebuild,
+# -portage-2.1.6.1.ebuild, -portage-2.2_rc17.ebuild:
+# Remove old versions.
-*portage-2.1.6.1 (12 Dec 2008)
+# *portage-2.1.6.1 (12 Dec 2008)
- 12 Dec 2008; Zac Medico <zmedico@gentoo.org> +portage-2.1.6.1.ebuild:
- 2.1.6.1 bump. This fixes bug #250148 (emerge hangs with selinux if ebuild
- spawns a daemon), bug #250166 (trigger download when generating manifest
- if file size differs from existing entry), and bug #250212 (new repoman
- upstream.workaround category for emake -j1 warnings). Bug #216231 tracks
- all bugs fixed since 2.1.4.x.
+# 12 Dec 2008; Zac Medico <zmedico@gentoo.org> +portage-2.1.6.1.ebuild:
+# 2.1.6.1 bump. This fixes bug #250148 (emerge hangs with selinux if ebuild
+# spawns a daemon), bug #250166 (trigger download when generating manifest
+# if file size differs from existing entry), and bug #250212 (new repoman
+# upstream.workaround category for emake -j1 warnings). Bug #216231 tracks
+# all bugs fixed since 2.1.4.x.
-*portage-2.1.6 (07 Dec 2008)
+# *portage-2.1.6 (07 Dec 2008)
- 07 Dec 2008; Zac Medico <zmedico@gentoo.org> +portage-2.1.6.ebuild:
- 2.1.6 final release. This fixes bug #249586. Bug #216231 tracks all bugs
- fixed since 2.1.4.x.
+# 07 Dec 2008; Zac Medico <zmedico@gentoo.org> +portage-2.1.6.ebuild:
+# 2.1.6 final release. This fixes bug #249586. Bug #216231 tracks all bugs
+# fixed since 2.1.4.x.
- 07 Dec 2008; Zac Medico <zmedico@gentoo.org> -portage-2.1.6_rc1.ebuild,
- -portage-2.1.6_rc2.ebuild, -portage-2.1.6_rc3.ebuild,
- -portage-2.2_rc16.ebuild:
- Remove old versions.
- """
+# 07 Dec 2008; Zac Medico <zmedico@gentoo.org> -portage-2.1.6_rc1.ebuild,
+# -portage-2.1.6_rc2.ebuild, -portage-2.1.6_rc3.ebuild,
+# -portage-2.2_rc16.ebuild:
+# Remove old versions.
+# """
class TestFileOwner(unittest.TestCase):
diff --git a/pym/gentoolkit/test/test_keyword.py b/pym/gentoolkit/test/test_keyword.py
index 9add43a..5d5236b 100644
--- a/pym/gentoolkit/test/test_keyword.py
+++ b/pym/gentoolkit/test/test_keyword.py
@@ -1,10 +1,7 @@
import sys
import unittest
-import warnings
-from tempfile import NamedTemporaryFile
from gentoolkit import keyword
-from gentoolkit.test import cmp
class TestGentoolkitKeyword(unittest.TestCase):
diff --git a/tox.ini b/tox.ini
index b7bcbdb..41306b1 100644
--- a/tox.ini
+++ b/tox.ini
@@ -1,5 +1,5 @@
[tox]
-envlist = py27,py35,py36,py37,pyflakes
+envlist = py27,py35,py36,py37,flake8
skip_missing_interpreters = True
[testenv]
@@ -7,9 +7,12 @@ commands =
python setup.py test
sitepackages = True
-[testenv:pyflakes]
+[testenv:flake8]
deps =
- pyflakes
+ flake8
commands =
- pyflakes pym
-sitepackages = False
+ python -m flake8 pym
+
+[flake8]
+# We initially start small, but we probably want to expand that list with time.
+select = F4,F6,F7,F8,F9