From: dol-sen Date: Wed, 13 Jul 2011 05:32:42 +0000 (-0700) Subject: fix the use of set updates and the with statement. X-Git-Tag: gentoolkit-0.3.0.5~31 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=4576c230e52a09fae3f45d872be158259297846a;p=gentoolkit.git fix the use of set updates and the with statement. --- diff --git a/pym/gentoolkit/revdep_rebuild/analyse.py b/pym/gentoolkit/revdep_rebuild/analyse.py index 34ef55b..69651ca 100644 --- a/pym/gentoolkit/revdep_rebuild/analyse.py +++ b/pym/gentoolkit/revdep_rebuild/analyse.py @@ -146,8 +146,8 @@ def analyse(settings, logger, libraries=None, la_libraries=None, bin_dirs, lib_dirs = prepare_search_dirs(logger, settings) masked_dirs, masked_files, ld = parse_revdep_config(settings['REVDEP_CONFDIR']) - lib_dirs = lib_dirs.union(ld) - bin_dirs = bin_dirs.union(ld) + lib_dirs.update(ld) + bin_dirs.update(ld) masked_dirs = masked_dirs.union(set(['/lib/modules', '/lib32/modules', '/lib64/modules',])) logger.info(green(' * ') + bold('Collecting dynamic linking informations')) diff --git a/pym/gentoolkit/revdep_rebuild/assign.py b/pym/gentoolkit/revdep_rebuild/assign.py index f7f0304..5ed938e 100644 --- a/pym/gentoolkit/revdep_rebuild/assign.py +++ b/pym/gentoolkit/revdep_rebuild/assign.py @@ -19,7 +19,7 @@ def assign_packages(broken, logger, settings): if os.path.exists(f): try: with open(f, 'r') as cnt: - for line in cnt.readlines(): + for line in cnt: m = re.match('^obj (/[^ ]+)', line) if m is not None: m = m.group(1) diff --git a/pym/gentoolkit/revdep_rebuild/cache.py b/pym/gentoolkit/revdep_rebuild/cache.py index 6d21016..ef46314 100644 --- a/pym/gentoolkit/revdep_rebuild/cache.py +++ b/pym/gentoolkit/revdep_rebuild/cache.py @@ -92,9 +92,9 @@ if __name__ == '__main__': bin_dirs, lib_dirs = prepare_search_dirs() masked_dirs, masked_files, ld = parse_revdep_config() - lib_dirs = lib_dirs.union(ld) - bin_dirs = bin_dirs.union(ld) - masked_dirs = masked_dirs.union(set(['/lib/modules', '/lib32/modules', '/lib64/modules',])) + lib_dirs.update(ld) + bin_dirs.update(ld) + masked_dirs = masked_dirs.update(['/lib/modules', '/lib32/modules', '/lib64/modules',]) libraries, la_libraries, libraries_links, symlink_pairs = collect_libraries_from_dir(lib_dirs, masked_dirs, logging) binaries = collect_binaries_from_dir(bin_dirs, masked_dirs, logging) diff --git a/pym/gentoolkit/revdep_rebuild/collect.py b/pym/gentoolkit/revdep_rebuild/collect.py index e5df8e3..8d80e21 100644 --- a/pym/gentoolkit/revdep_rebuild/collect.py +++ b/pym/gentoolkit/revdep_rebuild/collect.py @@ -23,7 +23,7 @@ def parse_conf(conf_file, visited=None, logger=None): for conf in conf_file: try: with open(conf) as f: - for line in f.readlines(): + for line in f: line = line.strip() if line.startswith('#'): continue @@ -36,7 +36,7 @@ def parse_conf(conf_file, visited=None, logger=None): else: path = included - to_parse = to_parse.union(glob.glob(path)) + to_parse.update(glob.glob(path)) else: lib_dirs.add(line) except EnvironmentError: @@ -45,10 +45,10 @@ def parse_conf(conf_file, visited=None, logger=None): if visited is None: visited = set() - visited = visited.union(conf_file) - to_parse = to_parse.difference(visited) + visited.update(conf_file) + to_parse.difference_update(visited) if to_parse: - lib_dirs = lib_dirs.union(parse_conf(to_parse, visited, logger=logger)) + lib_dirs.update(parse_conf(to_parse, visited, logger=logger)) return lib_dirs @@ -63,11 +63,11 @@ def prepare_search_dirs(logger, settings): #try: with open(os.path.join(portage.root, settings['DEFAULT_ENV_FILE']), 'r') as f: - for line in f.readlines(): + for line in f: line = line.strip() m = re.match("^export (ROOT)?PATH='([^']+)'", line) if m is not None: - bin_dirs = bin_dirs.union(set(m.group(2).split(':'))) + bin_dirs.update(set(m.group(2).split(':'))) #except EnvironmentError: #logger.debug(yellow('Could not open file %s' % f)) @@ -233,9 +233,9 @@ if __name__ == '__main__': bin_dirs, lib_dirs = prepare_search_dirs(logging) masked_dirs, masked_files, ld = parse_revdep_config() - lib_dirs = lib_dirs.union(ld) - bin_dirs = bin_dirs.union(ld) - masked_dirs = masked_dirs.union(set(['/lib/modules', '/lib32/modules', '/lib64/modules',])) + lib_dirs.update(ld) + bin_dirs.update(ld) + masked_dirs.update(['/lib/modules', '/lib32/modules', '/lib64/modules']) libraries, la_libraries, libraries_links, symlink_pairs = collect_libraries_from_dir(lib_dirs, masked_dirs, logging) binaries = collect_binaries_from_dir(bin_dirs, masked_dirs, logging)