Coverage for /opt/hostedtoolcache/Python/3.10.17/x64/lib/python3.10/site-packages/vfx_seqtools/actions/seqgen.py: 94%

18 statements  

« prev     ^ index     » next       coverage.py v7.8.2, created at 2025-05-30 00:30 +0000

1import logging 

2from typing import Annotated 

3 

4import fileseq 

5import typer 

6 

7from vfx_seqtools import common_options 

8from vfx_seqtools.decorators import attach_hook 

9 

10 

11def to_list(frames: str) -> list: 

12 """Return a list from a passed string of frame numbers. 

13 

14 Args: 

15 frames (str): the frame numbers, comma or space-separated. 

16 

17 Returns: 

18 list: list representation of the numbers. 

19 """ 

20 if "," in frames: 

21 return [int(i) for i in frames.split(",")] 

22 elif " " in frames: 

23 return [int(i) for i in frames.split()] 

24 else: 

25 return [int(i) for i in frames.split(",")] 

26 

27 

28@attach_hook(common_options.logging_options, hook_output_kwarg="logger") 

29@attach_hook(common_options.version_option, hook_output_kwarg="show_version") 

30def seqgen( 

31 frames: Annotated[ 

32 str, 

33 typer.Argument( 

34 help="A list of frames to consider, ex. '1,3,5,7'. Use quotes to surround space-separated values." 

35 ), 

36 ], 

37 show_version: bool, 

38 logger: logging.Logger, 

39) -> None: 

40 """ 

41 Generate a frame sequence from individual frame numbers. 

42 

43 'seqgen 1,3,5,7' - will return the frame sequence 1-7x2. 

44 """ 

45 framelist = to_list(frames) 

46 seq = fileseq.FrameSet(framelist) 

47 

48 print(seq.frange)