vimPlugins: normalize deprecation names

Parsing plugin lines in multiple places is hazardous and already manifested a
bug!
This commit is contained in:
ryneeverett 2020-03-29 16:09:59 +00:00
parent 1f32eb7987
commit 1c0f0de46c
2 changed files with 16 additions and 9 deletions

View file

@ -9,10 +9,10 @@
}, },
"vundle": { "vundle": {
"date": "2020-03-27", "date": "2020-03-27",
"new": "Vundle.vim" "new": "Vundle-vim"
}, },
"youcompleteme": { "youcompleteme": {
"date": "2020-03-27", "date": "2020-03-27",
"new": "YouCompleteMe" "new": "YouCompleteMe"
} }
} }

View file

@ -246,6 +246,11 @@ def prefetch_plugin(
) )
def fetch_plugin_from_pluginline(plugin_line: str) -> Plugin:
plugin, _ = prefetch_plugin(*parse_plugin_line(plugin_line))
return plugin
def print_download_error(plugin: str, ex: Exception): def print_download_error(plugin: str, ex: Exception):
print(f"{plugin}: {ex}", file=sys.stderr) print(f"{plugin}: {ex}", file=sys.stderr)
ex_traceback = ex.__traceback__ ex_traceback = ex.__traceback__
@ -418,7 +423,9 @@ in lib.fix' (lib.extends overrides packages)
print(f"updated {outfile}") print(f"updated {outfile}")
def rewrite_input(input_file: Path, redirects: dict = None, append: Tuple = ()): def rewrite_input(
input_file: Path, redirects: Dict[str, str] = None, append: Tuple = ()
):
with open(input_file, "r") as f: with open(input_file, "r") as f:
lines = f.readlines() lines = f.readlines()
@ -431,11 +438,11 @@ def rewrite_input(input_file: Path, redirects: dict = None, append: Tuple = ()):
with open(DEPRECATED, "r") as f: with open(DEPRECATED, "r") as f:
deprecations = json.load(f) deprecations = json.load(f)
for old, new in redirects.items(): for old, new in redirects.items():
old_name = old.split("/")[1].split(" ")[0].strip("\n") old_plugin = fetch_plugin_from_pluginline(old)
new_name = new.split("/")[1].split(" ")[0].strip("\n") new_plugin = fetch_plugin_from_pluginline(new)
if old_name != new_name: if old_plugin.normalized_name != new_plugin.normalized_name:
deprecations[old_name] = { deprecations[old_plugin.normalized_name] = {
"new": new_name, "new": new_plugin.normalized_name,
"date": cur_date_iso, "date": cur_date_iso,
} }
with open(DEPRECATED, "w") as f: with open(DEPRECATED, "w") as f:
@ -574,7 +581,7 @@ def main() -> None:
rewrite_input(args.input_file, append=(plugin_line + "\n",)) rewrite_input(args.input_file, append=(plugin_line + "\n",))
updater() updater()
plugin, _ = prefetch_plugin(*parse_plugin_line(plugin_line)) plugin = fetch_plugin_from_pluginline(plugin_line)
nixpkgs_repo.commit( nixpkgs_repo.commit(
"vimPlugins.{name}: init at {version}".format( "vimPlugins.{name}: init at {version}".format(
name=plugin.normalized_name, version=plugin.version name=plugin.normalized_name, version=plugin.version