Skip to content

Commit 272bbce

Browse files
committed
Remove filesetup object
1 parent de3c895 commit 272bbce

File tree

6 files changed

+12
-26
lines changed

6 files changed

+12
-26
lines changed

auto_editor/analyze.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,6 @@
2828
from auto_editor.utils.log import Log
2929

3030

31-
@dataclass(slots=True)
32-
class FileSetup:
33-
src: FileInfo
34-
strict: bool
35-
tb: Fraction
36-
bar: Bar
37-
log: Log
38-
39-
4031
class LevelError(Exception):
4132
pass
4233

@@ -177,6 +168,7 @@ class Levels:
177168
bar: Bar
178169
no_cache: bool
179170
log: Log
171+
strict: bool
180172

181173
@property
182174
def media_length(self) -> int:

auto_editor/lang/palet.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1487,12 +1487,12 @@ def edit_audio(
14871487
mincut: int = 6,
14881488
minclip: int = 3,
14891489
) -> np.ndarray:
1490-
if "@levels" not in env or "@filesetup" not in env:
1490+
if "@levels" not in env:
14911491
raise MyError("Can't use `audio` if there's no input media")
14921492

14931493
levels = env["@levels"]
1494-
src = env["@filesetup"].src
1495-
strict = env["@filesetup"].strict
1494+
src = levels.src
1495+
strict = levels.strict
14961496

14971497
stream_data: NDArray[np.bool_] | None = None
14981498
if stream == Sym("all"):
@@ -1531,19 +1531,17 @@ def edit_motion(
15311531
raise MyError("Can't use `motion` if there's no input media")
15321532

15331533
levels = env["@levels"]
1534-
strict = env["@filesetup"].strict
15351534
try:
15361535
return levels.motion(stream, blur, width) >= threshold
15371536
except LevelError as e:
1538-
return raise_(e) if strict else levels.all()
1537+
return raise_(e) if levels.strict else levels.all()
15391538

15401539

15411540
def edit_subtitle(pattern, stream=0, **kwargs):
15421541
if "@levels" not in env:
15431542
raise MyError("Can't use `subtitle` if there's no input media")
15441543

15451544
levels = env["@levels"]
1546-
strict = env["@filesetup"].strict
15471545
if "ignore-case" not in kwargs:
15481546
kwargs["ignore-case"] = False
15491547
if "max-count" not in kwargs:
@@ -1553,7 +1551,7 @@ def edit_subtitle(pattern, stream=0, **kwargs):
15531551
try:
15541552
return levels.subtitle(pattern, stream, ignore_case, max_count)
15551553
except LevelError as e:
1556-
return raise_(e) if strict else levels.all()
1554+
return raise_(e) if levels.strict else levels.all()
15571555

15581556

15591557
def my_eval(env: Env, node: object) -> Any:

auto_editor/make_layers.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import numpy as np
88

9-
from auto_editor.analyze import FileSetup, Levels
9+
from auto_editor.analyze import Levels
1010
from auto_editor.ffwrapper import FileInfo
1111
from auto_editor.lang.palet import Lexer, Parser, env, interpret, is_boolarr
1212
from auto_editor.lib.data_structs import print_str
@@ -125,16 +125,13 @@ def make_timeline(
125125
concat = np.concatenate
126126

127127
for i, src in enumerate(sources):
128-
filesetup = FileSetup(src, len(sources) < 2, tb, bar, log)
129-
130128
try:
131129
parser = Parser(Lexer("`--edit`", args.edit_based_on))
132130
if log.is_debug:
133131
log.debug(f"edit: {parser}")
134132

135133
env["timebase"] = tb
136-
env["@levels"] = Levels(src, tb, bar, args.no_cache, log)
137-
env["@filesetup"] = filesetup
134+
env["@levels"] = Levels(src, tb, bar, args.no_cache, log, len(sources) < 2)
138135

139136
results = interpret(env, parser)
140137

auto_editor/preview.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def preview(tl: v3, log: Log) -> None:
6565

6666
in_len = 0
6767
for src in all_sources:
68-
in_len += Levels(src, tb, Bar("none"), False, log).media_length
68+
in_len += Levels(src, tb, Bar("none"), False, log, False).media_length
6969

7070
out_len = tl.out_len()
7171

auto_editor/subcommands/levels.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ def main(sys_args: list[str] = sys.argv[1:]) -> None:
127127
except ParserError as e:
128128
log.error(e)
129129

130-
levels = Levels(src, tb, bar, False, log)
130+
levels = Levels(src, tb, bar, False, log, strict=True)
131131
try:
132132
if method == "audio":
133133
print_arr_gen(iter_audio(src, tb, **obj))

auto_editor/subcommands/repl.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from fractions import Fraction
66

77
import auto_editor
8-
from auto_editor.analyze import FileSetup, Levels
8+
from auto_editor.analyze import Levels
99
from auto_editor.ffwrapper import initFileInfo
1010
from auto_editor.lang.palet import ClosingError, Lexer, Parser, env, interpret
1111
from auto_editor.lib.data_structs import print_str
@@ -65,8 +65,7 @@ def main(sys_args: list[str] = sys.argv[1:]) -> None:
6565
tb = src.get_fps() if args.timebase is None else args.timebase
6666
bar = Bar("modern")
6767
env["timebase"] = tb
68-
env["@levels"] = Levels(src, tb, bar, False, log)
69-
env["@filesetup"] = FileSetup(src, strict, tb, bar, log)
68+
env["@levels"] = Levels(src, tb, bar, False, log, strict)
7069

7170
print(f"Auto-Editor {auto_editor.__version__}")
7271
text = None

0 commit comments

Comments
 (0)