mirror of
https://github.com/cp2k/cp2k.git
synced 2026-07-28 14:15:19 -04:00
Fix Python 3.12 warnings
This commit is contained in:
parent
ecebeaa6cb
commit
f8667229bc
3 changed files with 13 additions and 13 deletions
|
|
@ -28,7 +28,7 @@ def main() -> None:
|
|||
# ======================================================================================
|
||||
def build_bibliography(references_html_fn: str, output_dir: Path) -> None:
|
||||
content = Path(references_html_fn).read_text()
|
||||
entries = re.findall("<TR>.*?</TR>", content, re.DOTALL)
|
||||
entries = re.findall(r"<TR>.*?</TR>", content, re.DOTALL)
|
||||
|
||||
output = []
|
||||
output += ["%", "% This file was created by generate_input_reference.py", "%"]
|
||||
|
|
@ -36,22 +36,22 @@ def build_bibliography(references_html_fn: str, output_dir: Path) -> None:
|
|||
|
||||
for entry in entries:
|
||||
pattern = (
|
||||
'<TR><TD>\[(.*?)\]</TD><TD>\n <A NAME="reference_\d+">(.*?)</A><br>'
|
||||
"(.*?)</TD></TR>"
|
||||
r'<TR><TD>\[(.*?)\]</TD><TD>\n <A NAME="reference_\d+">(.*?)</A><br>'
|
||||
r"(.*?)</TD></TR>"
|
||||
)
|
||||
parts = re.search(pattern, entry, re.DOTALL)
|
||||
assert parts
|
||||
key = parts.group(1)
|
||||
title = parts.group(3).strip()
|
||||
if "<br>" in parts.group(2):
|
||||
m = re.match("(.*?)<br>(.*)", parts.group(2), re.DOTALL)
|
||||
m = re.match(r"(.*?)<br>(.*)", parts.group(2), re.DOTALL)
|
||||
assert m
|
||||
authors, mix = m.groups()
|
||||
else:
|
||||
authors, mix = "", parts.group(2)
|
||||
|
||||
if "https://doi.org" in mix:
|
||||
m = re.match('\s*<A HREF="(.*?)">(.*?)</A>', mix, re.DOTALL)
|
||||
m = re.match(r'\s*<A HREF="(.*?)">(.*?)</A>', mix, re.DOTALL)
|
||||
assert m
|
||||
doi, ref = m.groups()
|
||||
else:
|
||||
|
|
@ -367,13 +367,13 @@ def sanitize_name(name: str) -> str:
|
|||
# ======================================================================================
|
||||
def escape_markdown(text: str) -> str:
|
||||
# Code blocks without a language get mistaken for the end of the py:data directive.
|
||||
text = text.replace("\n\n```\n", "\n\n```none\n")
|
||||
text = text.replace(r"\n\n```\n", r"\n\n```none\n")
|
||||
|
||||
# Underscores are very common in our docs. Luckily asterisks also work for emphasis.
|
||||
text = text.replace("__", "\_\_")
|
||||
text = text.replace(r"__", r"\_\_")
|
||||
|
||||
# Headings mess up the page structure. Please use paragraphs and bold text instead.
|
||||
text = text.replace("#", "\#")
|
||||
text = text.replace(r"#", r"\#")
|
||||
|
||||
return text
|
||||
|
||||
|
|
|
|||
|
|
@ -371,8 +371,8 @@ def install_cp2k(
|
|||
if revision:
|
||||
input_lines.append("ARG GIT_COMMIT_SHA")
|
||||
run_lines.append(
|
||||
'if [ -n "${GIT_COMMIT_SHA}" ] ; then'
|
||||
' echo "git:\${GIT_COMMIT_SHA::7}" > REVISION; fi'
|
||||
r'if [ -n "${GIT_COMMIT_SHA}" ] ; then'
|
||||
r' echo "git:\${GIT_COMMIT_SHA::7}" > REVISION; fi'
|
||||
)
|
||||
|
||||
input_lines.append("COPY ./Makefile .")
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import os
|
|||
import pathlib
|
||||
import re
|
||||
import sys
|
||||
from datetime import datetime
|
||||
from datetime import datetime, timezone
|
||||
from functools import lru_cache
|
||||
import itertools
|
||||
from typing import Tuple, List, TypeVar
|
||||
|
|
@ -77,7 +77,7 @@ FLAG_EXCEPTIONS = (
|
|||
FLAG_EXCEPTIONS_RE = re.compile(r"|".join(FLAG_EXCEPTIONS))
|
||||
PORTABLE_FILENAME_RE = re.compile(r"^[a-zA-Z0-9._/#~=+-]*$")
|
||||
OP_RE = re.compile(r"[\\|()!&><=*/+-]")
|
||||
NUM_RE = re.compile("[0-9]+[ulUL]*")
|
||||
NUM_RE = re.compile(r"[0-9]+[ulUL]*")
|
||||
CP2K_FLAGS_RE = re.compile(
|
||||
r"FUNCTION cp2k_flags\(\)(.*)END FUNCTION cp2k_flags", re.DOTALL
|
||||
)
|
||||
|
|
@ -183,7 +183,7 @@ def check_file(path: pathlib.Path) -> List[str]:
|
|||
warnings += [f"{path}:{i+1} Double space in multi-line string"]
|
||||
|
||||
# check banner
|
||||
year = datetime.utcnow().year
|
||||
year = datetime.now(timezone.utc).year
|
||||
bsd_licensed = any(str(path).startswith(d) for d in BSD_DIRECTORIES)
|
||||
spdx = "BSD-3-Clause " if bsd_licensed else "GPL-2.0-or-later"
|
||||
if fn_ext == ".F" and not content.startswith(BANNER_F.format(year, spdx)):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue