fix: annotations
parent
b2924fbd04
commit
b15b2f340a
|
@ -17,7 +17,7 @@ on:
|
||||||
- 'none'
|
- 'none'
|
||||||
- 'dangerous'
|
- 'dangerous'
|
||||||
- 'strict'
|
- 'strict'
|
||||||
- 'paranoid'
|
# - 'paranoid'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
|
|
|
@ -4,11 +4,14 @@
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
|
||||||
|
|
||||||
script_dir = os.path.dirname(__file__)
|
script_dir = os.path.dirname(__file__)
|
||||||
PATCHES_DIR = os.path.join(script_dir, "..", "patches")
|
PATCHES_DIR = os.path.join(script_dir, "..", "patches")
|
||||||
|
|
||||||
SNIPPET_FILES_TO_UPDATE = [
|
SNIPPET_FILES_TO_UPDATE = [
|
||||||
|
]
|
||||||
|
|
||||||
|
NEW_TARGET_FILENAMES = [
|
||||||
]
|
]
|
||||||
|
|
||||||
NEW_METHOD_SIGNATURES = [
|
NEW_METHOD_SIGNATURES = [
|
||||||
|
@ -20,35 +23,31 @@ def update_snippets():
|
||||||
print("[E] The snippet/signature lists in the script are empty. Please fill them out.")
|
print("[E] The snippet/signature lists in the script are empty. Please fill them out.")
|
||||||
return
|
return
|
||||||
|
|
||||||
if len(SNIPPET_FILES_TO_UPDATE) != len(NEW_METHOD_SIGNATURES):
|
if not (len(SNIPPET_FILES_TO_UPDATE) == len(NEW_METHOD_SIGNATURES) == len(NEW_TARGET_FILENAMES)):
|
||||||
print("[E] Error: The number of snippet files does not match the number of new signatures.")
|
print("[E] Error: The number of items in the three lists do not match.")
|
||||||
print(f" Files: {len(SNIPPET_FILES_TO_UPDATE)}, Signatures: {len(NEW_METHOD_SIGNATURES)}")
|
print(f" Files: {len(SNIPPET_FILES_TO_UPDATE)}, Filenames: {len(NEW_TARGET_FILENAMES)}, Signatures: {len(NEW_METHOD_SIGNATURES)}")
|
||||||
return
|
return
|
||||||
|
|
||||||
print(f"[I] Starting update for {len(SNIPPET_FILES_TO_UPDATE)} snippet files...")
|
print(f"[I] Starting update for {len(SNIPPET_FILES_TO_UPDATE)} snippet files...")
|
||||||
|
|
||||||
for snippet_name, new_signature in zip(SNIPPET_FILES_TO_UPDATE, NEW_METHOD_SIGNATURES):
|
for snippet_name, new_filename, new_signature in zip(SNIPPET_FILES_TO_UPDATE, NEW_TARGET_FILENAMES, NEW_METHOD_SIGNATURES):
|
||||||
print(f" -> Processing: {snippet_name}")
|
print(f" -> Processing: {snippet_name}")
|
||||||
|
|
||||||
original_path = os.path.join(PATCHES_DIR, "original", snippet_name)
|
original_path = os.path.join(PATCHES_DIR, "original", snippet_name)
|
||||||
patched_path = os.path.join(PATCHES_DIR, "patched", snippet_name)
|
patched_path = os.path.join(PATCHES_DIR, "patched", snippet_name)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with open(original_path, 'r', encoding='utf-8') as f:
|
new_original_content = ""
|
||||||
original_content = f.read()
|
if new_filename:
|
||||||
|
new_original_content = f'@FileName("{new_filename}")\n'
|
||||||
annotation_line = ""
|
new_original_content += new_signature
|
||||||
if original_content.strip().startswith('@FileName'):
|
|
||||||
annotation_line = original_content.splitlines()[0] + "\n"
|
|
||||||
|
|
||||||
new_original_content = f"{annotation_line}{new_signature}"
|
|
||||||
|
|
||||||
with open(original_path, 'w', encoding='utf-8') as f:
|
with open(original_path, 'w', encoding='utf-8') as f:
|
||||||
f.write(new_original_content)
|
f.write(new_original_content)
|
||||||
print(f" - Updated original signature in: {original_path}")
|
print(f" - Updated original snippet: {original_path}")
|
||||||
|
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
print(f" [W] Original snippet not found: {original_path}")
|
print(f" [W] Original snippet not found, skipping: {original_path}")
|
||||||
continue
|
continue
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -65,10 +64,10 @@ def update_snippets():
|
||||||
|
|
||||||
with open(patched_path, 'w', encoding='utf-8') as f:
|
with open(patched_path, 'w', encoding='utf-8') as f:
|
||||||
f.write(new_patched_content)
|
f.write(new_patched_content)
|
||||||
print(f" - Updated patched signature in: {patched_path}")
|
print(f" - Updated patched snippet: {patched_path}")
|
||||||
|
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
print(f" [W] Patched snippet not found: {patched_path}")
|
print(f" [W] Patched snippet not found, skipping: {patched_path}")
|
||||||
|
|
||||||
print("\n[I] Snippet update process complete.")
|
print("\n[I] Snippet update process complete.")
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue