diff --git a/lib/_emerge/Binpkg.py b/lib/_emerge/Binpkg.py index 299ae7fbc9..d78a049b12 100644 --- a/lib/_emerge/Binpkg.py +++ b/lib/_emerge/Binpkg.py @@ -123,15 +123,15 @@ def _start(self): fetch_log = os.path.join( _emerge.emergelog._emerge_log_dir, "emerge-fetch.log" ) - msg = ( + msgs = ( "Fetching in the background:", prefetcher.pkg_path, "To view fetch progress, run in another terminal:", f"tail -f {fetch_log}", ) out = portage.output.EOutput() - for l in msg: - out.einfo(l) + for msg in msgs: + out.einfo(msg) self._current_task = prefetcher prefetcher.addExitListener(self._prefetch_exit) diff --git a/lib/_emerge/EbuildBuild.py b/lib/_emerge/EbuildBuild.py index d4a4c6dacb..5538220f12 100644 --- a/lib/_emerge/EbuildBuild.py +++ b/lib/_emerge/EbuildBuild.py @@ -108,14 +108,14 @@ def _start_with_metadata(self, aux_get_task): fetch_log = os.path.join( _emerge.emergelog._emerge_log_dir, "emerge-fetch.log" ) - msg = ( + msgs = ( "Fetching files in the background.", "To view fetch progress, run in another terminal:", f"tail -f {fetch_log}", ) out = portage.output.EOutput() - for l in msg: - out.einfo(l) + for msg in msgs: + out.einfo(msg) self._current_task = prefetcher prefetcher.addExitListener(self._prefetch_exit) diff --git a/lib/_emerge/EbuildMetadataPhase.py b/lib/_emerge/EbuildMetadataPhase.py index 54177840c7..4b288022a3 100644 --- a/lib/_emerge/EbuildMetadataPhase.py +++ b/lib/_emerge/EbuildMetadataPhase.py @@ -208,11 +208,11 @@ def _async_waitpid_cb(self, *args, **kwargs): ).splitlines() metadata = {} metadata_valid = True - for l in metadata_lines: - if "=" not in l: + for line in metadata_lines: + if "=" not in line: metadata_valid = False break - key, value = l.split("=", 1) + key, value = line.split("=", 1) metadata[key] = value if metadata_valid: diff --git a/lib/_emerge/EbuildPhase.py b/lib/_emerge/EbuildPhase.py index 9e5268ff73..c62760704c 100644 --- a/lib/_emerge/EbuildPhase.py +++ b/lib/_emerge/EbuildPhase.py @@ -71,8 +71,8 @@ async def _setup_locale(settings): # check_locale() returns None when check can not be executed. if await async_check_locale(silent=True, env=settings.environ()) is False: # try another locale - for l in ("C.UTF-8", "en_US.UTF-8", "en_GB.UTF-8", "C"): - settings["LC_CTYPE"] = l + for locale in ("C.UTF-8", "en_US.UTF-8", "en_GB.UTF-8", "C"): + settings["LC_CTYPE"] = locale if await async_check_locale(silent=True, env=settings.environ()): # TODO: output the following only once # writemsg( diff --git a/lib/_emerge/Scheduler.py b/lib/_emerge/Scheduler.py index 614df9e783..5c8a0a0ea3 100644 --- a/lib/_emerge/Scheduler.py +++ b/lib/_emerge/Scheduler.py @@ -445,15 +445,15 @@ def _background_mode(self): level=logging.INFO, noiselevel=-1, ) - msg = [""] + msgs = [""] for pkg in interactive_tasks: pkg_str = " " + colorize("INFORM", str(pkg.cpv)) if pkg.root_config.settings["ROOT"] != "/": pkg_str += " for " + pkg.root - msg.append(pkg_str) - msg.append("") + msgs.append(pkg_str) + msgs.append("") writemsg_level( - "".join(f"{l}\n" for l in msg), + "".join(f"{msg}\n" for msg in msgs), level=logging.INFO, noiselevel=-1, ) @@ -954,15 +954,15 @@ async def _run_pkg_pretend(self, loop=None): # bintree.inject call which moves the file. fetched = fetcher.pkg_path else: - msg = ( + msgs = ( "Fetching in the background:", fetcher.pkg_path, "To view fetch progress, run in another terminal:", f"tail -f {self._fetch_log}", ) out = portage.output.EOutput() - for l in msg: - out.einfo(l) + for msg in msgs: + out.einfo(msg) if await fetcher.async_wait() != os.EX_OK: failures += 1 self._record_pkg_failure(x, settings, fetcher.returncode) @@ -1121,14 +1121,14 @@ def merge(self): # for ensuring sane $PWD (bug #239560) and storing elog messages. tmpdir = root_config.settings.get("PORTAGE_TMPDIR", "") if not tmpdir or not os.path.isdir(tmpdir): - msg = ( + msgs = ( "The directory specified in your PORTAGE_TMPDIR variable does not exist:", tmpdir, "Please create this directory or correct your PORTAGE_TMPDIR setting.", ) out = portage.output.EOutput() - for l in msg: - out.eerror(l) + for msg in msgs: + out.eerror(msg) return FAILURE if self._background: diff --git a/lib/_emerge/actions.py b/lib/_emerge/actions.py index 43d936fd14..7056ddedb1 100644 --- a/lib/_emerge/actions.py +++ b/lib/_emerge/actions.py @@ -2795,18 +2795,20 @@ def adjust_config(myopts, settings): def display_missing_pkg_set(root_config, set_name): - msg = [] - msg.append( + msgs = [] + msgs.append( f"emerge: There are no sets to satisfy '{colorize('INFORM', set_name)}'. " "The following sets exist:" ) - msg.append("") + msgs.append("") for s in sorted(root_config.sets): - msg.append(f" {s}") - msg.append("") + msgs.append(f" {s}") + msgs.append("") - writemsg_level("".join(f"{l}\n" for l in msg), level=logging.ERROR, noiselevel=-1) + writemsg_level( + "".join(f"{msg}\n" for msg in msgs), level=logging.ERROR, noiselevel=-1 + ) def relative_profile_path(portdir, abs_profile): @@ -3053,7 +3055,7 @@ def check_procfs(): return os.EX_OK msg = f"It seems that {procfs_path} is not mounted. You have been warned." writemsg_level( - "".join(f"!!! {l}\n" for l in textwrap.wrap(msg, 70)), + "".join(f"!!! {line}\n" for line in textwrap.wrap(msg, 70)), level=logging.ERROR, noiselevel=-1, ) @@ -3368,15 +3370,15 @@ def repo_name_check(trees): pass if missing_repo_names: - msg = [] - msg.append( + msgs = [] + msgs.append( "WARNING: One or more repositories " + "have missing repo_name entries:" ) - msg.append("") + msgs.append("") for p in missing_repo_names: msg.append(f"\t{p}/profiles/repo_name") - msg.append("") - msg.extend( + msgs.append("") + msgs.extend( textwrap.wrap( "NOTE: Each repo_name entry " + "should be a plain text file containing a unique " @@ -3384,9 +3386,9 @@ def repo_name_check(trees): 70, ) ) - msg.append("\n") + msgs.append("\n") writemsg_level( - "".join(f"{l}\n" for l in msg), level=logging.WARNING, noiselevel=-1 + "".join(f"{msg}\n" for msg in msgs), level=logging.WARNING, noiselevel=-1 ) return bool(missing_repo_names) @@ -3403,18 +3405,18 @@ def repo_name_duplicate_check(trees): ignored_repos.setdefault(k, []).extend(paths) if ignored_repos: - msg = [] - msg.append( + msgs = [] + msgs.append( "WARNING: One or more repositories " + "have been ignored due to duplicate" ) - msg.append(" profiles/repo_name entries:") - msg.append("") + msgs.append(" profiles/repo_name entries:") + msgs.append("") for k in sorted(ignored_repos): - msg.append(f" {', '.join(k)} overrides") + msgs.append(f" {', '.join(k)} overrides") for path in ignored_repos[k]: - msg.append(f" {path}") - msg.append("") - msg.extend( + msgs.append(f" {path}") + msgs.append("") + msgs.extend( " " + x for x in textwrap.wrap( "All profiles/repo_name entries must be unique in order " @@ -3423,9 +3425,9 @@ def repo_name_duplicate_check(trees): + "/etc/portage/make.conf if you would like to disable this warning." ) ) - msg.append("\n") + msgs.append("\n") writemsg_level( - "".join(f"{l}\n" for l in msg), level=logging.WARNING, noiselevel=-1 + "".join(f"{msg}\n" for msg in msgs), level=logging.WARNING, noiselevel=-1 ) return bool(ignored_repos) diff --git a/lib/_emerge/depgraph.py b/lib/_emerge/depgraph.py index 2acd8f2e13..8fb71b7334 100644 --- a/lib/_emerge/depgraph.py +++ b/lib/_emerge/depgraph.py @@ -2077,7 +2077,7 @@ def _slot_confict_backtrack(self, root, slot_atom, all_parents, conflict_pkgs): ) self._dynamic_config._need_restart = True if debug: - msg = [ + msgs = [ "", "", "backtracking due to slot conflict:", @@ -2090,7 +2090,7 @@ def _slot_confict_backtrack(self, root, slot_atom, all_parents, conflict_pkgs): "", ] writemsg_level( - "".join(f"{l}\n" for l in msg), noiselevel=-1, level=logging.DEBUG + "".join(f"{msg}\n" for msg in msgs), noiselevel=-1, level=logging.DEBUG ) def _slot_conflict_backtrack_abi(self, pkg, slot_nodes, conflict_atoms): @@ -3320,17 +3320,17 @@ def _add_dep(self, dep, allow_unsatisfied=False): self._dynamic_config._backtrack_infos["missing dependency"] = dep self._dynamic_config._need_restart = True if debug: - msg = [] - msg.append("") - msg.append("") + msgs = [] + msgs.append("") + msgs.append("") msg.append("backtracking due to unsatisfied dep:") - msg.append(f" parent: {dep.parent}") - msg.append(f" priority: {dep.priority}") - msg.append(f" root: {dep.root}") - msg.append(f" atom: {dep.atom}") - msg.append("") + msgs.append(f" parent: {dep.parent}") + msgs.append(f" priority: {dep.priority}") + msgs.append(f" root: {dep.root}") + msgs.append(f" atom: {dep.atom}") + msgs.append("") writemsg_level( - "".join(f"{l}\n" for l in msg), + "".join(f"{msg}\n" for msg in msgs), noiselevel=-1, level=logging.DEBUG, ) @@ -12149,15 +12149,15 @@ def show_masked_packages(masked_packages): writemsg(filename + ":\n" + comment + "\n", noiselevel=-1) shown_comments.add(comment) portdb = root_config.trees["porttree"].dbapi - for l in missing_licenses: - if l in shown_licenses: + for lic in missing_licenses: + if lic in shown_licenses: continue - l_path = portdb.findLicensePath(l) + l_path = portdb.findLicensePath(lic) if l_path is None: continue - msg = f"A copy of the '{l}' license is located at '{l_path}'.\n\n" + msg = f"A copy of the '{lic}' license is located at '{l_path}'.\n\n" writemsg(msg, noiselevel=-1) - shown_licenses.add(l) + shown_licenses.add(lic) return have_eapi_mask diff --git a/lib/_emerge/main.py b/lib/_emerge/main.py index 465e20163d..0eb9b24f0b 100644 --- a/lib/_emerge/main.py +++ b/lib/_emerge/main.py @@ -1157,7 +1157,7 @@ def profile_check(trees, myaction): "--help, --info, --search, --sync, and --version." ) writemsg_level( - "".join(f"!!! {l}\n" for l in textwrap.wrap(msg, 70)), + "".join(f"!!! {line}\n" for line in textwrap.wrap(msg, 70)), level=logging.ERROR, noiselevel=-1, ) diff --git a/lib/portage/_emirrordist/main.py b/lib/portage/_emirrordist/main.py index 989665ab8a..63793e8988 100644 --- a/lib/portage/_emirrordist/main.py +++ b/lib/portage/_emirrordist/main.py @@ -450,8 +450,8 @@ def emirrordist_main(args): portage.util.initialize_logger() if options.verbose > 0: - l = logging.getLogger() - l.setLevel(l.getEffectiveLevel() - 10 * options.verbose) + logger = logging.getLogger() + logger.setLevel(logger.getEffectiveLevel() - 10 * options.verbose) with Config(options, portdb, SchedulerInterface(global_event_loop())) as config: if not options.mirror: diff --git a/lib/portage/cache/flat_hash.py b/lib/portage/cache/flat_hash.py index cc05362769..690fe6e89e 100644 --- a/lib/portage/cache/flat_hash.py +++ b/lib/portage/cache/flat_hash.py @@ -124,8 +124,8 @@ def __iter__(self): raise del e continue - for l in dir_list: - p = os.path.join(dir_path, l) + for directory in dir_list: + p = os.path.join(dir_path, directory) try: st = os.lstat(p) except OSError: diff --git a/lib/portage/cache/mappings.py b/lib/portage/cache/mappings.py index 469f3dbc4a..7287347c8d 100644 --- a/lib/portage/cache/mappings.py +++ b/lib/portage/cache/mappings.py @@ -307,10 +307,10 @@ def __iter__(self): yield k def __len__(self): - l = 0 + result = 0 for i in self.iteritems(): - l += 1 - return l + result += 1 + return result def iteritems(self): prefix = self._prefix diff --git a/lib/portage/cache/sql_template.py b/lib/portage/cache/sql_template.py index ec058ab15a..26fb0258ee 100644 --- a/lib/portage/cache/sql_template.py +++ b/lib/portage/cache/sql_template.py @@ -273,21 +273,21 @@ def iteritems(self): raise cache_errors.CacheCorruption(self, cpv, e) oldcpv = None - l = [] + items = [] for x, y, v in self.con.fetchall(): if oldcpv != x: if oldcpv is not None: - d = dict(l) + d = dict(items) if "_eclasses_" in d: d["_eclasses_"] = reconstruct_eclasses(oldcpv, d["_eclasses_"]) else: d["_eclasses_"] = {} yield cpv, d - l.clear() + items.clear() oldcpv = x - l.append((y, v)) + items.append((y, v)) if oldcpv is not None: - d = dict(l) + d = dict(items) if "_eclasses_" in d: d["_eclasses_"] = reconstruct_eclasses(oldcpv, d["_eclasses_"]) else: diff --git a/lib/portage/dbapi/porttree.py b/lib/portage/dbapi/porttree.py index 5a4d69f372..6574ff8e7a 100644 --- a/lib/portage/dbapi/porttree.py +++ b/lib/portage/dbapi/porttree.py @@ -1128,10 +1128,10 @@ def cp_all(self, categories=None, trees=None, reverse=False, sort=True): if atom != atom.cp: continue d[atom.cp] = None - l = list(d) + result = list(d) if sort: - l.sort(reverse=reverse) - return l + result.sort(reverse=reverse) + return result def cp_list(self, mycp, use_cache=1, mytree=None): # NOTE: Cache can be safely shared with the match cache, since the diff --git a/lib/portage/dbapi/vartree.py b/lib/portage/dbapi/vartree.py index 0c41d408c3..b54ab92d23 100644 --- a/lib/portage/dbapi/vartree.py +++ b/lib/portage/dbapi/vartree.py @@ -1309,12 +1309,12 @@ def removeFromContents(self, pkg, paths, relative_paths=True): raise else: new_needed = [] - for l in needed_lines: - l = l.rstrip("\n") - if not l: + for line in needed_lines: + line = line.rstrip("\n") + if not line: continue try: - entry = NeededEntry.parse(needed_filename, l) + entry = NeededEntry.parse(needed_filename, line) except InvalidData as e: writemsg_level(f"\n{e}\n\n", level=logging.ERROR, noiselevel=-1) continue @@ -4154,8 +4154,8 @@ def _eerror(self, phase, lines): def _elog(self, funcname, phase, lines): func = getattr(portage.elog.messages, funcname) if self._scheduler is None: - for l in lines: - func(l, phase=phase, key=self.mycpv) + for line in lines: + func(line, phase=phase, key=self.mycpv) else: background = self.settings.get("PORTAGE_BACKGROUND") == "1" log_path = None diff --git a/lib/portage/dep/__init__.py b/lib/portage/dep/__init__.py index a4a5bf26bd..3db07216cc 100644 --- a/lib/portage/dep/__init__.py +++ b/lib/portage/dep/__init__.py @@ -324,9 +324,9 @@ def paren_reduce(mystr, _deprecation_warn=True): raise InvalidDependString(_("malformed syntax: '%s'") % mystr) if level > 0: level -= 1 - l = stack.pop() - is_single = len(l) == 1 or ( - len(l) == 2 and (l[0] == "||" or l[0][-1] == "?") + item = stack.pop() + is_single = len(item) == 1 or ( + len(item) == 2 and (item[0] == "||" or item[0][-1] == "?") ) def ends_in_any_of_dep(k): @@ -346,31 +346,31 @@ def special_append(): if is_single and ( not stack[level] or not stack[level][-1][-1] == "?" ): - if len(l) == 1 and isinstance(l[0], list): - # l = [[...]] - stack[level].extend(l[0]) + if len(item) == 1 and isinstance(item[0], list): + # item = [[...]] + stack[level].extend(item[0]) else: - stack[level].extend(l) + stack[level].extend(item) else: - stack[level].append(l) + stack[level].append(item) - if l: + if item: if not ends_in_any_of_dep(level - 1) and not ends_in_operator( level ): # Optimize: ( ( ... ) ) -> ( ... ). Make sure there is no '||' hanging around. - stack[level].extend(l) + stack[level].extend(item) elif not stack[level]: # An '||' in the level above forces us to keep to brackets. special_append() - elif len(l) == 1 and ends_in_any_of_dep(level): + elif len(item) == 1 and ends_in_any_of_dep(level): # Optimize: || ( A ) -> A stack[level].pop() special_append() elif ( - len(l) == 2 - and (l[0] == "||" or l[0][-1] == "?") - and stack[level][-1] in (l[0], "||") + len(item) == 2 + and (item[0] == "||" or item[0][-1] == "?") + and stack[level][-1] in (item[0], "||") ): # Optimize: || ( || ( ... ) ) -> || ( ... ) # foo? ( foo? ( ... ) ) -> foo? ( ... ) @@ -647,12 +647,12 @@ def missing_white_space_check(token, pos): ) if level > 0: level -= 1 - l = stack.pop() + item = stack.pop() is_single = ( - len(l) == 1 - or (opconvert and l and l[0] == "||") - or (not opconvert and len(l) == 2 and l[0] == "||") + len(item) == 1 + or (opconvert and item and item[0] == "||") + or (not opconvert and len(item) == 2 and item[0] == "||") ) ignore = False @@ -664,19 +664,19 @@ def missing_white_space_check(token, pos): # Merge the current list if needed. if is_active(stack[level][-1]): stack[level].pop() - stack[level].extend(l) + stack[level].extend(item) else: stack[level].pop() else: - stack[level].extend(l) + stack[level].extend(item) continue if stack[level] and isinstance(stack[level][-1], str): - if stack[level][-1] == "||" and not l: + if stack[level][-1] == "||" and not item: # Optimize: || ( ) -> . if not eapi_attrs.empty_groups_always_true: # in EAPI 7+, we need to fail here - l.append((token_class or str)("__const__/empty-any-of")) + item.append((token_class or str)("__const__/empty-any-of")) stack[level].pop() elif stack[level][-1][-1] == "?": # The last token before the '(' that matches the current ')' @@ -713,45 +713,45 @@ def special_append(): """ if is_single: # Either [A], [[...]] or [|| [...]] - if l[0] == "||" and ends_in_any_of_dep(level - 1): + if item[0] == "||" and ends_in_any_of_dep(level - 1): if opconvert: - stack[level].extend(l[1:]) + stack[level].extend(item[1:]) else: - stack[level].extend(l[1]) - elif len(l) == 1 and isinstance(l[0], list): - # l = [[...]] + stack[level].extend(item[1]) + elif len(item) == 1 and isinstance(item[0], list): + # item = [[...]] last = last_any_of_operator_level(level - 1) if last == -1: if ( opconvert - and isinstance(l[0], list) - and l[0] - and l[0][0] == "||" + and isinstance(item[0], list) + and item[0] + and item[0][0] == "||" ): - stack[level].append(l[0]) + stack[level].append(item[0]) else: - stack[level].extend(l[0]) + stack[level].extend(item[0]) else: - if opconvert and l[0] and l[0][0] == "||": - stack[level].extend(l[0][1:]) + if opconvert and item[0] and item[0][0] == "||": + stack[level].extend(item[0][1:]) else: - stack[level].append(l[0]) + stack[level].append(item[0]) else: - stack[level].extend(l) + stack[level].extend(item) else: if opconvert and stack[level] and stack[level][-1] == "||": - stack[level][-1] = ["||"] + l + stack[level][-1] = ["||"] + item else: - stack[level].append(l) + stack[level].append(item) - if l and not ignore: + if item and not ignore: # The current list is not empty and we don't want to ignore it because # of an inactive use conditional. if not ends_in_any_of_dep(level - 1) and not ends_in_any_of_dep( level ): # Optimize: ( ( ... ) ) -> ( ... ). Make sure there is no '||' hanging around. - stack[level].extend(l) + stack[level].extend(item) elif not stack[level]: # An '||' in the level above forces us to keep to brackets. special_append() @@ -762,13 +762,13 @@ def special_append(): elif ends_in_any_of_dep(level) and ends_in_any_of_dep(level - 1): # Optimize: || ( A || ( B C ) ) -> || ( A B C ) stack[level].pop() - stack[level].extend(l) + stack[level].extend(item) else: if opconvert and ends_in_any_of_dep(level): # In opconvert mode, we have to move the operator from the level # above into the current list. stack[level].pop() - stack[level].append(["||"] + l) + stack[level].append(["||"] + item) else: special_append() @@ -2786,7 +2786,7 @@ def register_token(token): raise InvalidDependString(_("malformed syntax: '%s'") % required_use) if level > 0: level -= 1 - l = stack.pop() + item = stack.pop() ignore = False if stack[level]: if stack[level][-1] in valid_operators or ( @@ -2797,8 +2797,8 @@ def register_token(token): stack[level].pop() stack[level].append(True) - if l and not ignore: - stack[level].append(all(x for x in l)) + if item and not ignore: + stack[level].append(all(x for x in item)) else: raise InvalidDependString(_("malformed syntax: '%s'") % required_use) elif token in valid_operators: @@ -2955,12 +2955,12 @@ def is_satisfied(operator, argument): raise InvalidDependString(_("malformed syntax: '%s'") % required_use) if level > 0: level -= 1 - l = stack.pop() + item = stack.pop() op = None if stack[level]: if stack[level][-1] in valid_operators: op = stack[level].pop() - satisfied = is_satisfied(op, l) + satisfied = is_satisfied(op, item) stack[level].append(satisfied) node._satisfied = satisfied @@ -2970,7 +2970,7 @@ def is_satisfied(operator, argument): ): op = stack[level].pop() if is_active(op[:-1]): - satisfied = is_satisfied(op, l) + satisfied = is_satisfied(op, item) stack[level].append(satisfied) node._satisfied = satisfied else: @@ -2982,9 +2982,9 @@ def is_satisfied(operator, argument): continue if op is None: - satisfied = False not in l + satisfied = False not in item node._satisfied = satisfied - if l: + if item: stack[level].append(satisfied) if ( @@ -3104,9 +3104,9 @@ def flag(conditional): raise InvalidDependString(_("malformed syntax: '%s'") % mystr) if level > 0: level -= 1 - l = stack.pop() - is_single = len(l) == 1 or ( - len(l) == 2 and (l[0] == "||" or l[0][-1] == "?") + item = stack.pop() + is_single = len(item) == 1 or ( + len(item) == 2 and (item[0] == "||" or item[0][-1] == "?") ) def ends_in_any_of_dep(k): @@ -3126,39 +3126,39 @@ def special_append(): if is_single and ( not stack[level] or not stack[level][-1][-1] == "?" ): - if len(l) == 1 and isinstance(l[0], list): - # l = [[...]] - stack[level].extend(l[0]) + if len(item) == 1 and isinstance(item[0], list): + # item = [[...]] + stack[level].extend(item[0]) else: - stack[level].extend(l) + stack[level].extend(item) else: - stack[level].append(l) + stack[level].append(item) - if l: + if item: if not ends_in_any_of_dep(level - 1) and not ends_in_operator( level ): # Optimize: ( ( ... ) ) -> ( ... ). Make sure there is no '||' hanging around. - stack[level].extend(l) + stack[level].extend(item) elif not stack[level]: # An '||' in the level above forces us to keep to brackets. special_append() - elif len(l) == 1 and ends_in_any_of_dep(level): + elif len(item) == 1 and ends_in_any_of_dep(level): # Optimize: || ( A ) -> A stack[level].pop() special_append() elif ( - len(l) == 2 - and (l[0] == "||" or l[0][-1] == "?") - and stack[level][-1] in (l[0], "||") + len(item) == 2 + and (item[0] == "||" or item[0][-1] == "?") + and stack[level][-1] in (item[0], "||") ): # Optimize: || ( || ( ... ) ) -> || ( ... ) # foo? ( foo? ( ... ) ) -> foo? ( ... ) # || ( foo? ( ... ) ) -> foo? ( ... ) stack[level].pop() special_append() - if l[0][-1] == "?": - affecting_use.add(flag(l[0])) + if item[0][-1] == "?": + affecting_use.add(flag(item[0])) else: if stack[level] and stack[level][-1][-1] == "?": affecting_use.add(flag(stack[level][-1])) diff --git a/lib/portage/elog/messages.py b/lib/portage/elog/messages.py index 3ec9dd80e0..2ce3c61173 100644 --- a/lib/portage/elog/messages.py +++ b/lib/portage/elog/messages.py @@ -63,16 +63,17 @@ def collect_ebuild_messages(path): ) # Use split('\n') since normal line iteration or readlines() will # split on \r characters as shown in bug #390833. - for l in f.read().split("\n"): - if not l: + for line in f.read().split("\n"): + if not line: continue try: - msgtype, msg = l.split(" ", 1) + msgtype, msg = line.split(" ", 1) if msgtype not in _log_levels: raise ValueError(msgtype) except ValueError: writemsg( - _("!!! malformed entry in " "log file: '%s': %s\n") % (filename, l), + _("!!! malformed entry in " "log file: '%s': %s\n") + % (filename, line), noiselevel=-1, ) continue diff --git a/lib/portage/env/config.py b/lib/portage/env/config.py index 3535802516..5537fdddeb 100644 --- a/lib/portage/env/config.py +++ b/lib/portage/env/config.py @@ -59,8 +59,8 @@ def __init__(self, filename): def load(self): for loader in self.loaders: - l = loader(self.filename, None) - data, errors = l.load() + file = loader(self.filename, None) + data, errors = file.load() if len(data) and not len(errors): (self.data, self.errors) = (data, errors) return diff --git a/lib/portage/gpkg.py b/lib/portage/gpkg.py index fdb54c69b8..7f946b08a9 100644 --- a/lib/portage/gpkg.py +++ b/lib/portage/gpkg.py @@ -545,11 +545,11 @@ def _check_gpg_status(self, gpg_status): good_signature = False trust_signature = False - for l in gpg_status.splitlines(): - if l.startswith("[GNUPG:] GOODSIG"): + for line in gpg_status.splitlines(): + if line.startswith("[GNUPG:] GOODSIG"): good_signature = True - if l.startswith("[GNUPG:] TRUST_ULTIMATE") or l.startswith( + if line.startswith("[GNUPG:] TRUST_ULTIMATE") or line.startswith( "[GNUPG:] TRUST_FULLY" ): trust_signature = True diff --git a/lib/portage/package/ebuild/_config/LicenseManager.py b/lib/portage/package/ebuild/_config/LicenseManager.py index 90f7742e30..7f9521e93e 100644 --- a/lib/portage/package/ebuild/_config/LicenseManager.py +++ b/lib/portage/package/ebuild/_config/LicenseManager.py @@ -95,15 +95,15 @@ def _expandLicenseToken(self, token, traversed_groups): rValue.append("@" + group_name) elif license_group: traversed_groups.add(group_name) - for l in license_group: - if l.startswith("-"): + for lic in license_group: + if lic.startswith("-"): writemsg( _("Skipping invalid element %s" " in license group '%s'\n") - % (l, group_name), + % (lic, group_name), noiselevel=-1, ) else: - rValue.extend(self._expandLicenseToken(l, traversed_groups)) + rValue.extend(self._expandLicenseToken(lic, traversed_groups)) else: if self._license_groups and group_name not in self._undef_lic_groups: self._undef_lic_groups.add(group_name) diff --git a/lib/portage/package/ebuild/_config/UseManager.py b/lib/portage/package/ebuild/_config/UseManager.py index 3827ba27a7..aed61eeb22 100644 --- a/lib/portage/package/ebuild/_config/UseManager.py +++ b/lib/portage/package/ebuild/_config/UseManager.py @@ -321,7 +321,7 @@ def _parse_user_files_to_extatomdict(self, file_name, location, user_config): allow_use=False, ) for k, v in pusedict.items(): - l = [] + items = [] use_expand_prefix = "" for flag in v: if flag == "\n": @@ -334,8 +334,8 @@ def _parse_user_files_to_extatomdict(self, file_name, location, user_config): nv = "-" + use_expand_prefix + flag[1:] else: nv = use_expand_prefix + flag - l.append(nv) - ret.setdefault(k.cp, {})[k] = tuple(l) + items.append(nv) + ret.setdefault(k.cp, {})[k] = tuple(items) return ret diff --git a/lib/portage/package/ebuild/doebuild.py b/lib/portage/package/ebuild/doebuild.py index c7fa1d1e06..1f67b1a7bc 100644 --- a/lib/portage/package/ebuild/doebuild.py +++ b/lib/portage/package/ebuild/doebuild.py @@ -583,8 +583,8 @@ def doebuild_environment( masquerades.append(("ccache", "ccache")) for feature, m in masquerades: - for l in possible_libexecdirs: - p = os.path.join(os.sep, eprefix_lstrip, "usr", l, m, "bin") + for directory in possible_libexecdirs: + p = os.path.join(os.sep, eprefix_lstrip, "usr", directory, m, "bin") if os.path.isdir(p): mysettings["PATH"] = p + ":" + mysettings["PATH"] break @@ -2850,13 +2850,13 @@ def _post_src_install_uid_fix(mysettings, out): break if desktopfile_errors: - for l in _merge_desktopfile_error(desktopfile_errors): - l = l.replace(mysettings["ED"], "/") - eqawarn(l, phase="install", key=mysettings.mycpv, out=out) + for error in _merge_desktopfile_error(desktopfile_errors): + error = error.replace(mysettings["ED"], "/") + eqawarn(error, phase="install", key=mysettings.mycpv, out=out) if unicode_errors: - for l in _merge_unicode_error(unicode_errors): - eqawarn(l, phase="install", key=mysettings.mycpv, out=out) + for error in _merge_unicode_error(unicode_errors): + eqawarn(error, phase="install", key=mysettings.mycpv, out=out) build_info_dir = os.path.join(mysettings["PORTAGE_BUILDDIR"], "build-info") @@ -3081,12 +3081,12 @@ def is_libdir(obj_parent): needed_filename, encoding=_encodings["repo.content"], errors="strict" ) - for l in lines: - l = l.rstrip("\n") - if not l: + for line in lines: + line = line.rstrip("\n") + if not line: continue try: - entry = NeededEntry.parse(needed_filename, l) + entry = NeededEntry.parse(needed_filename, line) except InvalidData as e: portage.util.writemsg_level( f"\n{e}\n\n", level=logging.ERROR, noiselevel=-1 diff --git a/lib/portage/package/ebuild/fetch.py b/lib/portage/package/ebuild/fetch.py index ed40cf6ede..ad07015702 100644 --- a/lib/portage/package/ebuild/fetch.py +++ b/lib/portage/package/ebuild/fetch.py @@ -1047,10 +1047,10 @@ def fetch( if not file_restrict_mirror: location_lists.append(public_mirrors) - for l in itertools.chain(*location_lists): + for location in itertools.chain(*location_lists): filedict[myfile].append( functools.partial( - get_mirror_url, l, myfile, mysettings, mirror_cache + get_mirror_url, location, myfile, mysettings, mirror_cache ) ) if myuri is None: diff --git a/lib/portage/package/ebuild/getmaskingreason.py b/lib/portage/package/ebuild/getmaskingreason.py index 7fb1c15726..8e235e3c3d 100644 --- a/lib/portage/package/ebuild/getmaskingreason.py +++ b/lib/portage/package/ebuild/getmaskingreason.py @@ -80,13 +80,13 @@ def getmaskingreason( for profile in locations: pmask_filename = os.path.join(profile, "package.mask") node = None - for l, recursive_filename in grablines( + for line, recursive_filename in grablines( pmask_filename, recursive=1, remember_source_file=True ): if node is None or node[0] != recursive_filename: node = (recursive_filename, []) pmasklists.append(node) - node[1].append(l) + node[1].append(line) pmaskdict = settings._mask_manager._pmaskdict if mycp in pmaskdict: @@ -98,18 +98,18 @@ def getmaskingreason( comment_valid = -1 pmask_filename = pmask[0] for i in range(len(pmask[1])): - l = pmask[1][i].strip() + line = pmask[1][i].strip() try: l_atom = Atom( - l, allow_repo=True, allow_wildcard=True + line, allow_repo=True, allow_wildcard=True ).without_repo except InvalidAtom: l_atom = None - if l == "": + if line == "": comment = "" comment_valid = -1 - elif l[0] == "#": - comment += l + "\n" + elif line[0] == "#": + comment += line + "\n" comment_valid = i + 1 elif l_atom == x: if comment_valid != i: diff --git a/lib/portage/sync/syncbase.py b/lib/portage/sync/syncbase.py index c3a07da7d7..5cf29600ba 100644 --- a/lib/portage/sync/syncbase.py +++ b/lib/portage/sync/syncbase.py @@ -61,12 +61,12 @@ def has_bin(self): MUST only be called after _kwargs() has set the logger """ if self.bin_command is None: - msg = [ + msgs = [ f"Command not found: {self._bin_command}", f'Type "emerge {self.bin_pkg}" to enable {self._bin_command} support.', ] - for l in msg: - writemsg_level(f"!!! {l}\n", level=logging.ERROR, noiselevel=-1) + for msg in msgs: + writemsg_level(f"!!! {msg}\n", level=logging.ERROR, noiselevel=-1) return False try: diff --git a/lib/portage/util/ExtractKernelVersion.py b/lib/portage/util/ExtractKernelVersion.py index af6b96ee36..3a7926427c 100644 --- a/lib/portage/util/ExtractKernelVersion.py +++ b/lib/portage/util/ExtractKernelVersion.py @@ -41,7 +41,7 @@ def ExtractKernelVersion(base_dir): finally: f.close() - lines = [l.strip() for l in lines] + lines = [line.strip() for line in lines] version = "" diff --git a/lib/portage/util/__init__.py b/lib/portage/util/__init__.py index 50fa1680ff..67ac5416a8 100644 --- a/lib/portage/util/__init__.py +++ b/lib/portage/util/__init__.py @@ -2010,14 +2010,14 @@ def find_updated_config_files(target_root, config_protect): def getlibpaths(root, env=None): def read_ld_so_conf(path): - for l in grabfile(path): - include_match = _ld_so_include_re.match(l) + for file in grabfile(path): + include_match = _ld_so_include_re.match(file) if include_match is not None: subpath = os.path.join(os.path.dirname(path), include_match.group(1)) for p in glob.glob(subpath): yield from read_ld_so_conf(p) else: - yield l + yield file """ Return a list of paths that are used for library lookups """ if env is None: diff --git a/lib/portage/util/_dyn_libs/LinkageMapELF.py b/lib/portage/util/_dyn_libs/LinkageMapELF.py index 67ed16ccbc..2b09770dd1 100644 --- a/lib/portage/util/_dyn_libs/LinkageMapELF.py +++ b/lib/portage/util/_dyn_libs/LinkageMapELF.py @@ -281,29 +281,29 @@ def rebuild(self, exclude_pkgs=None, include_file=None, preserve_paths=None): raise raise CommandNotFound(args[0]) else: - for l in proc.stdout: + for line in proc.stdout: try: - l = _unicode_decode( - l, encoding=_encodings["content"], errors="strict" + line = _unicode_decode( + line, encoding=_encodings["content"], errors="strict" ) except UnicodeDecodeError: - l = _unicode_decode( - l, encoding=_encodings["content"], errors="replace" + line = _unicode_decode( + line, encoding=_encodings["content"], errors="replace" ) writemsg_level( _( "\nError decoding characters " "returned from scanelf: %s\n\n" ) - % (l,), + % (line,), level=logging.ERROR, noiselevel=-1, ) - l = l[3:].rstrip("\n") - if not l: + line = line[3:].rstrip("\n") + if not line: continue try: - entry = NeededEntry.parse("scanelf", l) + entry = NeededEntry.parse("scanelf", line) except InvalidData as e: writemsg_level(f"\n{e}\n\n", level=logging.ERROR, noiselevel=-1) continue @@ -369,23 +369,24 @@ def rebuild(self, exclude_pkgs=None, include_file=None, preserve_paths=None): while True: try: - owner, location, l = lines.pop() + owner, location, line = lines.pop() except IndexError: break - l = l.rstrip("\n") - if not l: + line = line.rstrip("\n") + if not line: continue - if "\0" in l: + if "\0" in line: # os.stat() will raise "TypeError: must be encoded string # without NULL bytes, not str" in this case. writemsg_level( - _("\nLine contains null byte(s) " "in %s: %s\n\n") % (location, l), + _("\nLine contains null byte(s) " "in %s: %s\n\n") + % (location, line), level=logging.ERROR, noiselevel=-1, ) continue try: - entry = NeededEntry.parse(location, l) + entry = NeededEntry.parse(location, line) except InvalidData as e: writemsg_level(f"\n{e}\n\n", level=logging.ERROR, noiselevel=-1) continue diff --git a/lib/portage/util/_dyn_libs/soname_deps_qa.py b/lib/portage/util/_dyn_libs/soname_deps_qa.py index 4c659d1e36..13b6aa2511 100644 --- a/lib/portage/util/_dyn_libs/soname_deps_qa.py +++ b/lib/portage/util/_dyn_libs/soname_deps_qa.py @@ -88,11 +88,11 @@ def _get_unresolved_soname_deps(metadata_dir, all_provides): needed = f.readlines() unresolved_by_file = [] - for l in needed: - l = l.rstrip("\n") - if not l: + for line in needed: + line = line.rstrip("\n") + if not line: continue - entry = NeededEntry.parse(needed_filename, l) + entry = NeededEntry.parse(needed_filename, line) missing = unresolved_by_category.get(entry.multilib_category) if not missing: continue diff --git a/lib/portage/util/locale.py b/lib/portage/util/locale.py index f45d761760..3a9bfe5619 100644 --- a/lib/portage/util/locale.py +++ b/lib/portage/util/locale.py @@ -67,9 +67,9 @@ def _check_locale(silent): + "en_US.UTF-8) in /etc/locale.gen and setting it " + "as LC_CTYPE in make.conf." ) - msg = [l for l in textwrap.wrap(msg, 70)] + msg = [line for line in textwrap.wrap(msg, 70)] msg.append("") - chars = lambda l: "".join(_unicode_decode(chr(x)) for x in l) + chars = lambda line: "".join(_unicode_decode(chr(x)) for x in line) if uc != ruc: msg.extend( [ @@ -85,7 +85,9 @@ def _check_locale(silent): ] ) writemsg_level( - "".join([f"!!! {l}\n" for l in msg]), level=logging.ERROR, noiselevel=-1 + "".join([f"!!! {line}\n" for line in msg]), + level=logging.ERROR, + noiselevel=-1, ) return False