From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1QhAz8-0007Pm-Nc for garchives@archives.gentoo.org; Thu, 14 Jul 2011 01:45:02 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 0094221C18B; Thu, 14 Jul 2011 01:44:53 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id A863721C18B for ; Thu, 14 Jul 2011 01:44:53 +0000 (UTC) Received: from pelican.gentoo.org (unknown [66.219.59.40]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id BF2EB2AC26B for ; Thu, 14 Jul 2011 01:44:52 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id CCFFD8003D for ; Thu, 14 Jul 2011 01:44:51 +0000 (UTC) From: "Brian Dolbec" To: gentoo-commits@lists.gentoo.org Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Brian Dolbec" Message-ID: Subject: [gentoo-commits] proj/gentoolkit:gentoolkit commit in: pym/gentoolkit/revdep_rebuild/ X-VCS-Repository: proj/gentoolkit X-VCS-Files: pym/gentoolkit/revdep_rebuild/collect.py pym/gentoolkit/revdep_rebuild/rebuild.py pym/gentoolkit/revdep_rebuild/settings.py pym/gentoolkit/revdep_rebuild/stuff.py X-VCS-Directories: pym/gentoolkit/revdep_rebuild/ X-VCS-Committer: dol-sen X-VCS-Committer-Name: Brian Dolbec X-VCS-Revision: c639b2341b63d784840c039ea08ef5f08e21bde8 Date: Thu, 14 Jul 2011 01:44:51 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: X-Archives-Hash: 902c64af0a4d98b81ac8631c1a193797 commit: c639b2341b63d784840c039ea08ef5f08e21bde8 Author: dol-sen gmail com> AuthorDate: Wed Jul 13 22:37:00 2011 +0000 Commit: Brian Dolbec gmail com> CommitDate: Wed Jul 13 22:37:00 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/gentoolkit.gi= t;a=3Dcommit;h=3Dc639b234 partial pylint cleanup --- pym/gentoolkit/revdep_rebuild/collect.py | 67 +++++++++++++++++------= ----- pym/gentoolkit/revdep_rebuild/rebuild.py | 42 ++++++++++-------- pym/gentoolkit/revdep_rebuild/settings.py | 17 ++++--- pym/gentoolkit/revdep_rebuild/stuff.py | 20 ++++++-- 4 files changed, 89 insertions(+), 57 deletions(-) diff --git a/pym/gentoolkit/revdep_rebuild/collect.py b/pym/gentoolkit/re= vdep_rebuild/collect.py index e8075d8..d1b23c0 100644 --- a/pym/gentoolkit/revdep_rebuild/collect.py +++ b/pym/gentoolkit/revdep_rebuild/collect.py @@ -1,5 +1,7 @@ #!/usr/bin/python =20 +"""Data collection module""" + import re import os import glob @@ -22,8 +24,8 @@ def parse_conf(conf_file, visited=3DNone, logger=3DNone= ): =20 for conf in conf_file: try: - with open(conf) as f: - for line in f: + with open(conf) as _file: + for line in _file: line =3D line.strip() if line.startswith('#'): continue @@ -62,8 +64,8 @@ def prepare_search_dirs(logger, settings): lib_dirs =3D set(['/lib', '/usr/lib', ]) =20 #try: - with open(os.path.join(portage.root, settings['DEFAULT_ENV_FILE']), 'r'= ) as f: - for line in f: + with open(os.path.join(portage.root, settings['DEFAULT_ENV_FILE']), 'r'= ) as _file: + for line in _file: line =3D line.strip() m =3D re.match("^export (ROOT)?PATH=3D'([^']+)'", line) if m is not None: @@ -84,10 +86,11 @@ def parse_revdep_config(revdep_confdir): masked_files =3D set() =20 #TODO: remove hard-coded path - for f in os.listdir(revdep_confdir): - for line in open(os.path.join('/etc/revdep-rebuild', f)): + for _file in os.listdir(revdep_confdir): + for line in open(os.path.join('/etc/revdep-rebuild', _file)): line =3D line.strip() - if not line.startswith('#'): #first check for comment, we do not want= to regex all lines + #first check for comment, we do not want to regex all lines + if not line.startswith('#'):=20 m =3D re.match('LD_LIBRARY_MASK=3D\\"([^"]+)\\"', line) if m is not None: s =3D m.group(1).split(' ') @@ -116,8 +119,9 @@ def collect_libraries_from_dir(dirs, mask, logger): (symlink_id, library_id) for resolving dependencies ''' =20 - - found_directories =3D [] # contains list of directories found; allow u= s to reduce number of fnc calls + # contains list of directories found + # allows us to reduce number of fnc calls + found_directories =3D [] =20 found_files =3D [] found_symlinks =3D [] found_la_files =3D [] # la libraries @@ -172,15 +176,17 @@ def collect_libraries_from_dir(dirs, mask, logger): prv & stat.S_IXOTH =3D=3D stat.S_IXOTH: found_files.append(l) except Exception as ex: - logger.debug(yellow('Exception during collecting libraries: ' + blue(= '%s') %str(ex))) + logger.debug( + yellow('Exception during collecting libraries: ' +=20 + blue('%s') %str(ex))) =20 =20 if found_directories: - f,a,l,p =3D collect_libraries_from_dir(found_directories, mask, logger= ) - found_files+=3Df - found_la_files+=3Da - found_symlinks+=3Dl - symlink_pairs+=3Dp + f, a, l, p =3D collect_libraries_from_dir(found_directories, mask, log= ger) + found_files +=3D f + found_la_files +=3D a + found_symlinks +=3D l + symlink_pairs +=3D p =20 return (found_files, found_la_files, found_symlinks, symlink_pairs) =20 @@ -191,7 +197,9 @@ def collect_binaries_from_dir(dirs, mask, logger): Returns list of binaries ''' =20 - found_directories =3D [] # contains list of directories found; allow u= s to reduce number of fnc calls + # contains list of directories found + # allows us to reduce number of fnc calls + found_directories =3D [] =20 found_files =3D [] =20 for d in dirs: @@ -211,7 +219,9 @@ def collect_binaries_from_dir(dirs, mask, logger): else: found_directories.append(l) elif os.path.isfile(l): - #we're looking for binaries, and with binaries we do not need links= , thus we can optimize a bit + # we're looking for binaries + # and with binaries we do not need links + # thus we can optimize a bit if not os.path.islink(l): prv =3D os.stat(l)[stat.ST_MODE] if prv & stat.S_IXUSR =3D=3D stat.S_IXUSR or \ @@ -219,7 +229,9 @@ def collect_binaries_from_dir(dirs, mask, logger): prv & stat.S_IXOTH =3D=3D stat.S_IXOTH: found_files.append(l) except Exception as e: - logger.debug(yellow('Exception during binaries collecting: '+blue('%s= ') %str(e))) + logger.debug( + yellow('Exception during binaries collecting: '+ + blue('%s') %str(e))) =20 if found_directories: found_files +=3D collect_binaries_from_dir(found_directories, mask, lo= gger) @@ -230,17 +242,20 @@ def collect_binaries_from_dir(dirs, mask, logger): =20 if __name__ =3D=3D '__main__': import logging - bin_dirs, lib_dirs =3D prepare_search_dirs(logging) + mbin_dirs, mlib_dirs =3D prepare_search_dirs(logging) =20 - masked_dirs, masked_files, ld =3D parse_revdep_config() - lib_dirs.update(ld) - bin_dirs.update(ld) - masked_dirs.update(['/lib/modules', '/lib32/modules', '/lib64/modules']= ) + mmasked_dirs, mmasked_files, mld =3D parse_revdep_config() + mlib_dirs.update(mld) + mbin_dirs.update(mld) + mmasked_dirs.update(['/lib/modules', '/lib32/modules', '/lib64/modules'= ]) =20 - libraries, la_libraries, libraries_links, symlink_pairs =3D collect_lib= raries_from_dir(lib_dirs, masked_dirs, logging) - binaries =3D collect_binaries_from_dir(bin_dirs, masked_dirs, logging) + libraries, la_libraries, libraries_links, msymlink_pairs =3D collect_li= braries_from_dir( + mlib_dirs, mmasked_dirs, logging) + binaries =3D collect_binaries_from_dir(mbin_dirs, mmasked_dirs, logging= ) =20 - logging.debug('Found: %i binaries and %i libraries.' %(len(binaries), l= en(libraries))) + logging.debug( + 'Found: %i binaries and %i libraries.' %( + len(binaries), len(libraries))) =20 =20 =20 diff --git a/pym/gentoolkit/revdep_rebuild/rebuild.py b/pym/gentoolkit/re= vdep_rebuild/rebuild.py index 9ac4811..04fb96c 100644 --- a/pym/gentoolkit/revdep_rebuild/rebuild.py +++ b/pym/gentoolkit/revdep_rebuild/rebuild.py @@ -10,18 +10,10 @@ # Creation date: 2010/10/17 # License: BSD =20 -import subprocess import os import sys -import re import getopt -import signal -import stat -import time -import glob -import portage import logging -from portage import portdb from portage.output import bold, red, blue, yellow, green, nocolor =20 from analyse import analyse @@ -41,6 +33,7 @@ __productname__ =3D "revdep-ng" # functions =20 def print_usage(): + """Outputs the help message""" print( APP_NAME + ': (' + VERSION +')') print print('This is free software; see the source for copying conditions.') @@ -93,8 +86,8 @@ def init_logger(settings): def parse_options(): """Parses the command line options an sets settings accordingly""" =20 - # @TODO: Verify: options: no-ld-path, no-order, no-progress are not app= liable=20 - # for revdep-ng + # TODO: Verify: options: no-ld-path, no-order, no-progress + #are not appliable =20 settings =3D DEFAULTS.copy() try: @@ -161,14 +154,25 @@ def rebuild(logger, assigned, settings): =20 emerge_command =3D emerge_command =20 - logger.warn(yellow('\nemerge') + args + ' --oneshot --complete-graph=3D= y ' + bold(emerge_command)) + logger.warn(yellow( + '\nemerge') + args +=20 + ' --oneshot --complete-graph=3Dy ' + + bold(emerge_command)) =09 - success =3D os.system('emerge ' + args + ' --oneshot --complete-graph=3D= y ' + emerge_command) + success =3D os.system( + 'emerge ' + args +=20 + ' --oneshot --complete-graph=3Dy ' +=20 + emerge_command) return success =20 =20 -# Runs from here def main(settings=3DNone, logger=3DNone): + """Main program operation method.... +=09 + @param settings: dict. defaults to settings.DEFAULTS + @param logger: python logging module defaults to init_logger(settings) + @return boolean success/failure + """ =20 if settings is None: print("NO Input settings, using defaults...") @@ -193,9 +197,9 @@ def main(settings=3DNone, logger=3DNone): yellow('This is a development version, ' 'so it may not work correctly')) logger.warn(blue(' * ') +=20 - yellow('The original revdep-rebuild script is installed as revdep-reb= uild.sh')) + yellow('The original revdep-rebuild script is ' + 'installed as revdep-rebuild.sh')) =20 - analyze_cache =3D {} if settings['USE_TMP_FILES'] \ and check_temp_files(settings['DEFAULT_TMP_DIR']): libraries, la_libraries, libraries_links, binaries =3D read_cache( @@ -218,13 +222,13 @@ def main(settings=3DNone, logger=3DNone): =20 has_masked =3D False tmp =3D [] - for a in assigned: - if get_masking_status(a): + for ebuild in assigned: + if get_masking_status(ebuild): has_masked =3D True logger.warn('!!! ' + red('All ebuilds that could satisfy: ') +=20 - green(a) + red(' have been masked')) + green(ebuild) + red(' have been masked')) else: - tmp.append(a) + tmp.append(ebuild) assigned =3D tmp =20 if has_masked: diff --git a/pym/gentoolkit/revdep_rebuild/settings.py b/pym/gentoolkit/r= evdep_rebuild/settings.py index 96aa491..b56f812 100644 --- a/pym/gentoolkit/revdep_rebuild/settings.py +++ b/pym/gentoolkit/revdep_rebuild/settings.py @@ -1,5 +1,7 @@ #!/usr/bin/python =20 +"""Default settings""" + import os import sys =20 @@ -12,17 +14,18 @@ DEFAULTS =3D { 'PKG_DIR': os.path.join(portage.root, 'var/db/pkg/'), 'DEFAULT_TMP_DIR': '/tmp/revdep-rebuild', #cache default location =20 - - 'USE_TMP_FILES': True, #if program should use temporary files from pre= vious run - 'CMD_MAX_ARGS': 1000, # number of maximum allowed files to be parsed a= t once + # number of maximum allowed files to be parsed at once + 'CMD_MAX_ARGS': 1000,=20 =20 'PRETEND': False, #pretend only 'EXACT': False, #exact package version - 'USE_TMP_FILES': True, #if program should use temporary files from pre= vious run + #if program should use temporary files from previous run + 'USE_TMP_FILES': True,=20 =20 - 'IS_DEV': True, #True for dev. version, False for stable - #used when IS_DEV is True, False forces to call emerge with --preten= d - # can be set True from the cli with the --no-pretend option + #True for dev. version, False for stable + #used when IS_DEV is True, False forces to call emerge with --pretend + # can be set True from the cli with the --no-pretend option + 'IS_DEV': True, 'NO_PRETEND': False, 'VERBOSITY': 1, =09 diff --git a/pym/gentoolkit/revdep_rebuild/stuff.py b/pym/gentoolkit/revd= ep_rebuild/stuff.py index 1ab21f2..163cc7d 100644 --- a/pym/gentoolkit/revdep_rebuild/stuff.py +++ b/pym/gentoolkit/revdep_rebuild/stuff.py @@ -1,5 +1,8 @@ #!/usr/bin/python =20 +"""Utilities submodule""" + + import subprocess =20 import portage @@ -27,15 +30,17 @@ def scan(params, files, max_args): ''' out =3D [] for i in range(0, len(files), max_args): - out +=3D call_program(['scanelf'] + params + files[i:i+max_args]).stri= p().split('\n') + out +=3D call_program( + ['scanelf'] + params + files[i:i+max_args]).strip().split('\n') return out =20 =20 -def exithandler(signum, frame): - sys.exit(1) - - def get_masking_status(ebuild): + """returns the masking status of an ebuild +=09 + @param ebuild: str + @return list + """ try: status =3D portage.getmaskingstatus(ebuild) except KeyError: @@ -44,6 +49,11 @@ def get_masking_status(ebuild): =20 =20 def _match_str_in_list(lst, stri): + """ + @param lst: list + @param stri: string + @return boolean or list menber that matches stri.endswith(member) + """ for l in lst: if stri.endswith(l): return l