🧑💻 Py scripts refinements
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user