Skip to content

Commit

Permalink
Merge branch 'main' into db_make_md
Browse files Browse the repository at this point in the history
  • Loading branch information
neteler authored Nov 23, 2024
2 parents 2091b3e + f1093bd commit 480a06d
Show file tree
Hide file tree
Showing 16 changed files with 34 additions and 35 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/python-code-quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
# renovate: datasource=pypi depName=bandit
BANDIT_VERSION: "1.7.10"
# renovate: datasource=pypi depName=ruff
RUFF_VERSION: "0.7.4"
RUFF_VERSION: "0.8.0"

runs-on: ${{ matrix.os }}
permissions:
Expand Down
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ repos:
)
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.7.4
rev: v0.8.0
hooks:
# Run the linter.
- id: ruff
args: [--fix, --preview]
- repo: https://github.com/igorshubovych/markdownlint-cli
rev: v0.42.0
rev: v0.43.0
hooks:
- id: markdownlint-fix
# Using this mirror lets us use mypyc-compiled black, which is about 2x faster
Expand Down
4 changes: 2 additions & 2 deletions display/d.text/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ def text(in_text):
print(
".L 0\n"
+ re.sub(
'(".*?")',
r'(".*?")',
"\n.C red\n,\\g<0>\n.C gray\n",
re.sub("\n", "\n.L 1\n.L 0\n", re.sub("(?m)^#.*\n?", "", src)),
re.sub(r"\n", "\n.L 1\n.L 0\n", re.sub(r"(?m)^#.*\n?", "", src)),
)
)
2 changes: 1 addition & 1 deletion gui/wxpython/gmodeler/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -2672,7 +2672,7 @@ def _getParamName(self, parameter_name, item):
@staticmethod
def _getModuleNickname(item):
return "{module_name}{module_id}".format(
module_name=re.sub("[^a-zA-Z]+", "", item.GetLabel()),
module_name=re.sub(r"[^a-zA-Z]+", "", item.GetLabel()),
module_id=item.GetId(),
)

