Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Dec 11, 2024
1 parent ce0a6a5 commit 0f0fd79
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions scripts/sipify.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,11 @@ class MultiLineType(Enum):
parser = argparse.ArgumentParser(description="Convert header file to SIP and Python")
parser.add_argument("-debug", action="store_true", help="Enable debug mode")
parser.add_argument("-qt6", action="store_true", help="Enable Qt6 mode")
parser.add_argument("-generate_deprecated_message", action="store_true", help="Generate sip files with deprecated messages (supported only in SIP > 6.9.0)")
parser.add_argument(
"-generate_deprecated_message",
action="store_true",
help="Generate sip files with deprecated messages (supported only in SIP > 6.9.0)",
)
parser.add_argument("-sip_output", help="SIP output file")
parser.add_argument("-python_output", help="Python output file")
parser.add_argument("-class_map", help="Class map file")
Expand Down Expand Up @@ -891,7 +895,9 @@ def process_doxygen_line(line: str) -> str:
version = version[:-1]
depr_line = f"\n.. deprecated:: {version}"
message = deprecated_match.group("DEPR_MESSAGE")
CONTEXT.deprecated_message = f"Since {version}. {process_deprecated_message(message)}"
CONTEXT.deprecated_message = (
f"Since {version}. {process_deprecated_message(message)}"
)
if message:
depr_line += "\n"
depr_line += "\n".join(f"\n {_m}" for _m in message.split("\n"))
Expand Down Expand Up @@ -1172,7 +1178,9 @@ def fix_annotations(line):
if "SIP_DEPRECATED" in line:

if CONTEXT.deprecated_message is None:
exit_with_error(f"Error in file {CONTEXT.header_file}: missing deprecated message for SIP_DEPRECATED instruction on line {CONTEXT.line_idx}. Please add \\deprecated instruction")
exit_with_error(
f"Error in file {CONTEXT.header_file}: missing deprecated message for SIP_DEPRECATED instruction on line {CONTEXT.line_idx}. Please add \\deprecated instruction"
)

# Printed annotations
replacements = {
Expand Down Expand Up @@ -1208,7 +1216,9 @@ def fix_annotations(line):

if CONTEXT.generate_deprecated_message:
# check deprecated message is not empty
replacements[r"\bSIP_DEPRECATED\b"] = f'/Deprecated="{CONTEXT.deprecated_message}"/'
replacements[r"\bSIP_DEPRECATED\b"] = (
f'/Deprecated="{CONTEXT.deprecated_message}"/'
)
else:
replacements[r"\bSIP_DEPRECATED\b"] = f"/Deprecated/"

Expand All @@ -1218,9 +1228,8 @@ def fix_annotations(line):
# Combine multiple annotations
while True:
new_line = re.sub(
r'/([\w,]+(="?[^"]+"?)?)/\s*/([\w,]+(="?[^"]+"?)?]?)/',
r"/\1,\3/",
line)
r'/([\w,]+(="?[^"]+"?)?)/\s*/([\w,]+(="?[^"]+"?)?]?)/', r"/\1,\3/", line
)
if new_line == line:
break
line = new_line
Expand Down

0 comments on commit 0f0fd79

Please sign in to comment.