From d1ad143cf14fb9c529fc5b8a192ee37402b9eb52 Mon Sep 17 00:00:00 2001 From: MaxVerevkin <79253435110@ya.ru> Date: Wed, 8 Jul 2020 23:43:38 +0300 Subject: [PATCH] create_manpage_completions.py: refactor: clean up parse_manpage_at_path --- share/tools/create_manpage_completions.py | 35 +++++++++++------------ 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/share/tools/create_manpage_completions.py b/share/tools/create_manpage_completions.py index 75ae89773..f8079f54b 100755 --- a/share/tools/create_manpage_completions.py +++ b/share/tools/create_manpage_completions.py @@ -748,7 +748,21 @@ def cleanup_autogenerated_file(path): def parse_manpage_at_path(manpage_path, output_directory): - filename = os.path.basename(manpage_path) + # Return if CMDNAME is in 'ignoredcommands' + ignoredcommands = [ + "cc", + "g++", + "gcc", + "c++", + "cpp", + "emacs", + "gprof", + "wget", + "ld", + "awk", + ] + if CMDNAME in ignoredcommands: + return # Clear diagnostics global diagnostic_indent @@ -788,27 +802,10 @@ def parse_manpage_at_path(manpage_path, output_directory): manpage = str(manpage) - # Get the "base" command, e.g. gcc.1.gz -> gcc - cmd_base = CMDNAME.split(".", 1)[0] - ignoredcommands = [ - "cc", - "g++", - "gcc", - "c++", - "cpp", - "emacs", - "gprof", - "wget", - "ld", - "awk", - ] - if cmd_base in ignoredcommands: - return - # Ignore perl's gazillion man pages ignored_prefixes = ["perl", "zsh"] for prefix in ignored_prefixes: - if cmd_base.startswith(prefix): + if CMDNAME.startswith(prefix): return # Ignore the millions of links to BUILTIN(1)