2021-02-06 15:30:17 -05:00
|
|
|
import pathlib
|
|
|
|
|
|
|
|
here = pathlib.Path(__file__).parent
|
2021-02-19 17:50:57 -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 youtubers_names():
|
2021-02-19 17:50:57 -05:00
|
|
|
"""
|
|
|
|
Looks for trailing slashes and words separated by commas at
|
|
|
|
every YouTuber's name line found in the readme.md file
|
|
|
|
(this is, the list itself).
|
2021-02-11 18:24:13 -05:00
|
|
|
|
2021-02-19 17:50:57 -05:00
|
|
|
result (str): return value of the function.
|
|
|
|
checker (str): detector of the line corresponding the file.
|
|
|
|
"""
|
2021-02-06 14:48:34 -05:00
|
|
|
|
2021-02-19 17:50:57 -05:00
|
|
|
result = 'No errors found.'
|
|
|
|
checker = '[**'
|
2021-02-11 18:24:13 -05:00
|
|
|
|
2021-02-19 17:50:57 -05:00
|
|
|
for line, value in enumerate(content_readme):
|
|
|
|
if checker in value:
|
|
|
|
# Check for trailing slash
|
|
|
|
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."
|
|
|
|
|
|
|
|
return result
|
|
|
|
|
|
|
|
|
|
|
|
print(youtubers_names())
|