Formatted with python-black
This commit is contained in:
1 parent
dba11ea1e3
commit
69f4f59bb6
11 files changed
+95
-59
No files matched your search
+39
-15
@@ -15,7 +15,7 @@ def check_env() -> bool:
|
||||
|
||||
Returns:
|
||||
bool: Whether or not everything was put in properly
|
||||
"""
|
||||
"""
|
||||
if not os.path.exists(".env.template"):
|
||||
console.print("[red]Couldn't find .env.template. Unable to check variables.")
|
||||
return True
|
||||
@@ -35,7 +35,11 @@ def check_env() -> bool:
|
||||
req_envs = []
|
||||
var_optional = False
|
||||
for line in template.readlines():
|
||||
if line.startswith("#") is not True and "=" in line and var_optional is not True:
|
||||
if (
|
||||
line.startswith("#") is not True
|
||||
and "=" in line
|
||||
and var_optional is not True
|
||||
):
|
||||
req_envs.append(line.split("=")[0])
|
||||
if "#" in line:
|
||||
examples[line.split("=")[0]] = "#".join(line.split("#")[1:]).strip()
|
||||
@@ -56,7 +60,9 @@ def check_env() -> bool:
|
||||
)
|
||||
var_optional = False
|
||||
elif line.startswith("#MATCH_TYPE "):
|
||||
types[req_envs[-1]] = eval(line.removeprefix("#MATCH_TYPE ")[:-1].split()[0])
|
||||
types[req_envs[-1]] = eval(
|
||||
line.removeprefix("#MATCH_TYPE ")[:-1].split()[0]
|
||||
)
|
||||
var_optional = False
|
||||
elif line.startswith("#EXPLANATION "):
|
||||
explanations[req_envs[-1]] = line.removeprefix("#EXPLANATION ")[:-1]
|
||||
@@ -82,9 +88,9 @@ def check_env() -> bool:
|
||||
try:
|
||||
temp = types[env](value)
|
||||
if env in bounds.keys():
|
||||
(bounds[env][0] <= temp or incorrect.add(env)) and len(bounds[env]) > 1 and (
|
||||
bounds[env][1] >= temp or incorrect.add(env)
|
||||
)
|
||||
(bounds[env][0] <= temp or incorrect.add(env)) and len(
|
||||
bounds[env]
|
||||
) > 1 and (bounds[env][1] >= temp or incorrect.add(env))
|
||||
except ValueError:
|
||||
incorrect.add(env)
|
||||
|
||||
@@ -107,11 +113,17 @@ def check_env() -> bool:
|
||||
for env in missing:
|
||||
table.add_row(
|
||||
env,
|
||||
explanations[env] if env in explanations.keys() else "No explanation given",
|
||||
explanations[env]
|
||||
if env in explanations.keys()
|
||||
else "No explanation given",
|
||||
examples[env] if env in examples.keys() else "",
|
||||
str(bounds[env][0]) if env in bounds.keys() and bounds[env][1] is not None else "",
|
||||
str(bounds[env][0])
|
||||
if env in bounds.keys() and bounds[env][1] is not None
|
||||
else "",
|
||||
str(bounds[env][1])
|
||||
if env in bounds.keys() and len(bounds[env]) > 1 and bounds[env][1] is not None
|
||||
if env in bounds.keys()
|
||||
and len(bounds[env]) > 1
|
||||
and bounds[env][1] is not None
|
||||
else "",
|
||||
)
|
||||
console.print(table)
|
||||
@@ -128,7 +140,9 @@ def check_env() -> bool:
|
||||
title_style="#C0CAF5 bold",
|
||||
)
|
||||
table.add_column("Variable", justify="left", style="#7AA2F7 bold", no_wrap=True)
|
||||
table.add_column("Current value", justify="left", style="#F7768E", no_wrap=False)
|
||||
table.add_column(
|
||||
"Current value", justify="left", style="#F7768E", no_wrap=False
|
||||
)
|
||||
table.add_column("Explanation", justify="left", style="#BB9AF7", no_wrap=False)
|
||||
table.add_column("Example", justify="center", style="#F7768E", no_wrap=True)
|
||||
table.add_column("Min", justify="right", style="#F7768E", no_wrap=True)
|
||||
@@ -137,10 +151,14 @@ def check_env() -> bool:
|
||||
table.add_row(
|
||||
env,
|
||||
os.getenv(env),
|
||||
explanations[env] if env in explanations.keys() else "No explanation given",
|
||||
explanations[env]
|
||||
if env in explanations.keys()
|
||||
else "No explanation given",
|
||||
str(types[env].__name__) if env in types.keys() else "str",
|
||||
str(bounds[env][0]) if env in bounds.keys() else "None",
|
||||
str(bounds[env][1]) if env in bounds.keys() and len(bounds[env]) > 1 else "None",
|
||||
str(bounds[env][1])
|
||||
if env in bounds.keys() and len(bounds[env]) > 1
|
||||
else "None",
|
||||
)
|
||||
missing.add(env)
|
||||
console.print(table)
|
||||
@@ -177,11 +195,17 @@ def check_env() -> bool:
|
||||
if env in explanations.keys()
|
||||
else "Incorrect input. Try again.",
|
||||
bounds[env][0] if env in bounds.keys() else None,
|
||||
bounds[env][1] if env in bounds.keys() and len(bounds[env]) > 1 else None,
|
||||
oob_errors[env] if env in oob_errors.keys() else "Input too long/short.",
|
||||
bounds[env][1]
|
||||
if env in bounds.keys() and len(bounds[env]) > 1
|
||||
else None,
|
||||
oob_errors[env]
|
||||
if env in oob_errors.keys()
|
||||
else "Input too long/short.",
|
||||
extra_info="[#C0CAF5 bold]⮶ "
|
||||
+ (
|
||||
explanations[env] if env in explanations.keys() else "No info available"
|
||||
explanations[env]
|
||||
if env in explanations.keys()
|
||||
else "No info available"
|
||||
),
|
||||
)
|
||||
)
|
||||
|
||||
+4
-2
@@ -7,10 +7,12 @@ def cleanup() -> int:
|
||||
|
||||
Returns:
|
||||
int: How many files were deleted
|
||||
"""
|
||||
"""
|
||||
if exists("./assets/temp"):
|
||||
count = 0
|
||||
files = [f for f in os.listdir(".") if f.endswith(".mp4") and "temp" in f.lower()]
|
||||
files = [
|
||||
f for f in os.listdir(".") if f.endswith(".mp4") and "temp" in f.lower()
|
||||
]
|
||||
count += len(files)
|
||||
for f in files:
|
||||
os.remove(f)
|
||||
|
||||
+6
-2
@@ -64,10 +64,14 @@ def handle_input(
|
||||
except ValueError:
|
||||
console.print("[red]" + err_message) # Type conversion failed
|
||||
continue
|
||||
if nmin is not None and len(user_input) < nmin: # Check if string is long enough
|
||||
if (
|
||||
nmin is not None and len(user_input) < nmin
|
||||
): # Check if string is long enough
|
||||
console.print("[red]" + oob_error)
|
||||
continue
|
||||
if nmax is not None and len(user_input) > nmax: # Check if string is not too long
|
||||
if (
|
||||
nmax is not None and len(user_input) > nmax
|
||||
): # Check if string is not too long
|
||||
console.print("[red]" + oob_error)
|
||||
continue
|
||||
break
|
||||
|
||||
+5
-5
@@ -9,11 +9,11 @@ def get_subreddit_undone(submissions: list, subreddit):
|
||||
|
||||
Args:
|
||||
submissions (list): List of posts that are going to potentially be generated into a video
|
||||
subreddit (praw.Reddit.SubredditHelper): Chosen subreddit
|
||||
subreddit (praw.Reddit.SubredditHelper): Chosen subreddit
|
||||
|
||||
Returns:
|
||||
Any: The submission that has not been done
|
||||
"""
|
||||
"""
|
||||
"""
|
||||
recursively checks if the top submission in the list was already done.
|
||||
"""
|
||||
@@ -36,8 +36,8 @@ def get_subreddit_undone(submissions: list, subreddit):
|
||||
) # all of the videos in hot have already been done
|
||||
|
||||
|
||||
def already_done(done_videos: list, submission)->bool:
|
||||
"""Checks to see if the given submission is in the list of videos
|
||||
def already_done(done_videos: list, submission) -> bool:
|
||||
"""Checks to see if the given submission is in the list of videos
|
||||
|
||||
Args:
|
||||
done_videos (list): Finished videos
|
||||
@@ -45,7 +45,7 @@ def already_done(done_videos: list, submission)->bool:
|
||||
|
||||
Returns:
|
||||
Boolean: Whether the video was found in the list
|
||||
"""
|
||||
"""
|
||||
|
||||
for video in done_videos:
|
||||
if video["id"] == str(submission):
|
||||
|
||||
+4
-2
@@ -5,8 +5,10 @@ from utils.console import print_step
|
||||
|
||||
|
||||
def check_done(
|
||||
redditobj:dict[str],
|
||||
)->dict[str]|None: # don't set this to be run anyplace that isn't subreddit.py bc of inspect stack
|
||||
redditobj: dict[str],
|
||||
) -> dict[
|
||||
str
|
||||
] | None: # don't set this to be run anyplace that isn't subreddit.py bc of inspect stack
|
||||
"""Checks if the chosen post has already been generated
|
||||
|
||||
Args:
|
||||
|
||||
Reference in new issue
Block a user