Expand Down
2 changes: 1 addition & 1 deletion gui/wxpython/photo2image/ip2i_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ def __init__(
fc_count = 0
for line in fc:
fc_count += 1
if re.search("NUM", line):
if re.search(r"NUM", line):
storeLine = fc_count
numberOfFiducial = int(line.split()[-1])
dataFiducialX = []
Expand Down
2 changes: 1 addition & 1 deletion lib/init/grass.py
Original file line number Diff line number Diff line change
Expand Up @@ -1015,7 +1015,7 @@ def load_env(grass_env_file):
# Regular expression for lines starting with "export var=val" (^export
# lines below). Environment variables should start with a-zA-Z or _.
# \1 and \2 are a variable name and its value, respectively.
export_re = re.compile("^export[ \t]+([a-zA-Z_]+[a-zA-Z0-9_]*)=(.*?)[ \t]*$")
export_re = re.compile(r"^export[ \t]+([a-zA-Z_]+[a-zA-Z0-9_]*)=(.*?)[ \t]*$")

for line in readfile(grass_env_file).splitlines():
# match ^export lines
Expand Down
3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ extend-exclude = '''
'''

[tool.ruff]
required-version = ">=0.6.0"
required-version = ">=0.8.0"

builtins = ["_"]

Expand Down Expand Up @@ -183,7 +183,6 @@ ignore = [
"PLW1641", # eq-without-hash
"PLW2901", # redefined-loop-name
"PLW3201", # bad-dunder-method-name
"PT004", # pytest-missing-fixture-name-underscore # deprecated, so doesn't appear with --preview
"PTH100", # os-path-abspath
"PTH101", # os-chmod
"PTH102", # os-mkdir
Expand Down
4 changes: 2 additions & 2 deletions python/grass/gunittest/case.py
Original file line number Diff line number Diff line change
Expand Up @@ -1320,10 +1320,10 @@ def runModule(cls, module, expecting_stdout=False, **kwargs):
# TODO: standardized error code would be handy here
import re

if re.search("Raster map.*not found", errors, flags=re.DOTALL):
if re.search(r"Raster map.*not found", errors, flags=re.DOTALL):
errors += "\nSee available raster maps:\n"
errors += call_module("g.list", type="raster")
if re.search("Vector map.*not found", errors, flags=re.DOTALL):
if re.search(r"Vector map.*not found", errors, flags=re.DOTALL):
errors += "\nSee available vector maps:\n"
errors += call_module("g.list", type="vector")
# TODO: message format, parameters
Expand Down
8 changes: 4 additions & 4 deletions python/grass/script/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ def convert(text):

def alphanum_key(actual_key):
sort_key = key(actual_key) if key else actual_key
return [convert(c) for c in re.split("([0-9]+)", sort_key)]
return [convert(c) for c in re.split(r"([0-9]+)", sort_key)]

items.sort(key=alphanum_key)

Expand Down Expand Up @@ -501,15 +501,15 @@ def legalize_vector_name(name, fallback_prefix="x"):
# The implementation is based on Vect_legal_filename().
if not name:
raise ValueError("name cannot be empty")
if fallback_prefix and re.match("[^A-Za-z]", fallback_prefix[0]):
if fallback_prefix and re.match(r"[^A-Za-z]", fallback_prefix[0]):
raise ValueError("fallback_prefix must start with an ASCII letter")
if fallback_prefix and re.match("[^A-Za-z]", name[0], flags=re.ASCII):
if fallback_prefix and re.match(r"[^A-Za-z]", name[0], flags=re.ASCII):
# We prefix here rather than just replace, because in cases of unique
# identifiers, e.g., columns or node names, replacing the first
# character by the same replacement character increases chances of
# conflict (e.g. column names 10, 20, 30).
name = "{fallback_prefix}{name}".format(**locals())
name = re.sub("[^A-Za-z0-9_]", "_", name, flags=re.ASCII)
name = re.sub(r"[^A-Za-z0-9_]", "_", name, flags=re.ASCII)
keywords = ["and", "or", "not"]
if name in keywords:
name = "{name}_".format(**locals())
Expand Down
2 changes: 1 addition & 1 deletion raster/r.topidx/arc_to_gridatb.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def match(pattern, string):
return False


if len(sys.argv) != 3 or re.match("^-*help", sys.argv[1]):
if len(sys.argv) != 3 or re.match(r"^-*help", sys.argv[1]):
print("Usage: arc.to.gridatb.py arc_file gridatb_file")
sys.exit()

Expand Down
4 changes: 2 additions & 2 deletions raster/r.topidx/gridatb_to_arc.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
len(sys.argv) == 1
or len(sys.argv) == 4
or len(sys.argv) > 5
or re.match("^-*help", sys.argv[1])
or re.match(r"^-*help", sys.argv[1])
):
print("Usage: gridatb.to.arc.py gridatb_file arc_file [xllcorner yllcorner]")
sys.exit()
Expand All @@ -33,7 +33,7 @@

title = inf.readline()
inline = inf.readline()
m = re.match("^[ \t]*([0-9.]+)[ \t]+([0-9.]+)[ \t]+([0-9.]+)[ \t]*$", inline)
m = re.match(r"^[ \t]*([0-9.]+)[ \t]+([0-9.]+)[ \t]+([0-9.]+)[ \t]*$", inline)
if not m:
print(f"{infname}: Invalid input file format")
inf.close()
Expand Down
2 changes: 1 addition & 1 deletion utils/g.html2man/g.html2man.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def main():
sf.close()

# strip excess whitespace
blank_re = re.compile("[ \t\n]*\n([ \t]*\n)*")
blank_re = re.compile(r"[ \t\n]*\n([ \t]*\n)*")
s = blank_re.sub("\n", s)
s = s.lstrip()

Expand Down
2 changes: 1 addition & 1 deletion utils/g.html2man/ggroff.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def __init__(self, filename, stream=sys.stdout):
"index": [],
}
self.stack = []
self.strip_re = re.compile("^[ \t]+")
self.strip_re = re.compile(r"^[ \t]+")
self.filename = filename
self.at_bol = True

Expand Down
6 changes: 3 additions & 3 deletions utils/gitlog2changelog.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
# Match the author line and extract the part we want
# (Don't use startswith to allow Author override inside commit message.)
elif "Author:" in line:
authorList = re.split(": ", line, 1)
authorList = re.split(r": ", line, 1)
try:
author = authorList[1]
author = author[0 : len(author) - 1]
Expand All @@ -71,7 +71,7 @@

