Skip to content

Commit

Permalink
CI: Fix Flake8 linter errors in man/ directory (OSGeo#4292)
Browse files Browse the repository at this point in the history
* resolved some more flake8 warnings

* fixed all man flake8 errors except buildhtml

* Update .flake8

---------
Co-authored-by: Arohan Ajit <aajit@chirpn.com>
  • Loading branch information
arohanajit authored and Mahesh1998 committed Sep 19, 2024
1 parent a61aedf commit 04b2b51
Show file tree
Hide file tree
Showing 11 changed files with 98 additions and 29 deletions.
11 changes: 0 additions & 11 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion man/build_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion man/build_check_rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
15 changes: 14 additions & 1 deletion man/build_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
14 changes: 13 additions & 1 deletion man/build_class_rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
16 changes: 15 additions & 1 deletion man/build_full_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
15 changes: 14 additions & 1 deletion man/build_full_index_rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
9 changes: 8 additions & 1 deletion man/build_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
9 changes: 8 additions & 1 deletion man/build_index_rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
18 changes: 12 additions & 6 deletions man/build_keywords.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -81,17 +87,17 @@ def get_module_man_html_file_path(module):
try:
index_keys = lines.index("<h2>KEYWORDS</h2>\n") + 1
index_desc = lines.index("<h2>NAME</h2>\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]))
Expand All @@ -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()):
Expand Down
16 changes: 12 additions & 4 deletions man/build_topics.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -24,16 +32,16 @@
try:
index_keys = lines.index("<h2>KEYWORDS</h2>\n") + 1
index_desc = lines.index("<h2>NAME</h2>\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] = {}
Expand Down

0 comments on commit 04b2b51

Please sign in to comment.