2021-02-06 20:26:52 +00:00
|
|
|
import pathlib
|
|
|
|
|
|
|
|
here = pathlib.Path(__file__).parent
|
2021-02-28 00:57:10 +00:00
|
|
|
file_readme = here / '../../readme.md'
|
2021-02-06 19:48:34 +00:00
|
|
|
with open(file_readme, 'r') as read_readme:
|
2021-02-24 17:19:43 +00:00
|
|
|
content = read_readme.readlines()
|
2021-02-06 19:48:34 +00:00
|
|
|
|
2021-02-28 00:53:56 +00:00
|
|
|
CHECKER = "Content about:"
|
2021-02-11 23:24:13 +00:00
|
|
|
|
2021-02-28 00:53:56 +00:00
|
|
|
|
|
|
|
def trailing_slash() -> str:
|
2021-02-19 00:15:27 +00:00
|
|
|
"""
|
2021-02-28 00:53:56 +00:00
|
|
|
Looks for backslash and the end of all the matching
|
|
|
|
lines ("Content about:" lines).
|
2021-02-19 16:04:53 +00:00
|
|
|
"""
|
2021-02-19 00:15:27 +00:00
|
|
|
|
2021-02-28 00:53:56 +00:00
|
|
|
result = ["🟢 0: perfect."]
|
2021-02-19 22:50:57 +00:00
|
|
|
|
2021-02-28 00:53:56 +00:00
|
|
|
for line, value in enumerate(content):
|
|
|
|
if CHECKER in value:
|
|
|
|
last = value[-2]
|
|
|
|
if last != "\\":
|
|
|
|
if last == " ":
|
|
|
|
content[line] = f"{value[:-1]}\\\n"
|
|
|
|
else:
|
|
|
|
content[line] = f"{value[:-1]} \\\n"
|
2021-02-19 16:04:53 +00:00
|
|
|
|
2021-02-28 00:53:56 +00:00
|
|
|
with open(file_readme, 'w') as write_readme:
|
|
|
|
write_readme.writelines(content)
|
2021-02-06 19:48:34 +00:00
|
|
|
|
2021-02-28 00:53:56 +00:00
|
|
|
result.append(f"🔴 {line}: backslash. Fixed.")
|
2021-02-11 23:24:13 +00:00
|
|
|
|
2021-02-28 00:53:56 +00:00
|
|
|
if len(result) > 1:
|
|
|
|
return '\n'.join(result[1:])
|
|
|
|
else:
|
|
|
|
return ''.join(result)
|