Skip to content

Commit

Permalink
source: Allow generator input
Browse files Browse the repository at this point in the history
  • Loading branch information
LightArrowsEXE committed Oct 7, 2024
1 parent f1ed7d0 commit 02f5eb0
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions vssource/funcs.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import annotations

from functools import partial
from typing import Any, Literal, Protocol, Sequence, overload
from typing import Any, Literal, Generator, Protocol, Sequence, overload

from vstools import (
ChromaLocationT, ColorRangeT, CustomRuntimeError, FieldBasedT, FileType, FileTypeMismatchError, IndexingType,
Expand All @@ -17,8 +17,17 @@
]


def parse_video_filepath(filepath: SPathLike | Sequence[SPathLike]) -> tuple[SPath, ParsedFile]:
filepath = next(iter(Indexer.normalize_filenames(filepath)))
def parse_video_filepath(
filepath: SPathLike | Sequence[SPathLike] | Generator[SPath, None, None]
) -> tuple[SPath, ParsedFile]:
if isinstance(filepath, Generator):
filepath = list(filepath)

try:
filepath = next(iter(Indexer.normalize_filenames(filepath)))
except StopIteration:
raise CustomRuntimeError('No files provided!', source, filepath)

check_perms(filepath, 'r', strict=True, func=source)

file = FileType.parse(filepath) if filepath.exists() else None
Expand Down Expand Up @@ -100,7 +109,7 @@ def __call__(self, *args: Any, **kwargs: Any) -> Any:

@copy_signature(_source_func)
def source(
filepath: SPathLike | Sequence[SPathLike] | None = None,
filepath: SPathLike | Sequence[SPathLike] | Generator[SPathLike, None, None] | None = None,
bits: int | None = None, *,
matrix: MatrixT | None = None,
transfer: TransferT | None = None,
Expand Down

0 comments on commit 02f5eb0

Please sign in to comment.