fixup: Format Python code with Black

pull/885/head
autoblack 2 years ago
parent 68a643ebec
commit 40bfcf468e

@ -11,8 +11,9 @@ from utils.console import handle_input
console = Console() console = Console()
config = dict # autocomplete config = dict # autocomplete
def crawl(obj: dict, func=lambda x, y: print(x, y, end="\n"), path=None): 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 if path is None: # path Default argument value is mutable
path = [] path = []
for key in obj.keys(): for key in obj.keys():
if type(obj[key]) is dict: if type(obj[key]) is dict:
@ -53,11 +54,7 @@ def check(value, checks, name):
and not hasattr(value, "__iter__") and not hasattr(value, "__iter__")
and ( and (
("nmin" in checks and checks["nmin"] is not None and value < checks["nmin"]) ("nmin" in checks and checks["nmin"] is not None and value < checks["nmin"])
or ( or ("nmax" in checks and checks["nmax"] is not None and value > checks["nmax"])
"nmax" in checks
and checks["nmax"] is not None
and value > checks["nmax"]
)
) )
): ):
incorrect = True incorrect = True
@ -65,16 +62,8 @@ def check(value, checks, name):
not incorrect not incorrect
and hasattr(value, "__iter__") and hasattr(value, "__iter__")
and ( and (
( ("nmin" in checks and checks["nmin"] is not None and len(value) < checks["nmin"])
"nmin" in checks or ("nmax" in checks and checks["nmax"] is not None and len(value) > checks["nmax"])
and checks["nmin"] is not None
and len(value) < checks["nmin"]
)
or (
"nmax" in checks
and checks["nmax"] is not None
and len(value) > checks["nmax"]
)
) )
): ):
incorrect = True incorrect = True
@ -82,15 +71,9 @@ def check(value, checks, name):
if incorrect: if incorrect:
value = handle_input( value = handle_input(
message=( message=(
( (("[blue]Example: " + str(checks["example"]) + "\n") if "example" in checks else "")
("[blue]Example: " + str(checks["example"]) + "\n")
if "example" in checks
else ""
)
+ "[red]" + "[red]"
+ ("Non-optional ", "Optional ")[ + ("Non-optional ", "Optional ")["optional" in checks and checks["optional"] is True]
"optional" in checks and checks["optional"] is True
]
) )
+ "[#C0CAF5 bold]" + "[#C0CAF5 bold]"
+ str(name) + str(name)
@ -131,9 +114,7 @@ def check_toml(template_file, config_file) -> Tuple[bool, Dict]:
try: try:
template = toml.load(template_file) template = toml.load(template_file)
except Exception as error: except Exception as error:
console.print( console.print(f"[red bold]Encountered error when trying to to load {template_file}: {error}")
f"[red bold]Encountered error when trying to to load {template_file}: {error}"
)
return False return False
try: try:
config = toml.load(config_file) config = toml.load(config_file)

@ -46,7 +46,10 @@ def name_normalize(name: str) -> str:
else: else:
return name return name
def make_final_video(number_of_clips: int, length: int, reddit_obj: dict, background_config: Tuple[str, str, str, Any]):
def make_final_video(
number_of_clips: int, length: int, reddit_obj: dict, background_config: Tuple[str, str, str, Any]
):
"""Gathers audio clips, gathers all screenshots, stitches them together and saves the final video to assets/temp """Gathers audio clips, gathers all screenshots, stitches them together and saves the final video to assets/temp
Args: Args:
number_of_clips (int): Index to end at when going through the screenshots' number_of_clips (int): Index to end at when going through the screenshots'
@ -66,9 +69,7 @@ def make_final_video(number_of_clips: int, length: int, reddit_obj: dict, backgr
) )
# Gather all audio clips # Gather all audio clips
audio_clips = [ audio_clips = [AudioFileClip(f"assets/temp/mp3/{i}.mp3") for i in range(number_of_clips)]
AudioFileClip(f"assets/temp/mp3/{i}.mp3") for i in range(number_of_clips)
]
audio_clips.insert(0, AudioFileClip("assets/temp/mp3/title.mp3")) audio_clips.insert(0, AudioFileClip("assets/temp/mp3/title.mp3"))
audio_concat = concatenate_audioclips(audio_clips) audio_concat = concatenate_audioclips(audio_clips)
audio_composite = CompositeAudioClip([audio_concat]) audio_composite = CompositeAudioClip([audio_concat])
@ -105,8 +106,7 @@ def make_final_video(number_of_clips: int, length: int, reddit_obj: dict, backgr
# ) # )
# else: story mode stuff # else: story mode stuff
img_clip_pos = background_config[3] img_clip_pos = background_config[3]
image_concat = concatenate_videoclips( image_concat = concatenate_videoclips(image_clips).set_position(img_clip_pos)
image_clips).set_position(img_clip_pos)
image_concat.audio = audio_composite image_concat.audio = audio_composite
final = CompositeVideoClip([background_clip, image_concat]) final = CompositeVideoClip([background_clip, image_concat])
title = re.sub(r"[^\w\s-]", "", reddit_obj["thread_title"]) title = re.sub(r"[^\w\s-]", "", reddit_obj["thread_title"])

Loading…
Cancel
Save