2021-02-06 15:29:26 -05:00
|
|
|
import pathlib
|
|
|
|
|
|
|
|
here = pathlib.Path(__file__).parent
|
2021-02-27 19:57:10 -05:00
|
|
|
file_readme = here / '../../readme.md'
|
2021-02-06 14:48:34 -05:00
|
|
|
with open(file_readme, 'r') as read_readme:
|
2021-02-24 12:19:43 -05:00
|
|
|
content = read_readme.readlines()
|
2021-02-06 14:48:34 -05:00
|
|
|
|
2021-02-27 19:53:56 -05:00
|
|
|
CHECKER = "Featured playlists:"
|
|
|
|
LENGTH = 124
|
2021-02-11 18:24:13 -05:00
|
|
|
|
|
|
|
|
2021-02-27 19:53:56 -05:00
|
|
|
def trailing_slash() -> str:
|
|
|
|
"""
|
|
|
|
Looks for backslash and the end of all the matching
|
|
|
|
lines ("Featured playlists:" lines) and a line
|
|
|
|
break tag "<br>" at the next line.
|
2021-02-19 17:50:57 -05:00
|
|
|
"""
|
2021-02-06 14:48:34 -05:00
|
|
|
|
2021-02-27 19:53:56 -05:00
|
|
|
result = ["🟢 0: perfect."]
|
2021-02-24 12:19:43 -05:00
|
|
|
|
2021-02-27 19:53:56 -05:00
|
|
|
for line, value in enumerate(content):
|
|
|
|
if CHECKER in value:
|
|
|
|
last = value[-2]
|
|
|
|
if len(value) < LENGTH:
|
|
|
|
if last != "\\" and "<br>" not in content[line+1]:
|
|
|
|
if last == " ":
|
|
|
|
content[line] = f"{value[:-1]}\\\n<br>\n"
|
|
|
|
else:
|
|
|
|
content[line] = f"{value[:-1]} \\\n<br>\n"
|
2021-02-24 12:19:43 -05:00
|
|
|
|
2021-02-27 19:53:56 -05:00
|
|
|
with open(file_readme, 'w') as write_readme:
|
|
|
|
write_readme.writelines(content)
|
2021-02-24 12:19:43 -05:00
|
|
|
|
2021-02-27 19:53:56 -05:00
|
|
|
result.append(f"🔴 {line}: backslash | line break. Fixed.")
|
|
|
|
elif last != "\\" and "<br>" in content[line+1]:
|
|
|
|
if last == " ":
|
|
|
|
content[line] = f"{value[:-1]}\\\n"
|
|
|
|
else:
|
|
|
|
content[line] = f"{value[:-1]} \\\n"
|
2021-02-24 12:19:43 -05:00
|
|
|
|
2021-02-27 19:53:56 -05:00
|
|
|
with open(file_readme, 'w') as write_readme:
|
|
|
|
write_readme.writelines(content)
|
2021-02-24 12:19:43 -05:00
|
|
|
|
2021-02-27 19:53:56 -05:00
|
|
|
result.append(f"🔴 {line}: backslash. Fixed.")
|
|
|
|
elif last == "\\" and "<br>" not in content[line+1]:
|
|
|
|
content[line+1] = "<br>\n\n"
|
2021-02-24 12:19:43 -05:00
|
|
|
|
2021-02-27 19:53:56 -05:00
|
|
|
with open(file_readme, 'w') as write_readme:
|
|
|
|
write_readme.writelines(content)
|
2021-02-24 12:19:43 -05:00
|
|
|
|
2021-02-27 19:53:56 -05:00
|
|
|
result.append(f"🔴 {line}: line break. Fixed.")
|
2021-02-24 12:19:43 -05:00
|
|
|
|
2021-02-27 19:53:56 -05:00
|
|
|
if len(result) > 1:
|
|
|
|
return '\n'.join(result[1:])
|
|
|
|
else:
|
|
|
|
return ''.join(result)
|