commit:     fb40f65ddd7635f98a2e0b14a8914697635896d4
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Tue Jan 19 07:07:57 2021 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Tue Jan 19 07:17:19 2021 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=fb40f65d

bin: misc pylint fixes

Signed-off-by: Zac Medico <zmedico <AT> gentoo.org>

 bin/clean_locks         |  5 +++--
 bin/dispatch-conf       | 17 ++++++++++-------
 bin/ebuild              |  4 +---
 bin/egencache           |  6 +++---
 bin/emerge              | 13 ++++---------
 bin/glsa-check          |  5 +++--
 bin/portageq            | 18 +++++++++---------
 bin/quickpkg            | 10 +++++-----
 bin/regenworld          |  6 +++---
 lib/portage/__init__.py |  3 ++-
 10 files changed, 43 insertions(+), 44 deletions(-)

diff --git a/bin/clean_locks b/bin/clean_locks
index d1f296065..e5765fd7e 100755
--- a/bin/clean_locks
+++ b/bin/clean_locks
@@ -1,8 +1,9 @@
 #!/usr/bin/python -b
-# Copyright 1999-2020 Gentoo Authors
+# Copyright 1999-2021 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
-import sys, errno
+import errno
+import sys
 from os import path as osp
 if osp.isfile(osp.join(osp.dirname(osp.dirname(osp.realpath(__file__))), 
".portage_not_installed")):
        sys.path.insert(0, 
osp.join(osp.dirname(osp.dirname(osp.realpath(__file__))), "lib"))

diff --git a/bin/dispatch-conf b/bin/dispatch-conf
index fa047244a..0fdfbaa81 100755
--- a/bin/dispatch-conf
+++ b/bin/dispatch-conf
@@ -1,5 +1,5 @@
 #!/usr/bin/python -b
-# Copyright 1999-2020 Gentoo Authors
+# Copyright 1999-2021 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 #
@@ -16,10 +16,17 @@ import io
 import re
 import subprocess
 import sys
+import termios
+import tty
 
 from stat import ST_GID, ST_MODE, ST_UID
 from random import random
 
+try:
+       import curses
+except ImportError:
+       curses = None
+
 from os import path as osp
 if osp.isfile(osp.join(osp.dirname(osp.dirname(osp.realpath(__file__))), 
".portage_not_installed")):
        sys.path.insert(0, 
osp.join(osp.dirname(osp.dirname(osp.realpath(__file__))), "lib"))
@@ -454,7 +461,6 @@ class dispatch:
 def getch ():
     # from ASPN - Danny Yoo
     #
-    import tty, termios
 
     fd = sys.stdin.fileno()
     old_settings = termios.tcgetattr(fd)
@@ -466,8 +472,7 @@ def getch ():
     return ch
 
 def clear_screen():
-    try:
-        import curses
+    if curses is not None:
         try:
             curses.setupterm()
             sys.stdout.write(_unicode_decode(curses.tigetstr("clear")))
@@ -475,8 +480,6 @@ def clear_screen():
             return
         except curses.error:
             pass
-    except ImportError:
-        pass
     os.system("clear 2>/dev/null")
 
 shell = os.environ.get("SHELL")
@@ -503,7 +506,7 @@ def usage(argv):
 for x in sys.argv:
     if x in ('-h', '--help'):
         usage(sys.argv)
-    elif x in ('--version'):
+    elif x in ('--version',):
         print("Portage", portage.VERSION)
         sys.exit(os.EX_OK)
 

diff --git a/bin/ebuild b/bin/ebuild
index 09f7f839b..0a2b13a13 100755
--- a/bin/ebuild
+++ b/bin/ebuild
@@ -1,5 +1,5 @@
 #!/usr/bin/python -b
-# Copyright 1999-2020 Gentoo Authors
+# Copyright 1999-2021 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 import argparse
@@ -46,7 +46,6 @@ portage._internal_caller = True
 from portage import os
 from portage import _encodings
 from portage import _shell_quote
-from portage import _unicode_decode
 from portage import _unicode_encode
 from portage.const import VDB_PATH
 from portage.exception import PermissionDenied, PortageKeyError, \
@@ -111,7 +110,6 @@ if debug:
 
 # do this _after_ 'import portage' to prevent unnecessary tracing
 if debug and "python-trace" in portage.features:
-       import portage.debug
        portage.debug.set_trace(True)
 
 if not opts.color == 'y' and \

diff --git a/bin/egencache b/bin/egencache
index 4ee63edad..9b6df2e7d 100755
--- a/bin/egencache
+++ b/bin/egencache
@@ -1,5 +1,5 @@
 #!/usr/bin/python -b
-# Copyright 2009-2020 Gentoo Authors
+# Copyright 2009-2021 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 # unicode_literals for compat with TextIOWrapper in Python 2
@@ -49,7 +49,6 @@ if 
osp.isfile(osp.join(osp.dirname(osp.dirname(osp.realpath(__file__))), ".porta
 import portage
 portage._internal_caller = True
 from portage import os, _encodings, _unicode_encode, _unicode_decode
-from _emerge.MetadataRegen import MetadataRegen
 from portage.cache.cache_errors import CacheError, StatCollision
 from portage.cache.index.pkg_desc_index import pkg_desc_index_line_format, 
pkg_desc_index_line_read
 from portage.const import TIMESTAMP_FORMAT
@@ -65,6 +64,7 @@ from portage.util.changelog import ChangeLogTypeSort
 from portage import cpv_getkey
 from portage.dep import Atom, isjustname
 from portage.versions import vercmp
+from _emerge.MetadataRegen import MetadataRegen
 
 try:
        from xml.etree import ElementTree
@@ -76,7 +76,7 @@ else:
        except ImportError:
                pass
        else:
-               from portage.xml.metadata import parse_metadata_use
+               from portage.xml.metadata import parse_metadata_use # pylint: 
disable=ungrouped-imports
 
 
 def parse_args(args):

diff --git a/bin/emerge b/bin/emerge
index f0a2b8429..813d7bae5 100755
--- a/bin/emerge
+++ b/bin/emerge
@@ -1,5 +1,5 @@
 #!/usr/bin/python -b
-# Copyright 2006-2020 Gentoo Authors
+# Copyright 2006-2021 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 import platform
@@ -40,12 +40,12 @@ try:
        import portage
        portage._internal_caller = True
        portage._disable_legacy_globals()
+       from portage.elog import mod_echo
+       from portage.exception import IsADirectory, ParseError, PermissionDenied
        from portage.util._eventloop.global_event_loop import global_event_loop
        from _emerge.main import emerge_main
 
        if __name__ == "__main__":
-               from portage.exception import IsADirectory, ParseError, \
-                               PermissionDenied
                portage.process.sanitize_fds()
                try:
                        retval = emerge_main()
@@ -69,12 +69,7 @@ try:
                        # mod_echo output before showing the traceback.
                        import traceback
                        tb_str = traceback.format_exc()
-                       try:
-                               from portage.elog import mod_echo
-                       except ImportError:
-                               pass
-                       else:
-                               mod_echo.finalize()
+                       mod_echo.finalize()
                        sys.stderr.write(tb_str)
                        sys.exit(1)
                sys.exit(retval)

diff --git a/bin/glsa-check b/bin/glsa-check
index 8200f75b6..a3e7aa043 100755
--- a/bin/glsa-check
+++ b/bin/glsa-check
@@ -1,5 +1,5 @@
 #!/usr/bin/python -b
-# Copyright 1999-2020 Gentoo Authors
+# Copyright 1999-2021 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 import argparse
@@ -318,9 +318,10 @@ if mode == "test":
 
 # mail mode as requested by solar
 if mode == "mail":
-       import portage.mail, socket
+       import socket
        from io import BytesIO
        from email.mime.text import MIMEText
+       import portage.mail
 
        # color doesn't make any sense for mail
        nocolor()

diff --git a/bin/portageq b/bin/portageq
index dbcd9f62d..67fdc9d38 100755
--- a/bin/portageq
+++ b/bin/portageq
@@ -1,5 +1,5 @@
 #!/usr/bin/python -b
-# Copyright 1999-2020 Gentoo Authors
+# Copyright 1999-2021 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 import argparse
@@ -100,7 +100,7 @@ docstrings = {}
 
 @uses_eroot
 def has_version(argv):
-       if (len(argv) < 2):
+       if len(argv) < 2:
                print("ERROR: insufficient parameters!")
                return 3
 
@@ -148,7 +148,7 @@ has_version.__doc__ = docstrings['has_version']
 
 @uses_eroot
 def best_version(argv):
-       if (len(argv) < 2):
+       if len(argv) < 2:
                print("ERROR: insufficient parameters!")
                return 3
 
@@ -189,7 +189,7 @@ best_version.__doc__ = docstrings['best_version']
 
 @uses_eroot
 def mass_best_version(argv):
-       if (len(argv) < 2):
+       if len(argv) < 2:
                print("ERROR: insufficient parameters!")
                return 2
        try:
@@ -207,7 +207,7 @@ mass_best_version.__doc__ = docstrings['mass_best_version']
 
 @uses_eroot
 def metadata(argv):
-       if (len(argv) < 4):
+       if len(argv) < 4:
                print('ERROR: insufficient parameters!', file=sys.stderr)
                return 2
 
@@ -460,7 +460,7 @@ filter_protected.__doc__ = docstrings['filter_protected']
 
 @uses_eroot
 def best_visible(argv):
-       if (len(argv) < 2):
+       if len(argv) < 2:
                writemsg("ERROR: insufficient parameters!\n", noiselevel=-1)
                return 2
 
@@ -549,7 +549,7 @@ def mass_best_visible(argv):
                "binary":"bintree",
                "installed":"vartree"}
 
-       if (len(argv) < 2):
+       if len(argv) < 2:
                print("ERROR: insufficient parameters!")
                return 2
        try:
@@ -1316,7 +1316,7 @@ def usage(argv):
        help_mode = '--help' in argv
        for name in commands:
                doc = docstrings.get(name)
-               if (doc == None):
+               if doc == None:
                        print("   " + name)
                        print("      MISSING DOCUMENTATION!")
                        print("")
@@ -1325,7 +1325,7 @@ def usage(argv):
                lines = doc.lstrip("\n").split("\n")
                print("   " + name + " " + lines[0].strip())
                if len(argv) > 1:
-                       if (not help_mode):
+                       if not help_mode:
                                lines = lines[:-1]
                        for line in lines[1:]:
                                print("      " + line.strip())

diff --git a/bin/quickpkg b/bin/quickpkg
index a171b3bd5..1b7ad666c 100755
--- a/bin/quickpkg
+++ b/bin/quickpkg
@@ -1,5 +1,5 @@
 #!/usr/bin/python -b
-# Copyright 1999-2020 Gentoo Authors
+# Copyright 1999-2021 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 import argparse
@@ -197,16 +197,16 @@ def quickpkg_set(options, infos, arg, eout):
        setconfig = load_default_config(settings, trees)
        sets = setconfig.getSets()
 
-       set = arg[1:]
-       if not set in sets:
+       set_name = arg[1:]
+       if not set_name in sets:
                eout.eerror("Package set not found: '%s'; skipping" % (arg,))
                infos["missing"].append(arg)
                return 1
 
        try:
-               atoms = setconfig.getSetAtoms(set)
+               atoms = setconfig.getSetAtoms(set_name)
        except PackageSetNotFound as e:
-               eout.eerror("Failed to process package set '%s' because " % set 
+
+               eout.eerror("Failed to process package set '%s' because " % 
set_name +
                        "it contains the non-existent package set '%s'; 
skipping" % e)
                infos["missing"].append(arg)
                return 1

diff --git a/bin/regenworld b/bin/regenworld
index 9f33502c6..a5b1f0431 100755
--- a/bin/regenworld
+++ b/bin/regenworld
@@ -1,5 +1,5 @@
 #!/usr/bin/python -b
-# Copyright 1999-2020 Gentoo Authors
+# Copyright 1999-2021 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 import sys
@@ -19,10 +19,10 @@ __candidatematcher__ = re.compile("^[0-9]+: \\*\\*\\* 
emerge ")
 __noncandidatematcher__ = re.compile(" sync( |$)| clean( |$)| search( 
|$)|--oneshot|--fetchonly| unmerge( |$)")
 
 def issyspkg(pkgline):
-       return (pkgline[0] == "*")
+       return pkgline[0] == "*"
 
 def iscandidate(logline):
-       return (__candidatematcher__.match(logline) \
+       return (__candidatematcher__.match(logline)
                                and not __noncandidatematcher__.search(logline))
 
 def getpkginfo(logline):

diff --git a/lib/portage/__init__.py b/lib/portage/__init__.py
index 178d724db..3c9f78497 100644
--- a/lib/portage/__init__.py
+++ b/lib/portage/__init__.py
@@ -1,4 +1,4 @@
-# Copyright 1998-2020 Gentoo Authors
+# Copyright 1998-2021 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 # pylint: disable=ungrouped-imports
 
@@ -58,6 +58,7 @@ try:
                        'portagetree,portdbapi',
                'portage.dbapi.vartree:dblink,merge,unmerge,vardbapi,vartree',
                'portage.dbapi.virtual:fakedbapi',
+               'portage.debug',
                'portage.dep',
                'portage.dep:best_match_to_list,dep_getcpv,dep_getkey,' + \
                        
'flatten,get_operator,isjustname,isspecific,isvalidatom,' + \

Reply via email to