2021-02-06 15:26:52 -05:00
|
|
|
import pathlib
|
|
|
|
|
|
|
|
here = pathlib.Path(__file__).parent
|
2021-02-18 19:15:27 -05:00
|
|
|
file_readme = here / '../../test.md'
|
2021-02-06 14:48:34 -05:00
|
|
|
with open(file_readme, 'r') as read_readme:
|
|
|
|
content_readme = read_readme.readlines()
|
|
|
|
|
2021-02-11 18:24:13 -05:00
|
|
|
|
2021-02-06 14:48:34 -05:00
|
|
|
def content_about():
|
2021-02-18 19:15:27 -05:00
|
|
|
"""
|
|
|
|
Looks for trailing slashes and words separated by commas at
|
|
|
|
every "Content about:" section found in the readme.md file
|
|
|
|
(this is, the list itself).
|
2021-02-11 18:24:13 -05:00
|
|
|
|
2021-02-19 11:04:53 -05:00
|
|
|
result (str): return value of the function.
|
|
|
|
checker (str): detector of the line corresponding the file.
|
|
|
|
"""
|
2021-02-18 19:15:27 -05:00
|
|
|
|
2021-02-19 11:04:53 -05:00
|
|
|
result = 'No errors found.'
|
|
|
|
checker = 'Content about:'
|
|
|
|
|
|
|
|
for line, value in enumerate(content_readme):
|
|
|
|
if checker in value:
|
|
|
|
# Check for trailing slash
|
2021-02-19 17:50:57 -05:00
|
|
|
if value[-2] != '\\':
|
|
|
|
if value[-2] == ' ':
|
|
|
|
content_readme[line] = value[:-1] + '\\' + '\n'
|
|
|
|
with open(file_readme, 'w') as write_readme:
|
|
|
|
write_readme.writelines(content_readme)
|
|
|
|
else:
|
|
|
|
content_readme[line] = value[:-1] + ' \\' + '\n'
|
|
|
|
with open(file_readme, 'w') as write_readme:
|
|
|
|
write_readme.writelines(content_readme)
|
|
|
|
|
|
|
|
result = "Trailing slash wasn't found.\nFixed."
|
2021-02-19 11:04:53 -05:00
|
|
|
|
|
|
|
return result
|
2021-02-06 14:48:34 -05:00
|
|
|
|
2021-02-11 18:24:13 -05:00
|
|
|
|
2021-02-18 19:15:27 -05:00
|
|
|
print(content_about())
|