
Fileseq Documentation Release 1.13.1 Justin Israel Sep 25, 2021 Contents 1 fileseq module 1 2 fileseq.exceptions module 5 3 fileseq.filesequence module 7 4 fileseq.frameset module 17 Python Module Index 29 Index 31 i ii CHAPTER 1 fileseq module A Python library for parsing frame ranges and file sequences commonly used in VFX and Animation applications. The MIT License (MIT) Original work Copyright (c) 2015 Matthew Chambers Modified work Copyright 2015 Justin Israel Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documen- tation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PAR- TICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFT- WARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. Frame Range Shorthand Support for: • Standard: 1-10 • Comma Delimited: 1-10,10-20 • Chunked: 1-100x5 • Filled: 1-100y5 • Staggered: 1-100:3 (1-100x3, 1-100x2, 1-100) • Negative frame numbers: -10-100 • Subframes: 1001-1066x0.25 1 Fileseq Documentation, Release 1.13.1 • Padding: #=4 padded, @=single pad • Printf Syntax Padding: %04d=4 padded, %01d=1 padded • Houdini Syntax Padding: $F4=4 padding, $F=1 padded FrameSets A FrameSet wraps a sequence of frames in a list list container. Iterate a FrameSet >>> fs= FrameSet("1-5") >>> for f in fs: ... print(f) 1 2 3 4 5 Access Frames Using Indices >>> fs= FrameSet("1-100:8") >>> fs[0] # First frame. 1 >>> fs[-1] # Last frame. 98 Access Frames Using Convenience Methods: >>> fs= FrameSet("1-100:8") >>> fs.start() # First frame. 1 >>> fs.end() # Last frame. 98 FileSequence A FileSequence is a container representing a filepath over a range of frames Instantiate from string >>> FileSequence("/foo/bar.1-10#.exr") <FileSequence: '/foo/bar.1-10#.exr'> Format Path for VFX Software Using FileSequence.format Method >>> seq= FileSequence("/foo/bar.1-10#.exr") >>> seq.format(template='{dirname}{basename}{padding}{extension}') '/foo/bar.#.exr' >>> seq= FileSequence("/foo/bar.1-10#.#.exr", allow_subframes= True) >>> seq.format(template='{dirname}{basename}{padding}{extension}') '/foo/bar.#.#.exr' Joining 2 Chapter 1. fileseq module Fileseq Documentation, Release 1.13.1 >>> seq= FileSequence("/foo/bar.1-10#.exr") >>> seq.setPadding('%02d') >>> seq <FileSequence: '/foo/bar.1-10%02d.exr'> >>> seq.format(template='{dirname}{basename}{padding}{extension}') '/foo/bar.%02d.exr' Get List of File Paths >>> seq= FileSequence("/foo/bar.1-5#.exr") >>> list(seq) ['/foo/bar.0001.exr', '/foo/bar.0002.exr', '/foo/bar.0003.exr', '/foo/bar.0004.exr', '/foo/bar.0005.exr'] >>> [seq[idx] for idx, fr in enumerate(seq.frameSet())] ['/foo/bar.0001.exr', '/foo/bar.0002.exr', '/foo/bar.0003.exr', '/foo/bar.0004.exr', '/foo/bar.0005.exr'] Finding Sequences on Disk Check a Directory for All Existing Sequences >>> seqs= findSequencesOnDisk("/show/shot/renders/bty_foo/v1") Check a Directory for One Existing Sequence • Use a ‘@’ or ‘#’ where you might expect to use ‘*’ for a wildcard character. • For this method, it doesn’t matter how many instances of the padding character you use, it will still find your sequence (unless enabling strict padding option). Yes: findSequenceOnDisk('/foo/[email protected]') Yes: findSequenceOnDisk('/foo/bar.@@@@@.exr') No: findSequenceOnDisk('/foo/bar.*.exr') • To find subframe sequences you must explicitly opt-in fileseq.findSequenceOnDisk('/foo/bar.#.#.exr', allow_subframes=True) 3 Fileseq Documentation, Release 1.13.1 4 Chapter 1. fileseq module CHAPTER 2 fileseq.exceptions module exceptions - Exception subclasses relevant to fileseq operations. exception fileseq.exceptions.FileSeqException Bases: exceptions.ValueError Thrown for general exceptions handled by FileSeq. exception fileseq.exceptions.MaxSizeException Bases: exceptions.ValueError Thrown when a range exceeds allowable size. exception fileseq.exceptions.ParseException Bases: fileseq.exceptions.FileSeqException Thrown after a frame range or file sequence parse error. 5 Fileseq Documentation, Release 1.13.1 6 Chapter 2. fileseq.exceptions module CHAPTER 3 fileseq.filesequence module filesequence - A parsing object representing sequential files for fileseq. class fileseq.filesequence.FileSequence(sequence, pad_style=<PAD_STYLE: HASH4>, al- low_subframes=False) Bases: future.types.newobject.newobject FileSequence represents an ordered sequence of files. Parameters sequence (str) – (ie: dir/path.1-100#.ext) Returns Return type FileSequence Raises • fileseq.exceptions.MaxSizeException – If frame size exceeds • fileseq.constants.MAX_FRAME_SIZE DISK_RE = <_sre.SRE_Pattern object> DISK_SUB_RE = <_sre.SRE_Pattern object> PAD_MAP = {'#': {<PAD_STYLE: HASH1>: 1, <PAD_STYLE: HASH4>: 4}, '@': {<PAD_STYLE: HASH1>: 1, <PAD_STYLE: HASH4>: 1}} REVERSE_PAD_MAP = {<PAD_STYLE: HASH1>: {1: '#'}, <PAD_STYLE: HASH4>: {1: '@', 4: '#'}} SPLIT_RE = <_sre.SRE_Pattern object> SPLIT_SUB_RE = <_sre.SRE_Pattern object> __getitem__(idx) Allows indexing and slicing into the underlying FrameSet When indexing, a string filepath is returns for the frame. When slicing, a new FileSequence is returned. Slicing outside the range of the sequence results in an IndexError Parameters idx (int or slice) – the desired index 7 Fileseq Documentation, Release 1.13.1 Returns Return type str or FileSequence Raises IndexError – If slice is outside the range of the sequence __iter__() Allow iteration over the path or paths this FileSequence represents. Yields FileSequence __len__() The length (number of files) represented by this FileSequence. Returns Return type int basename() Return the basename of the sequence. Returns sequence basename Return type str classmethod conformPadding(chars, pad_style=<PAD_STYLE: HASH4>) Ensure alternate input padding formats are conformed to formats defined in PAD_MAP If chars is already a format defined in PAD_MAP, then it is returned unmodified. Example:: ‘#’ -> ‘#’ ‘@@@@’ -> ‘@@@@’ ‘%04d’ -> ‘#’ Parameters • chars (str) – input padding chars • pad_style (.PAD_STYLE_DEFAULT or .PAD_STYLE_HASH1 or .PAD_STYLE_HASH4) – padding style Returns conformed padding chars Return type str Raises ValueError – If chars contains invalid padding characters copy() Create a deep copy of this sequence Returns Return type FileSequence decimalPlaces() Returns the number of decimal places to output. Returns Return type int or None dirname() Return the directory name of the sequence. Returns Return type str 8 Chapter 3. fileseq.filesequence module Fileseq Documentation, Release 1.13.1 end() Returns the end frame of the sequences FrameSet. Will return 0 if the sequence has no frame pattern. Returns Return type int extension() Return the file extension of the sequence, including leading period. Returns Return type str classmethod findSequenceOnDisk(pattern, strictPadding=False, pad_style=<PAD_STYLE: HASH4>, allow_subframes=False) Search for a specific sequence on disk. The padding characters used in the pattern are used to filter the frame values of the files on disk (if strictPadding is True). Examples Find sequence matching basename and extension, and a wildcard for any frame. returns bar.1.exr bar.10.exr, bar.100.exr, bar.1000.exr, inclusive FileSequence.findSequenceOnDisk("seq/bar@@@@.exr") Find exactly 4-padded sequence, i.e. seq/bar1-100#.exr returns only frames bar1000.exr through bar9999.exr FileSequence.findSequenceOnDisk("seq/bar#.exr", strictPadding=True) Parameters • pattern (str) – the sequence pattern being searched for • strictPadding (bool) – if True, ignore files with padding length different from pat- tern • pad_style (.PAD_STYLE_DEFAULT or .PAD_STYLE_HASH1 or .PAD_STYLE_HASH4) – padding style • allow_subframes (bool) – if True, handle subframe filenames Returns Return type FileSequence Raises FileSeqException – if no sequence is found on disk classmethod findSequencesInList(paths, pad_style=<PAD_STYLE: HASH4>, al- low_subframes=False) Returns the list of discrete sequences within paths. This does not try to determine if the files actually exist on disk, it assumes you already know that. Parameters • paths (list[str]) – a list of paths • pad_style (.PAD_STYLE_DEFAULT or .PAD_STYLE_HASH1 or .PAD_STYLE_HASH4) – padding style • allow_subframes (bool) – if True, handle subframe filenames Returns 9 Fileseq Documentation, Release 1.13.1 Return type list classmethod findSequencesOnDisk(pattern, include_hidden=False, strictPadding=False, pad_style=<PAD_STYLE: HASH4>, al- low_subframes=False) Yield the sequences found in the given directory. Examples: FileSequence.findSequencesOnDisk('/path/to/files') The pattern can also specify glob-like shell wildcards including the following: • ? - 1 wildcard character • * - 1 or more wildcard character • {foo,bar} - either ‘foo’ or ‘bar’ Exact frame ranges are not considered, and padding characters are converted to wildcards (# or @) Examples: FileSequence.findSequencesOnDisk('/path/to/files/image_stereo_{left,right}.#.
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages37 Page
-
File Size-