Skip to content

Commit

Permalink
Rename "color" to "parse_color"
Browse files Browse the repository at this point in the history
  • Loading branch information
WyattBlue committed Oct 24, 2024
1 parent 805cbf8 commit 968d577
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 20 deletions.
4 changes: 2 additions & 2 deletions auto_editor/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
from auto_editor.utils.log import Log
from auto_editor.utils.types import (
Args,
color,
frame_rate,
margin,
number,
parse_color,
resolution,
sample_rate,
speed,
Expand Down Expand Up @@ -108,7 +108,7 @@ def main_options(parser: ArgumentParser) -> ArgumentParser:
parser.add_argument(
"--background",
"-b",
type=color,
type=parse_color,
metavar="COLOR",
help="Set the background as a solid RGB color",
)
Expand Down
3 changes: 1 addition & 2 deletions auto_editor/ffwrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,11 @@ def initFFmpeg(log: Log, ff_location: str | None, my_ffmpeg: bool) -> FFmpeg:
if path is None:
log.error("Did not find ffmpeg on PATH.")

return FFmpeg(log, path)
return FFmpeg(path)


@dataclass(slots=True)
class FFmpeg:
log: Log
path: str

def run(self, cmd: list[str]) -> None:
Expand Down
3 changes: 1 addition & 2 deletions auto_editor/render/video.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

from auto_editor.output import parse_bitrate
from auto_editor.timeline import TlImage, TlRect, TlVideo
from auto_editor.utils.types import color

if TYPE_CHECKING:
from collections.abc import Iterator
Expand Down Expand Up @@ -203,7 +202,7 @@ def render_av(

bar.start(tl.end, "Creating new video")

bg = color(args.background)
bg = args.background
null_frame = make_solid(target_width, target_height, target_pix_fmt, bg)
frame_index = -1

Expand Down
4 changes: 2 additions & 2 deletions auto_editor/timeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from auto_editor.ffwrapper import initFileInfo, mux
from auto_editor.lib.contracts import *
from auto_editor.utils.cmdkw import Required, pAttr, pAttrs
from auto_editor.utils.types import color, natural, number, threshold
from auto_editor.utils.types import natural, number, parse_color, threshold

if TYPE_CHECKING:
from collections.abc import Iterator
Expand Down Expand Up @@ -165,7 +165,7 @@ def as_dict(self) -> dict:
pAttr("y", Required, is_int, int),
pAttr("width", Required, is_int, int),
pAttr("height", Required, is_int, int),
pAttr("fill", "#c4c4c4", is_str, color),
pAttr("fill", "#c4c4c4", is_str, parse_color),
)
visual_objects = {
"rect": (TlRect, rect_builder),
Expand Down
14 changes: 2 additions & 12 deletions auto_editor/utils/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import re
from dataclasses import dataclass, field
from fractions import Fraction
from typing import Literal


class CoerceError(Exception):
Expand Down Expand Up @@ -156,16 +155,7 @@ def speed_range(val: str) -> tuple[float, str, str]:
return number(a[0]), a[1], a[2]


Stream = int | Literal["all"]


def stream(val: str) -> Stream:
if val == "all" or val == "'all":
return "all"
return natural(val)


def color(val: str) -> str:
def parse_color(val: str) -> str:
"""
Convert a color str into an RGB tuple
Expand Down Expand Up @@ -219,7 +209,7 @@ class Args:
frame_rate: Fraction | None = None
sample_rate: int | None = None
resolution: tuple[int, int] | None = None
background: str = "#000"
background: str = "#000000"
edit_based_on: str = "audio"
keep_tracks_separate: bool = False
audio_normalize: str = "#f"
Expand Down

0 comments on commit 968d577

Please sign in to comment.