docs: improved examples in .config.template.toml

fix: mutability issue in settings.py
style: added autocomplete support for the settings.config var
style: fixed autocomplete issues overall
pull/879/head
Jason 3 years ago
parent b26798c232
commit b82459166b

@ -1,7 +1,7 @@
[reddit.creds]
client_id = { optional = false, nmin = 12, nmax = 30, explanation = "the ID of your Reddit app of SCRIPT type", example = "fFAGRNJru1FTz70BzhT3Zg", regex = "^[-a-zA-Z0-9._~+/]+=*$", input_error = "The client ID can only contain printable characters.", oob_error = "The ID should be over 12 and under 30 characters, double check your input." }
client_secret = { optional = false, nmin = 20, nmax = 40, explanation = "the SECRET of your Reddit app of SCRIPT type", example = "fFAGRNJru1FTz70BzhT3Zg", regex = "^[-a-zA-Z0-9._~+/]+=*$", input_error = "The client ID can only contain printable characters.", oob_error = "The secret should be over 20 and under 40 characters, double check your input." }
username = { optional = false, nmin = 3, nmax = 20, explanation = "the username of your reddit account", example = "asdfghjkl", regex = "^[-_0-9a-zA-Z]+$", oob_error = "A username HAS to be between 3 and 20 characters" }
username = { optional = false, nmin = 3, nmax = 20, explanation = "the username of your reddit account", example = "JasonLovesDoggo", regex = "^[-_0-9a-zA-Z]+$", oob_error = "A username HAS to be between 3 and 20 characters" }
password = { optional = false, nmin = 8, explanation = "the password of your reddit account", example = "fFAGRNJru1FTz70BzhT3Zg", oob_error = "Password too short" }
2fa = { optional = true, type = "bool", options = [
true,
@ -15,7 +15,7 @@ random = { optional = true, options = [
false,
], default = false, type = "bool", explanation = "If set to no, it will ask you a thread link to extract the thread, if yes it will randomize it. Default: 'False'", example = "True" }
subreddit = { optional = false, regex = "[_0-9a-zA-Z]+$", nmin = 3, nmax = 21, explanation = "what subreddit to pull posts from, the name of the sub, not the URL", example = "AskReddit", oob_error = "A subreddit name HAS to be between 3 and 20 characters" }
post_id = { optional = true, default = "", regex = "^((?!://|://).)*$", explanation = "Used if you want to use a specific post.", example = "urdtfx" }
post_id = { optional = true, default = "", regex = "^((?!://|://)[+a-zA-Z])*$", explanation = "Used if you want to use a specific post.", example = "urdtfx" }
max_comment_length = { default = 500, optional = false, nmin = 10, nmax = 10000, type = "int", explanation = "max number of characters a comment can have. default is 500", example = 500, oob_error = "the max comment length should be between 10 and 10000" }
post_lang = { default = "", optional = true, explanation = "The language you would like to translate to.", example = "es-cr"}
@ -24,7 +24,7 @@ allow_nsfw = { optional = false, type = "bool", default = false, example = false
true,
false,
], explanation = "Whether to allow NSFW content, True or False" }
theme = { optional = false, default = "light", example = "dark", options = [
theme = { optional = false, default = "dark", example = "light", options = [
"dark",
"light",
], explanation = "sets the Reddit theme, either LIGHT or DARK" }
@ -37,7 +37,7 @@ storymode = { optional = true, type = "bool", default = false, example = false,
[settings.tts]
choice = { optional = false, default = "", options = [ "streamlabspolly", "tiktok", "googletranslate", "awspolly",], example = "streamlabspolly", explanation = "The backend used for TTS generation. This can be left blank and you will be prompted to choose at runtime." }
aws_polly_voice = { optional = false, default = "Matthew", example = "Matthew", explanation = "The voice used for AWS Polly" }
streamlabs_polly_voice = { optional = false, default = "Matthew", example = "Matthew", explanation = "The voice used for Streamlabs Polly" }
tiktok_voice = { optional = false, default = "en_us_006", example = "en_us_006", explanation = "The voice used for TikTok TTS" }
choice = { optional = false, default = "", options = [ "streamlabspolly", "tiktok", "googletranslate", "awspolly", ""], example = "streamlabspolly", explanation = "The backend used for TTS generation. This can be left blank and you will be prompted to choose at runtime." }

@ -1,40 +0,0 @@
name: 'Stale issue handler'
on:
workflow_dispatch:
schedule:
- cron: '0 0 * * *'
jobs:
stale:
runs-on: ubuntu-latest
steps:
- uses: actions/stale@main
id: stale-issue
name: stale-issue
with:
stale-issue-message: 'This issue is stale because it has been open 7 days with no activity. Remove stale label or comment, or this will be closed in 10 days.'
close-issue-message: 'Issue closed due to being stale. Please reopen if issue persists in latest version.'
days-before-stale: 7
days-before-close: 10
stale-issue-label: 'stale'
close-issue-label: 'outdated'
exempt-issue-labels: 'enhancement,keep,blocked'
exempt-all-issue-milestones: true
operations-per-run: 300
remove-stale-when-updated: true
- uses: actions/stale@main
id: stale-pr
name: stale-pr
with:
stale-pr-message: 'This pull request is stale as it has been open for 7 days with no activity. Remove stale label or comment, or this will be closed in 10 days.'
close-pr-message: 'Pull request closed due to being stale.'
days-before-stale: 7
days-before-close: 10
close-pr-label: 'outdated'
stale-pr-label: 'stale'
exempt-pr-labels: 'keep,blocked,before next release,after next release'
exempt-all-pr-milestones: true
operations-per-run: 300
remove-stale-when-updated: true

@ -1,5 +1,4 @@
#!/usr/bin/env python
# import os
import toml
from rich.console import Console
import re
@ -8,13 +7,13 @@ from typing import Tuple, Dict
from utils.console import handle_input
# from console import handle_input
console = Console()
config = dict # autocomplete
def crawl(obj: dict, func=lambda x, y: print(x, y, end="\n"), path: list = []):
def crawl(obj: dict, func=lambda x, y: print(x, y, end="\n"), path=None):
if path is None: # path Default argument value is mutable
path = []
for key in obj.keys():
if type(obj[key]) is dict:
crawl(obj[key], func, path + [key])
@ -138,7 +137,7 @@ def check_toml(template_file, config_file) -> Tuple[bool, Dict]:
return False
try:
config = toml.load(config_file)
except (toml.TomlDecodeError):
except toml.TomlDecodeError:
console.print(
f"""[blue]Couldn't read {config_file}.
Overwrite it?(y/n)"""
@ -155,7 +154,7 @@ Overwrite it?(y/n)"""
f"[red bold]Failed to overwrite {config_file}. Giving up.\nSuggestion: check {config_file} permissions for the user."
)
return False
except (FileNotFoundError):
except FileNotFoundError:
console.print(
f"""[blue]Couldn't find {config_file}
Creating it now."""

@ -15,10 +15,10 @@ def check_done(
"""Checks if the chosen post has already been generated
Args:
redditobj (Dict[str]): Reddit object gotten from reddit/subreddit.py
redditobj (Submission): Reddit object gotten from reddit/subreddit.py
Returns:
Dict[str]|None: Reddit object in args
Submission|None: Reddit object in args
"""
with open(
"./video_creation/data/videos.json", "r", encoding="utf-8"

@ -20,8 +20,8 @@ def download_screenshots_of_reddit_posts(reddit_object: dict, screenshot_num: in
"""Downloads screenshots of reddit posts as seen on the web. Downloads to assets/temp/png
Args:
reddit_object (Dict[str]): Reddit object received from reddit/subreddit.py
screenshot_num (int): Number of screenshots to downlaod
reddit_object (Dict): Reddit object received from reddit/subreddit.py
screenshot_num (int): Number of screenshots to download
"""
print_step("Downloading screenshots of reddit posts...")

@ -27,7 +27,7 @@ def save_text_to_mp3(reddit_obj) -> Tuple[int, int]:
"""Saves text to MP3 files.
Args:
reddit_obj (dict[str]): Reddit object received from reddit API in reddit/subreddit.py
reddit_obj (): Reddit object received from reddit API in reddit/subreddit.py
Returns:
tuple[int,int]: (total length of the audio, the number of comments audio was generated for)

Loading…
Cancel
Save