mirror of
https://github.com/JoseDeFreitas/awesome-youtubers.git
synced 2024-12-22 13:55:08 -05:00
commit
db5b3e4fe3
28
linter/lint.py
Normal file
28
linter/lint.py
Normal file
@ -0,0 +1,28 @@
|
||||
from rules import (content_about, featured_playlists, youtubers_names)
|
||||
|
||||
file_readme = './../readme.md'
|
||||
with open(file_readme, 'r') as read_readme:
|
||||
content_readme = read_readme.readlines()
|
||||
|
||||
def main():
|
||||
"""
|
||||
Main function. Used specifically to call print results
|
||||
by calling functions into rules/.
|
||||
"""
|
||||
if len(youtubers_names.youtubers_name_errors_nums) == 0:
|
||||
print("Every YouTubers names are good.", "\n")
|
||||
else:
|
||||
print("'YouTubers name' errors:\n", '\n'.join(["Error at line {}: there should be a trailing '\\'.".format(i) for i in youtubers_names.youtubers_name_errors_nums]), "\n")
|
||||
|
||||
if len(content_about.content_about_errors_nums) == 0:
|
||||
print("Every 'Content about' sections are good.", "\n")
|
||||
else:
|
||||
print("'Content about' errors:\n", '\n'.join(["Error at line {}: there should be a trailing '\\'.".format(i) for i in content_about.content_about_errors_nums]), "\n")
|
||||
|
||||
if len(featured_playlists.featured_playlists_errors_nums) == 0:
|
||||
print("Every 'Featured playlists' sections are good.", "\n")
|
||||
else:
|
||||
print("'Featured playlists' errors:\n", '\n'.join(["Error at line {}: there should be a trailing '\\'.".format(i) for i in featured_playlists.featured_playlists_errors_nums]), "\n")
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
17
linter/readme.md
Normal file
17
linter/readme.md
Normal file
@ -0,0 +1,17 @@
|
||||
# Awesome YouTubers linter
|
||||
|
||||
The awesome-youtubers linter is a workflow that checks the layout of the pull requests opened. This helps the contributors show if
|
||||
something in the layout is not formatted correctly so it can be fixed. This linter was created in order to keep the format of the
|
||||
list without breaking the layouts (images, new lines, etc.)
|
||||
|
||||
## Rules
|
||||
|
||||
The rules that the linter follows are:
|
||||
|
||||
- Trailing `\` at the end of the name and link of the YouTuber.
|
||||
- Trailing `\` at the end of the "Content about" section.
|
||||
- Trailing `\` at the end of the "Featured playlists" section.
|
||||
- Spaces between badges.
|
||||
- Spaces between "Content about" words (including `,`).
|
||||
- Spaces between "Featured playlists" words (including `,`).
|
||||
- Links formatted correctly in the markdown syntax (`[text](link)`)
|
15
linter/rules/content_about.py
Normal file
15
linter/rules/content_about.py
Normal file
@ -0,0 +1,15 @@
|
||||
file_readme = './../readme.md'
|
||||
with open(file_readme, 'r') as read_readme:
|
||||
content_readme = read_readme.readlines()
|
||||
|
||||
def content_about():
|
||||
content_about_errors_nums = []
|
||||
content_about_line = 'Content about:'
|
||||
|
||||
for j, i in enumerate(content_readme):
|
||||
if content_about_line in i:
|
||||
if i[-2] != '\\':
|
||||
content_about_errors_nums.append(j)
|
||||
return content_about_errors_nums
|
||||
|
||||
content_about_errors_nums = content_about()
|
16
linter/rules/featured_playlists.py
Normal file
16
linter/rules/featured_playlists.py
Normal file
@ -0,0 +1,16 @@
|
||||
file_readme = './../readme.md'
|
||||
with open(file_readme, 'r') as read_readme:
|
||||
content_readme = read_readme.readlines()
|
||||
|
||||
def featured_playlists():
|
||||
featured_playlists_errors_nums = []
|
||||
featured_playlists_line = 'Featured playlists:'
|
||||
featured_playlists_dlen = 124
|
||||
|
||||
for j, i in enumerate(content_readme):
|
||||
if featured_playlists_line in i:
|
||||
if len(i) < featured_playlists_dlen and i[-2] != '\\':
|
||||
featured_playlists_errors_nums.append(j)
|
||||
return featured_playlists_errors_nums
|
||||
|
||||
featured_playlists_errors_nums = featured_playlists()
|
15
linter/rules/youtubers_names.py
Normal file
15
linter/rules/youtubers_names.py
Normal file
@ -0,0 +1,15 @@
|
||||
file_readme = './../readme.md'
|
||||
with open(file_readme, 'r') as read_readme:
|
||||
content_readme = read_readme.readlines()
|
||||
|
||||
def youtubers_names():
|
||||
youtubers_name_errors_nums = []
|
||||
youtuber_count_char = '[**'
|
||||
|
||||
for j, i in enumerate(content_readme):
|
||||
if youtuber_count_char in i:
|
||||
if i[-2] != '\\':
|
||||
youtubers_name_errors_nums.append(j)
|
||||
return youtubers_name_errors_nums
|
||||
|
||||
youtubers_name_errors_nums = youtubers_names()
|
Loading…
Reference in New Issue
Block a user