mirror of
https://github.com/JoseDeFreitas/awesome-youtubers.git
synced 2025-01-03 11:30:49 -05:00
Format output
This commit is contained in:
parent
91e7f28ac1
commit
f2b67d98b8
@ -1,13 +1,33 @@
|
||||
# from rules.content_about import content_about
|
||||
# Last "as" keyword is in the form ab_cd, where "a" and
|
||||
# "b" are the first letters of the two words of the module
|
||||
# and "c" and "d" are the first letters of the two words
|
||||
# of the function of the module.
|
||||
|
||||
from rules.content_about import trailing_slash as ca_ts
|
||||
from rules.featured_playlists import trailing_slash as fp_ts
|
||||
from rules.youtubers_names import trailing_slash as yn_ts
|
||||
|
||||
|
||||
def main():
|
||||
def main() -> None:
|
||||
"""
|
||||
Main function. Used specifically to call print results
|
||||
by calling functions into rules/.
|
||||
|
||||
Functions:
|
||||
content_about: trailing_slash, comma_separated
|
||||
featured_playlists: trailing_slash, closed_backsticks
|
||||
youtubers_names: trailing_slash, youtube_link
|
||||
"""
|
||||
|
||||
pass
|
||||
# "youtubers_names"
|
||||
print("YouTubers names:")
|
||||
print(yn_ts())
|
||||
# "content_about"
|
||||
print("Content about:")
|
||||
print(ca_ts())
|
||||
# "featured_playlists"
|
||||
print("Featured playlists:")
|
||||
print(fp_ts())
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
@ -5,33 +5,19 @@ file_readme = here / '../../test.md'
|
||||
with open(file_readme, 'r') as read_readme:
|
||||
content = read_readme.readlines()
|
||||
|
||||
CHECKER = "Content about:"
|
||||
|
||||
class ContentAbout():
|
||||
"""
|
||||
Contains methods for the detection of various
|
||||
rules asigned to the "Content about:" sections.
|
||||
These methods edit the readme.md file (the awe-
|
||||
some list) in-place if any of the rules isn't
|
||||
met.
|
||||
|
||||
Attributes:
|
||||
checker (str): matches the "Content about:" string.
|
||||
result (str): result of the operation.
|
||||
"""
|
||||
|
||||
checker = "Content about:"
|
||||
|
||||
def __init__(self):
|
||||
self.result = "🟢 0: perfect."
|
||||
|
||||
def trailing_slash(self) -> str:
|
||||
def trailing_slash() -> str:
|
||||
"""
|
||||
Looks for backslash and the end of all the matching
|
||||
lines ("Content about:" lines).
|
||||
"""
|
||||
|
||||
result = ["🟢 0: perfect."]
|
||||
|
||||
for line, value in enumerate(content):
|
||||
if self.checker in value:
|
||||
if CHECKER in value:
|
||||
last = value[-2]
|
||||
if last != "\\":
|
||||
if last == " ":
|
||||
@ -42,22 +28,9 @@ class ContentAbout():
|
||||
with open(file_readme, 'w') as write_readme:
|
||||
write_readme.writelines(content)
|
||||
|
||||
self.result = f"🔴 {line}: backslash.\nFixed."
|
||||
result.append(f"🔴 {line}: backslash. Fixed.")
|
||||
|
||||
return self.result
|
||||
|
||||
def comma_separated(self) -> str:
|
||||
"""
|
||||
Looks through all words in the section to check
|
||||
if they're separated by a comma and a space
|
||||
", ".
|
||||
"""
|
||||
|
||||
# for line, value in enumerate(content):
|
||||
# if self.checker in value:
|
||||
|
||||
return self.result
|
||||
|
||||
|
||||
content_about = ContentAbout()
|
||||
print(content_about.trailing_slash())
|
||||
if len(result) > 1:
|
||||
return '\n'.join(result[1:])
|
||||
else:
|
||||
return ''.join(result)
|
||||
|
@ -5,38 +5,23 @@ file_readme = here / '../../test.md'
|
||||
with open(file_readme, 'r') as read_readme:
|
||||
content = read_readme.readlines()
|
||||
|
||||
CHECKER = "Featured playlists:"
|
||||
LENGTH = 124
|
||||
|
||||
class FeaturedPlaylists():
|
||||
"""
|
||||
Contains methods for the detection of various
|
||||
rules asigned to the "Featured playlists:" sections.
|
||||
These methods edit the readme.md file (the awe-
|
||||
some list) in-place if any of the rules isn't
|
||||
met.
|
||||
|
||||
Attributes:
|
||||
checker (str): matches the "Featured playlists:" string.
|
||||
length (int): minimum length of the line to break line.
|
||||
result (str): result of the operation.
|
||||
"""
|
||||
|
||||
checker = "Featured playlists:"
|
||||
length = 124
|
||||
|
||||
def __init__(self):
|
||||
self.result = "🟢 0: perfect."
|
||||
|
||||
def trailing_slash(self):
|
||||
def trailing_slash() -> str:
|
||||
"""
|
||||
Looks for backslash and the end of all the matching
|
||||
lines ("Featured playlists:" lines) and a line
|
||||
break tag "<br>" at the next line.
|
||||
"""
|
||||
|
||||
result = ["🟢 0: perfect."]
|
||||
|
||||
for line, value in enumerate(content):
|
||||
if self.checker in value:
|
||||
if CHECKER in value:
|
||||
last = value[-2]
|
||||
if len(value) < self.length:
|
||||
if len(value) < LENGTH:
|
||||
if last != "\\" and "<br>" not in content[line+1]:
|
||||
if last == " ":
|
||||
content[line] = f"{value[:-1]}\\\n<br>\n"
|
||||
@ -46,7 +31,7 @@ class FeaturedPlaylists():
|
||||
with open(file_readme, 'w') as write_readme:
|
||||
write_readme.writelines(content)
|
||||
|
||||
self.result = f"🔴 {line}: backslash | line break.\nFixed."
|
||||
result.append(f"🔴 {line}: backslash | line break. Fixed.")
|
||||
elif last != "\\" and "<br>" in content[line+1]:
|
||||
if last == " ":
|
||||
content[line] = f"{value[:-1]}\\\n"
|
||||
@ -56,25 +41,16 @@ class FeaturedPlaylists():
|
||||
with open(file_readme, 'w') as write_readme:
|
||||
write_readme.writelines(content)
|
||||
|
||||
self.result = f"🔴 {line}: backslash.\nFixed."
|
||||
result.append(f"🔴 {line}: backslash. Fixed.")
|
||||
elif last == "\\" and "<br>" not in content[line+1]:
|
||||
content[line+1] = "<br>\n\n"
|
||||
|
||||
with open(file_readme, 'w') as write_readme:
|
||||
write_readme.writelines(content)
|
||||
|
||||
self.result = f"🔴 {line}: line break.\nFixed."
|
||||
result.append(f"🔴 {line}: line break. Fixed.")
|
||||
|
||||
return self.result
|
||||
|
||||
def closed_backsticks(self):
|
||||
"""
|
||||
Looks that all backsticks of every word are co-
|
||||
rrectly opened and subsequent closed.
|
||||
"""
|
||||
|
||||
return self.result
|
||||
|
||||
|
||||
featured_playlists = FeaturedPlaylists()
|
||||
print(featured_playlists.trailing_slash())
|
||||
if len(result) > 1:
|
||||
return '\n'.join(result[1:])
|
||||
else:
|
||||
return ''.join(result)
|
||||
|
@ -5,34 +5,19 @@ file_readme = here / '../../test.md'
|
||||
with open(file_readme, 'r') as read_readme:
|
||||
content = read_readme.readlines()
|
||||
|
||||
CHECKER = "[**"
|
||||
|
||||
class YoutubersNames():
|
||||
"""
|
||||
Contains methods for the detection of various
|
||||
rules asigned to the YouTubers names lines.
|
||||
These methods edit the readme.md file (the awe-
|
||||
some list) in-place if any of the rules isn't
|
||||
met.
|
||||
|
||||
Attributes:
|
||||
checker (str): matches the YouTuber names
|
||||
"[**" string.
|
||||
result (str): result of the operation.
|
||||
"""
|
||||
|
||||
checker = "[**"
|
||||
|
||||
def __init__(self):
|
||||
self.result = "🟢 0: perfect."
|
||||
|
||||
def trailing_slash(self):
|
||||
def trailing_slash() -> str:
|
||||
"""
|
||||
Looks for backslash and the end of all the matching
|
||||
lines (YouTubers names lines).
|
||||
"""
|
||||
|
||||
result = ["🟢 0: perfect."]
|
||||
|
||||
for line, value in enumerate(content):
|
||||
if self.checker in value:
|
||||
if CHECKER in value:
|
||||
last = value[-2]
|
||||
if last != "\\":
|
||||
if last == " ":
|
||||
@ -43,23 +28,9 @@ class YoutubersNames():
|
||||
with open(file_readme, 'w') as write_readme:
|
||||
write_readme.writelines(content)
|
||||
|
||||
self.result = f"🔴 {line}: backslash.\nFixed."
|
||||
result.append(f"🔴 {line}: backslash. Fixed.")
|
||||
|
||||
return self.result
|
||||
|
||||
def youtube_link(self):
|
||||
"""
|
||||
Checks whether the link typed is from youtube.com.
|
||||
"""
|
||||
|
||||
link = "youtube.com"
|
||||
for line, value in enumerate(content):
|
||||
if self.checker in value:
|
||||
if link not in value:
|
||||
self.result = f"🔴 {line}: YouTube link."
|
||||
|
||||
return self.result
|
||||
|
||||
|
||||
youtubers_names = YoutubersNames()
|
||||
print(youtubers_names.trailing_slash())
|
||||
if len(result) > 1:
|
||||
return '\n'.join(result[1:])
|
||||
else:
|
||||
return ''.join(result)
|
||||
|
Loading…
Reference in New Issue
Block a user