Fix asort script to sort last terms in braces

- Fix README bad new line
- Do same fix for es-ES and zh-CN
- Apply sort on README.md, README_es.md and README_zh
  - Don't run with pt_BR
This commit is contained in:
Maxence Germain de Montauzan
2018-04-19 17:51:04 +02:00
committed by Luong Vo
parent ecd6d915e5
commit 8a0147ae4e
6 changed files with 177 additions and 170 deletions

View File

@ -11,6 +11,7 @@
from __future__ import print_function
import os
import shutil
import re
README_FILE = '../README.md'
@ -20,6 +21,7 @@ TEMP_FILE = 'temp.md'
BEGIN = '## Applications'
END = '## Setup'
regex = re.compile(r"[^[]*\[([^]]*)\]")
def main():
global README_FILE
@ -47,23 +49,23 @@ def main():
# sort_enable = False
if sort_enable:
line = line.strip()
# each item starts with a character '-' (maybe '*' and '+')
if line.startswith(('-', '*', '+')):
# each item starts with a character '-'
if line.startswith(('-')):
line = line.strip()
items.append(line)
elif line.startswith('#'):
sort_enable = False if END in line else True
# When no more items, blank line or new header
elif line is '\n':
# when we meet the next header, we should stop adding new item to the list.
for item in sorted(items, key=lambda x: x.upper()):
for item in sorted(items, key=lambda x: regex.findall(x.upper())[len(regex.findall(x.upper()))-1]):
# write the ordered list to the temporary file.
print(item, file=outfile)
print('', file=outfile)
items.clear()
# remember to put the next header in the temporary file.
print(line, file=outfile)
print(line, end='', file=outfile)
elif line.startswith('#'):
sort_enable = False if END in line else True
print(line, end='', file=outfile)
else:
print(line, end='', file=outfile)
else:

View File

@ -11,6 +11,7 @@
from __future__ import print_function
import os
import shutil
import re
README_FILE = '../README_es-ES.md'
@ -20,6 +21,7 @@ TEMP_FILE = 'temp_es-ES.md'
BEGIN = '## Aplicaciones'
END = '## Configurar'
regex = re.compile(r"[^[]*\[([^]]*)\]")
def main():
global README_FILE
@ -47,23 +49,23 @@ def main():
# sort_enable = False
if sort_enable:
line = line.strip()
# each item starts with a character '-' (maybe '*' and '+')
if line.startswith(('-', '*', '+')):
# each item starts with a character '-'
if line.startswith(('-')):
line = line.strip()
items.append(line)
elif line.startswith('#'):
sort_enable = False if END in line else True
# When no more items, blank line or new header
elif line is '\n':
# when we meet the next header, we should stop adding new item to the list.
for item in sorted(items, key=lambda x: x.upper()):
for item in sorted(items, key=lambda x: regex.findall(x.upper())[len(regex.findall(x.upper()))-1]):
# write the ordered list to the temporary file.
print(item, file=outfile)
print('', file=outfile)
items.clear()
# remember to put the next header in the temporary file.
print(line, file=outfile)
print(line, end='', file=outfile)
elif line.startswith('#'):
sort_enable = False if END in line else True
print(line, end='', file=outfile)
else:
print(line, end='', file=outfile)
else:
@ -75,3 +77,4 @@ def main():
if __name__ == '__main__':
main()

View File

@ -11,6 +11,7 @@
from __future__ import print_function
import os
import shutil
import re
README_FILE = '../README_zh-CN.md'
@ -20,6 +21,7 @@ TEMP_FILE = 'temp_zh.md'
BEGIN = '## 应用'
END = '## 设置'
regex = re.compile(r"[^[]*\[([^]]*)\]")
def main():
global README_FILE
@ -47,23 +49,23 @@ def main():
# sort_enable = False
if sort_enable:
line = line.strip()
# each item starts with a character '-' (maybe '*' and '+')
if line.startswith(('-', '*', '+')):
# each item starts with a character '-'
if line.startswith(('-')):
line = line.strip()
items.append(line)
elif line.startswith('#'):
sort_enable = False if END in line else True
# When no more items, blank line or new header
elif line is '\n':
# when we meet the next header, we should stop adding new item to the list.
for item in sorted(items, key=lambda x: x.upper()):
for item in sorted(items, key=lambda x: regex.findall(x.upper())[len(regex.findall(x.upper()))-1]):
# write the ordered list to the temporary file.
print(item, file=outfile)
print('', file=outfile)
items.clear()
# remember to put the next header in the temporary file.
print(line, file=outfile)
print(line, end='', file=outfile)
elif line.startswith('#'):
sort_enable = False if END in line else True
print(line, end='', file=outfile)
else:
print(line, end='', file=outfile)
else: