From 90f77ed3e72e33d7a5f15e0b826e8994fb1695b1 Mon Sep 17 00:00:00 2001 From: Jose De Freitas Date: Thu, 11 Feb 2021 18:24:13 -0500 Subject: [PATCH] Update linter --- .gitignore | 3 ++- linter/lint.py | 4 +++- linter/rules/content_about.py | 4 +++- linter/rules/featured_playlists.py | 4 +++- linter/rules/youtubers_names.py | 4 +++- 5 files changed, 14 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 600d2d3..4edd750 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -.vscode \ No newline at end of file +.vscode +__pycache__ \ No newline at end of file diff --git a/linter/lint.py b/linter/lint.py index 08f3070..3f7130a 100644 --- a/linter/lint.py +++ b/linter/lint.py @@ -1,5 +1,6 @@ from rules import (content_about, featured_playlists, youtubers_names) + def main(): """ Main function. Used specifically to call print results @@ -9,7 +10,7 @@ def main(): 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: @@ -20,5 +21,6 @@ def main(): 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])) + if __name__ == '__main__': main() diff --git a/linter/rules/content_about.py b/linter/rules/content_about.py index a1e6414..59f4f87 100644 --- a/linter/rules/content_about.py +++ b/linter/rules/content_about.py @@ -5,14 +5,16 @@ file_readme = here / './../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() diff --git a/linter/rules/featured_playlists.py b/linter/rules/featured_playlists.py index de4a192..49cf30c 100644 --- a/linter/rules/featured_playlists.py +++ b/linter/rules/featured_playlists.py @@ -5,15 +5,17 @@ file_readme = here / './../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() diff --git a/linter/rules/youtubers_names.py b/linter/rules/youtubers_names.py index cbe7450..9330373 100644 --- a/linter/rules/youtubers_names.py +++ b/linter/rules/youtubers_names.py @@ -5,14 +5,16 @@ file_readme = here / './../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()