From 04b2b5160eb8d8123d6907984f0b7651323ba247 Mon Sep 17 00:00:00 2001 From: Arohan Ajit Date: Thu, 12 Sep 2024 12:59:10 -0400 Subject: [PATCH] CI: Fix Flake8 linter errors in man/ directory (#4292) * resolved some more flake8 warnings * fixed all man flake8 errors except buildhtml * Update .flake8 --------- Co-authored-by: Arohan Ajit --- .flake8 | 11 ----------- man/build_check.py | 2 +- man/build_check_rest.py | 2 +- man/build_class.py | 15 ++++++++++++++- man/build_class_rest.py | 14 +++++++++++++- man/build_full_index.py | 16 +++++++++++++++- man/build_full_index_rest.py | 15 ++++++++++++++- man/build_index.py | 9 ++++++++- man/build_index_rest.py | 9 ++++++++- man/build_keywords.py | 18 ++++++++++++------ man/build_topics.py | 16 ++++++++++++---- 11 files changed, 98 insertions(+), 29 deletions(-) diff --git a/.flake8 b/.flake8 index 4afa5809c80..3182812dd1d 100644 --- a/.flake8 +++ b/.flake8 @@ -20,17 +20,6 @@ per-file-ignores = # F841 local variable assigned to but never used # E741 ambiguous variable name 'l' __init__.py: F401, F403 - man/build_check_rest.py: F403, F405 - man/build_full_index_rest.py: F403, F405 - man/parser_standard_options.py: F403, F405 - man/build_class.py: F403, F405 - man/build_class_rest.py: F403, F405 - man/build_check.py: F403, F405 - man/build_full_index.py: F403, F405 - man/build_index.py: F403, F405 - man/build_index_rest.py: F403, F405 - man/build_keywords.py: F403, F405, E722 - man/build_topics.py: F403, F405, E722 man/build_html.py: E501 imagery/i.atcorr/create_iwave.py: F632, F821, W293 doc/python/raster_example_ctypes.py: F403, F405 diff --git a/man/build_check.py b/man/build_check.py index 6111a4dbe9f..9d9675fb7ac 100644 --- a/man/build_check.py +++ b/man/build_check.py @@ -9,7 +9,7 @@ import sys import os -from build_html import * +from build_html import html_dir, message_tmpl, html_files, read_file os.chdir(html_dir) diff --git a/man/build_check_rest.py b/man/build_check_rest.py index 159be8453db..f9868dfd697 100644 --- a/man/build_check_rest.py +++ b/man/build_check_rest.py @@ -9,7 +9,7 @@ import sys import os -from build_rest import * +from build_rest import rest_dir, message_tmpl, rest_files, read_file os.chdir(rest_dir) diff --git a/man/build_class.py b/man/build_class.py index 8300c62079f..564fb5c20e6 100644 --- a/man/build_class.py +++ b/man/build_class.py @@ -9,7 +9,20 @@ import sys import os -from build_html import * +from build_html import ( + html_dir, + write_html_header, + grass_version, + modclass_intro_tmpl, + modclass_tmpl, + to_title, + html_files, + check_for_desc_override, + get_desc, + desc2_tmpl, + write_html_footer, + replace_file, +) no_intro_page_classes = ["display", "general", "miscellaneous", "postscript"] diff --git a/man/build_class_rest.py b/man/build_class_rest.py index c1de3d623d0..05aec125d04 100644 --- a/man/build_class_rest.py +++ b/man/build_class_rest.py @@ -9,7 +9,19 @@ import sys import os -from build_rest import * +from build_rest import ( + rest_dir, + grass_version, + modclass_intro_tmpl, + modclass_tmpl, + desc2_tmpl, + write_rest_header, + write_rest_footer, + rest_files, + check_for_desc_override, + get_desc, + replace_file, +) os.chdir(rest_dir) diff --git a/man/build_full_index.py b/man/build_full_index.py index 76379787905..ead5167cbb1 100644 --- a/man/build_full_index.py +++ b/man/build_full_index.py @@ -9,7 +9,21 @@ import sys import os -from build_html import * +from build_html import ( + html_dir, + grass_version, + html_files, + write_html_header, + write_html_footer, + check_for_desc_override, + get_desc, + replace_file, + to_title, + full_index_header, + toc, + cmd2_tmpl, + desc1_tmpl, +) year = None if len(sys.argv) > 1: diff --git a/man/build_full_index_rest.py b/man/build_full_index_rest.py index 14167df0f84..26183505393 100644 --- a/man/build_full_index_rest.py +++ b/man/build_full_index_rest.py @@ -8,7 +8,20 @@ import os -from build_rest import * +from build_rest import ( + rest_dir, + rest_files, + write_rest_header, + grass_version, + full_index_header, + sections, + cmd2_tmpl, + check_for_desc_override, + get_desc, + desc1_tmpl, + write_rest_footer, + replace_file, +) os.chdir(rest_dir) diff --git a/man/build_index.py b/man/build_index.py index 5a01787afe3..12de7f01162 100644 --- a/man/build_index.py +++ b/man/build_index.py @@ -9,7 +9,14 @@ import sys import os -from build_html import * +from build_html import ( + html_dir, + grass_version, + write_html_header, + write_html_cmd_overview, + write_html_footer, + replace_file, +) os.chdir(html_dir) diff --git a/man/build_index_rest.py b/man/build_index_rest.py index 68463bbb753..b919042e4af 100644 --- a/man/build_index_rest.py +++ b/man/build_index_rest.py @@ -9,7 +9,14 @@ import os -from build_rest import * +from build_rest import ( + rest_dir, + grass_version, + write_rest_header, + write_rest_cmd_overview, + write_rest_footer, + replace_file, +) os.chdir(rest_dir) diff --git a/man/build_keywords.py b/man/build_keywords.py index 477c1a131ff..6070fad1a28 100644 --- a/man/build_keywords.py +++ b/man/build_keywords.py @@ -21,7 +21,13 @@ import os import sys import glob -from build_html import * +from build_html import ( + grass_version, + header1_tmpl, + headerkeywords_tmpl, + write_html_footer, +) + blacklist = [ "Display", @@ -81,17 +87,17 @@ def get_module_man_html_file_path(module): try: index_keys = lines.index("

KEYWORDS

\n") + 1 index_desc = lines.index("

NAME

\n") + 1 - except: + except Exception: continue try: keys = lines[index_keys].split(",") - except: + except Exception: continue for key in keys: key = key.strip() try: key = key.split(">")[1].split("<")[0] - except: + except Exception: pass if not key: sys.exit("Empty keyword from file %s line: %s" % (fname, lines[index_keys])) @@ -104,10 +110,10 @@ def get_module_man_html_file_path(module): for black in blacklist: try: del keywords[black] - except: + except Exception: try: del keywords[black.lower()] - except: + except Exception: continue for key in sorted(keywords.keys()): diff --git a/man/build_topics.py b/man/build_topics.py index bd0606d1aeb..be5f2962d2c 100644 --- a/man/build_topics.py +++ b/man/build_topics.py @@ -6,7 +6,15 @@ import os import sys import glob -from build_html import * +from build_html import ( + grass_version, + header1_tmpl, + headertopics_tmpl, + headerkey_tmpl, + desc1_tmpl, + moduletopics_tmpl, + write_html_footer, +) path = sys.argv[1] year = os.getenv("VERSION_DATE") @@ -24,16 +32,16 @@ try: index_keys = lines.index("

KEYWORDS

\n") + 1 index_desc = lines.index("

NAME

\n") + 1 - except: + except Exception: continue try: key = lines[index_keys].split(",")[1].strip().replace(" ", "_") key = key.split(">")[1].split("<")[0] - except: + except Exception: continue try: desc = lines[index_desc].split("-", 1)[1].strip() - except: + except Exception: desc.strip() if key not in keywords.keys(): keywords[key] = {}