# Match the date line
elif line.startswith("Date:"):
dateList = re.split(": ", line, 1)
dateList = re.split(r": ", line, 1)
try:
date = dateList[1]
date = date[0 : len(date) - 1]
Expand Down Expand Up @@ -100,7 +100,7 @@
else:
message = message + " " + line.strip()
# If this line is hit all of the files have been stored for this commit
elif re.search("files? changed", line):
elif re.search(r"files? changed", line):
filesFound = True
continue
# Collect the files for this commit. FIXME: Still need to add +/- to files
Expand Down
18 changes: 9 additions & 9 deletions utils/mkhtml.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ def handle_data(self, data):

def escape_href(label):
# remove html tags
label = re.sub("<[^<]+?>", "", label)
label = re.sub(r"<[^<]+?>", "", label)
# fix &nbsp;
label = label.replace("&nbsp;", "")
# fix "
Expand Down Expand Up @@ -351,16 +351,16 @@ def update_toc(data):

# process header
src_data = read_file(src_file)
name = re.search("(<!-- meta page name:)(.*)(-->)", src_data, re.IGNORECASE)
name = re.search(r"(<!-- meta page name:)(.*)(-->)", src_data, re.IGNORECASE)
pgm_desc = "GRASS GIS Reference Manual"
if name:
pgm = name.group(2).strip().split("-", 1)[0].strip()
name_desc = re.search(
"(<!-- meta page name description:)(.*)(-->)", src_data, re.IGNORECASE
r"(<!-- meta page name description:)(.*)(-->)", src_data, re.IGNORECASE
)
if name_desc:
pgm_desc = name_desc.group(2).strip()
desc = re.search("(<!-- meta page description:)(.*)(-->)", src_data, re.IGNORECASE)
desc = re.search(r"(<!-- meta page description:)(.*)(-->)", src_data, re.IGNORECASE)
if desc:
pgm = desc.group(2).strip()
header_tmpl = string.Template(header_base + header_nopgm)
Expand All @@ -369,7 +369,7 @@ def update_toc(data):
else:
header_tmpl = string.Template(header_base + header_pgm_desc)

if not re.search("<html>", src_data, re.IGNORECASE):
if not re.search(r"<html>", src_data, re.IGNORECASE):
tmp_data = read_file(tmp_file)
"""
Adjusting keywords html pages paths if add-on html man page
Expand All @@ -395,15 +395,15 @@ def update_toc(data):
orig_keywords_paths.group(1),
",".join(new_keywords_paths),
)
if not re.search("<html>", tmp_data, re.IGNORECASE):
if not re.search(r"<html>", tmp_data, re.IGNORECASE):
sys.stdout.write(header_tmpl.substitute(PGM=pgm, PGM_DESC=pgm_desc))

if tmp_data:
header_logo_img_el = '<img src="grass_logo.png" alt="GRASS logo">'
for line in tmp_data.splitlines(True):
# The cleanup happens on Makefile level too.
if not re.search(
"</body>|</html>|</div> <!-- end container -->", line, re.IGNORECASE
r"</body>|</html>|</div> <!-- end container -->", line, re.IGNORECASE
):
if header_logo_img_el in line:
sys.stdout.write(line)
Expand All @@ -420,7 +420,7 @@ def update_toc(data):

# if </html> is found, suppose a complete html is provided.
# otherwise, generate module class reference:
if re.search("</html>", src_data, re.IGNORECASE):
if re.search(r"</html>", src_data, re.IGNORECASE):
sys.exit()

index_names = {
Expand Down Expand Up @@ -453,7 +453,7 @@ def to_title(name):
index_titles[key] = to_title(name)

# process footer
index = re.search("(<!-- meta page index:)(.*)(-->)", src_data, re.IGNORECASE)
index = re.search(r"(<!-- meta page index:)(.*)(-->)", src_data, re.IGNORECASE)
if index:
index_name = index.group(2).strip()
if "|" in index_name:
Expand Down
4 changes: 2 additions & 2 deletions utils/mkrest.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def read_file(name):

src_data = read_file(src_file)

title = re.search("(<!-- meta page description:)(.*)(-->)", src_data, re.IGNORECASE)
title = re.search(r"(<!-- meta page description:)(.*)(-->)", src_data, re.IGNORECASE)

if title:
title_name = title.group(2).strip()
Expand Down Expand Up @@ -108,7 +108,7 @@ def read_file(name):
"v": "vector",
}

index = re.search("(<!-- meta page index:)(.*)(-->)", src_data, re.IGNORECASE)
index = re.search(r"(<!-- meta page index:)(.*)(-->)", src_data, re.IGNORECASE)

if index:
index_name = index.group(2).strip()
Expand Down

0 comments on commit 480a06d

Please sign in to comment.