🧑‍💻 Py scripts refinements

This commit is contained in:
Scott Lahteine
2025-10-07 02:26:49 -05:00
parent 0937fe55a4
commit 35da223f0a
8 changed files with 25 additions and 23 deletions
+4 -2
View File
@@ -51,7 +51,8 @@ def format_text(argv):
return
# Open and read the file src_file
with open(src_file, 'r', encoding='utf-8') as rf: file_text = rf.read()
with open(src_file, 'r', encoding='utf-8') as rf:
file_text = rf.read()
if len(file_text) == 0:
print('No text to process')
@@ -60,7 +61,8 @@ def format_text(argv):
# Read from file or STDIN until it terminates
filtered = re.sub(r'\s+$', '', file_text) + '\n'
if dst_file:
with open(dst_file, 'w', encoding='utf-8') as wf: wf.write(filtered)
with open(dst_file, 'w', encoding='utf-8', newline='') as wf:
wf.write(filtered)
else:
print(filtered)