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
|
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}")
|
date_sep_line_list.append(f"{lineno:>5} {line}")
|
||||||
# 'if' lines could be complicated
|
# 'if' lines could be complicated
|
||||||
elif "if " in line and "if =" not in line:
|
elif "if " in line and "if =" not in line:
|
||||||
@@ -99,18 +102,31 @@ def convert_to_throw(date_older_list: list[str]) -> list[tuple[str, str]]:
|
|||||||
converted_list = []
|
converted_list = []
|
||||||
for line in date_older_list.copy():
|
for line in date_older_list.copy():
|
||||||
indent: str = " " * (len(line) - len(line.lstrip()))
|
indent: str = " " * (len(line) - len(line.lstrip()))
|
||||||
before_equal = ""
|
|
||||||
after_equal = ""
|
|
||||||
try:
|
|
||||||
before_equal, after_equal = (x.strip() for x in line.split("=", maxsplit=2))
|
|
||||||
except ValueError as err:
|
|
||||||
print(err, line, "\n")
|
|
||||||
date_older_list.remove(line)
|
|
||||||
continue
|
|
||||||
|
|
||||||
alias = before_equal
|
if "=" not in line:
|
||||||
alias_unquoted = before_equal.strip('"')
|
assert "inherit (" in line
|
||||||
replacement = next(x.strip(";:") for x in after_equal.split())
|
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:
|
||||||
|
before_equal, after_equal = (x.strip() for x in line.split("=", maxsplit=2))
|
||||||
|
except ValueError as err:
|
||||||
|
print(err, line, "\n")
|
||||||
|
date_older_list.remove(line)
|
||||||
|
continue
|
||||||
|
|
||||||
|
alias = before_equal
|
||||||
|
replacement = next(x.strip(";:") for x in after_equal.split())
|
||||||
|
|
||||||
|
alias_unquoted = alias.strip('"')
|
||||||
replacement = replacement.removeprefix("pkgs.")
|
replacement = replacement.removeprefix("pkgs.")
|
||||||
|
|
||||||
converted = (
|
converted = (
|
||||||
|
|||||||
Reference in New Issue
Block a user