Added docs and typing in function declarations
This commit is contained in:
6 files changed
+68
-15
No files matched your search
@@ -11,6 +11,11 @@ console = Console()
|
||||
|
||||
|
||||
def check_env() -> bool:
|
||||
"""Checks to see what's been put in .env
|
||||
|
||||
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
|
||||
|
||||
@@ -3,6 +3,11 @@ from os.path import exists
|
||||
|
||||
|
||||
def cleanup() -> int:
|
||||
"""Deletes all temporary assets in assets/temp
|
||||
|
||||
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()]
|
||||
|
||||
+20
-2
@@ -4,7 +4,16 @@ from os import getenv
|
||||
from utils.console import print_substep
|
||||
|
||||
|
||||
def get_subreddit_undone(submissions: List, subreddit):
|
||||
def get_subreddit_undone(submissions: list, subreddit):
|
||||
"""_summary_
|
||||
|
||||
Args:
|
||||
submissions (list): List of posts that are going to potentially be generated into a video
|
||||
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.
|
||||
"""
|
||||
@@ -27,7 +36,16 @@ def get_subreddit_undone(submissions: List, subreddit):
|
||||
) # all of the videos in hot have already been done
|
||||
|
||||
|
||||
def already_done(done_videos: list, submission):
|
||||
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
|
||||
submission (Any): The submission
|
||||
|
||||
Returns:
|
||||
Boolean: Whether the video was found in the list
|
||||
"""
|
||||
|
||||
for video in done_videos:
|
||||
if video["id"] == str(submission):
|
||||
|
||||
+11
-4
@@ -5,10 +5,17 @@ from utils.console import print_step
|
||||
|
||||
|
||||
def check_done(
|
||||
redditobj,
|
||||
): # don't set this to be run anyplace that isn't subreddit.py bc of inspect stack
|
||||
"""params:
|
||||
reddit_object: The Reddit Object you received in askreddit.py"""
|
||||
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:
|
||||
redditobj (dict[str]): Reddit object gotten from reddit/subreddit.py
|
||||
|
||||
Returns:
|
||||
dict[str]|None: Reddit object in args
|
||||
"""
|
||||
|
||||
with open("./video_creation/data/videos.json", "r") as done_vids_raw:
|
||||
done_videos = json.load(done_vids_raw)
|
||||
for video in done_videos:
|
||||
|
||||
+11
-6
@@ -1,12 +1,17 @@
|
||||
import re
|
||||
|
||||
|
||||
def sanitize_text(text):
|
||||
"""
|
||||
Sanitizes the text for tts.
|
||||
What gets removed:
|
||||
- following characters`^_~@!&;#:-%“”‘"%*/{}[]()\|<>?=+`
|
||||
- any http or https links
|
||||
def sanitize_text(text: str) -> str:
|
||||
"""Sanitizes the text for tts.
|
||||
What gets removed:
|
||||
- following characters`^_~@!&;#:-%“”‘"%*/{}[]()\|<>?=+`
|
||||
- any http or https links
|
||||
|
||||
Args:
|
||||
text (str): Text to be sanitized
|
||||
|
||||
Returns:
|
||||
str: Sanitized text
|
||||
"""
|
||||
|
||||
# remove any urls from the text
|
||||
|
||||
Reference in new issue
Block a user