fix the use of set updates and the with statement.
authordol-sen <brian.dolbec@gmail.com>
Wed, 13 Jul 2011 05:32:42 +0000 (22:32 -0700)
committerdol-sen <brian.dolbec@gmail.com>
Wed, 13 Jul 2011 05:32:42 +0000 (22:32 -0700)
pym/gentoolkit/revdep_rebuild/analyse.py
pym/gentoolkit/revdep_rebuild/assign.py
pym/gentoolkit/revdep_rebuild/cache.py
pym/gentoolkit/revdep_rebuild/collect.py

index 34ef55bea6b3cb5b7852268402938f2c64695280..69651ca0754ba6c5f5e9ac6798ef4765f7110e77 100644 (file)
@@ -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'))
index f7f03045f65b59e8a138db4b06ee7518f3581533..5ed938e888de40456d2a27c461271b3667b4a00b 100644 (file)
@@ -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)
index 6d21016fe1154c5dc7984bff75470f3434321fe7..ef46314e4f46a3615a0834e8a191dee563832459 100644 (file)
@@ -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)
index e5df8e3ddaa9db6050e740606bfc769055daa1cd..8d80e21d46c3414c8e7e2dfde34cedad870b84c0 100644 (file)
@@ -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)