Enhance sorting functionality in asort.py (#772)

This commit is contained in:
KhwajaYousuf 2024-01-13 01:19:20 -05:00 committed by GitHub
parent e5b311dff3
commit 847365f7ee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -5,8 +5,8 @@
# GitHub: https://www.github.com/chrisleegit # GitHub: https://www.github.com/chrisleegit
# File: asort.py # File: asort.py
# Date: 2016/08/22 11:12 # Date: 2016/08/22 11:12
# Version: 0.1 # Version: 0.2
# Description: A very simple python script that can sort items alphabetically. # Description: A python script to sort items alphabetically.
import os import os
import shutil import shutil
@ -37,7 +37,7 @@ def main():
print(f'Cargando archivo: {README_FILE}') print(f'Cargando archivo: {README_FILE}')
# Read the file: README.md # Read the file: README.md
with (open(README_FILE, 'r') as infile, open(TEMP_FILE, 'w') as outfile): with open(README_FILE, 'r') as infile, open(TEMP_FILE, 'w') as outfile:
# Process each line # Process each line
for line in infile: for line in infile:
if not sort_enable and BEGIN in line: if not sort_enable and BEGIN in line:
@ -65,9 +65,9 @@ def main():
print(line, end='', file=outfile) print(line, end='', file=outfile)
else: else:
print(line, end='', file=outfile) print(line, end='', file=outfile)
print('Reemplazar el archivo original: README_es-ES.md') print('Reemplazar el archivo original: README_es-ES.md')
shutil.move(TEMP_FILE, README_FILE) shutil.move(TEMP_FILE, README_FILE)
if __name__ == '__main__': if __name__ == '__main__':
main() main()