awesome-youtubers/linter/rules/content_about.py

35 lines
1.1 KiB
Python
Raw Normal View History

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).
"""
content_about_result = 'No errors found.'
# content_about_errors = {}
2021-02-06 14:48:34 -05:00
content_about_line = 'Content about:'
2021-02-11 18:24:13 -05:00
2021-02-06 14:48:34 -05:00
for j, i in enumerate(content_readme):
if content_about_line in i:
2021-02-18 19:15:27 -05:00
# content_about_words = i[len(content_about_line):-2]
2021-02-06 14:48:34 -05:00
if i[-2] != '\\':
2021-02-18 19:15:27 -05:00
content_readme[j] = i.replace('&', '\\')
with open(file_readme, 'w') as write_readme:
write_readme.writelines(content_readme)
content_about_result = "Found errors. Fixed them."
# content_about_errors.append(j)
return content_about_result
# return content_about_errors
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())