Skip to content

Commit 6449879

Browse files
committed
Remove f-string in logging
1 parent c22b8ea commit 6449879

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

scripts/html_chunking/chunker.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,14 @@ def chunk_html(
6565
if count_html_tokens(html_content, options.count_tag_tokens) <= options.max_token_limit:
6666
return [Chunk(text=html_content, metadata={"source": source_url})]
6767
except Exception as e:
68-
warnings.warn(f"Could not pre-calculate total tokens: {e}. Proceeding with chunking.")
68+
warnings.warn("Could not pre-calculate total tokens: %s. Proceeding with chunking." % e)
6969

7070
try:
7171
soup = BeautifulSoup(html_content, 'html.parser')
7272
body = soup.body or soup
7373
string_chunks = _split_element_by_children(body, options)
7474
except Exception as e:
75-
warnings.warn(f"A critical error occurred during semantic chunking: {e}. Falling back to linear splitting.")
75+
warnings.warn("A critical error occurred during semantic chunking: %s. Falling back to linear splitting." % e)
7676
string_chunks = _linear_split(html_content, options)
7777

7878
# Post-process string chunks to add stateful anchor metadata

scripts/html_chunking/example.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,14 +91,14 @@ def main():
9191
print("HTML Chunking Example\n====================\n")
9292

9393
if not os.path.exists(args.html_file):
94-
print(f"Error: Sample document '{args.html_file}' not found.", file=sys.stderr)
94+
print("Error: Sample document '%s' not found." % args.html_file, file=sys.stderr)
9595
return 1
9696

9797
try:
9898
with open(args.html_file, "r", encoding="utf-8") as f:
9999
sample_html = f.read()
100100
except IOError as e:
101-
print(f"Error reading HTML file '{args.html_file}': {e}", file=sys.stderr)
101+
print("Error reading HTML file '%s': %s" % (args.html_file, e), file=sys.stderr)
102102
return 1
103103

104104
original_tokens = count_html_tokens(sample_html)
@@ -131,12 +131,12 @@ def main():
131131
try:
132132
sys.exit(main())
133133
except ImportError as e:
134-
print(f"Error: Failed to import a required module.", file=sys.stderr)
135-
print(f"Detail: {e}", file=sys.stderr)
134+
print("Error: Failed to import a required module.", file=sys.stderr)
135+
print("Detail: %s" % e, file=sys.stderr)
136136
print("\nSuggestion: Try running this script from the project's root directory using 'python -m html_chunking.example'", file=sys.stderr)
137137
sys.exit(1)
138138
except Exception as e:
139-
print(f"An unexpected error occurred: {e}", file=sys.stderr)
139+
print("An unexpected error occurred: %s" % e, file=sys.stderr)
140140
import traceback
141141
traceback.print_exc()
142142
sys.exit(1)

0 commit comments

Comments
 (0)