maintainers/scripts/remove-old-aliases: handle inherit (x) y;
Man this script is not very nice
This commit is contained in:
committed by
Michael Daniels
parent
66737dcdb4
commit
2d3f108bb6
@@ -70,7 +70,10 @@ def get_date_lists(
|
||||
):
|
||||
continue
|
||||
|
||||
if "=" not in line:
|
||||
if line.lstrip().startswith("inherit (") and ";" in line:
|
||||
if not only_throws:
|
||||
date_older_list.append(line)
|
||||
elif "=" not in line:
|
||||
date_sep_line_list.append(f"{lineno:>5} {line}")
|
||||
# 'if' lines could be complicated
|
||||
elif "if " in line and "if =" not in line:
|
||||
@@ -99,6 +102,18 @@ def convert_to_throw(date_older_list: list[str]) -> list[tuple[str, str]]:
|
||||
converted_list = []
|
||||
for line in date_older_list.copy():
|
||||
indent: str = " " * (len(line) - len(line.lstrip()))
|
||||
|
||||
if "=" not in line:
|
||||
assert "inherit (" in line
|
||||
before, sep, after = line.partition("inherit (")
|
||||
inside, sep, after = after.partition(")")
|
||||
if not sep:
|
||||
print(f"FAILED ON {line}")
|
||||
continue
|
||||
alias, *_ = after.strip().split(";")[0].split()
|
||||
replacement = f"{inside.strip()}.{alias}"
|
||||
|
||||
else:
|
||||
before_equal = ""
|
||||
after_equal = ""
|
||||
try:
|
||||
@@ -109,8 +124,9 @@ def convert_to_throw(date_older_list: list[str]) -> list[tuple[str, str]]:
|
||||
continue
|
||||
|
||||
alias = before_equal
|
||||
alias_unquoted = before_equal.strip('"')
|
||||
replacement = next(x.strip(";:") for x in after_equal.split())
|
||||
|
||||
alias_unquoted = alias.strip('"')
|
||||
replacement = replacement.removeprefix("pkgs.")
|
||||
|
||||
converted = (
|
||||
|
||||
Reference in New Issue
Block a user