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")

Format Path for VFX Software Using FileSequence.format Method

>>> seq= FileSequence("/foo/bar.1-10#.exr") >>> seq.format(template='{}{}{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 >>> 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). : 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=, 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 = {'#': {: 1, : 4}, '@': {: 1, : 1}} REVERSE_PAD_MAP = {: {1: '#'}, : {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=) 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=, 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=, 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=, 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}.#.

˓→jpg') FileSequence.findSequencesOnDisk('/path/to/files/imag?_*_{left,right}.@@@.jpg ˓→', strictPadding=True)

Parameters • pattern (str) – directory to scan, or pattern to filter in directory • include_hidden (bool) – if true, show .hidden files as well • 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 list

format(template=’{basename}{range}{padding}{extension}’) Return the file sequence as a formatted string according to the given template. Utilizes the python string format syntax. Available keys include: • basename - the basename of the sequence. • range - the range of the sequence • padding - the detecting amount of padding. • extension - the file extension of the sequence. • start - the start frame. • end - the end frame. • length - the length of the frame range.

10 Chapter 3. fileseq.filesequence module Fileseq Documentation, Release 1.13.1

• inverted - the inverted frame range. (returns “” if none) • dirname - the directory name. If asking for the inverted range value, and the new inverted range exceeded fileseq.constants. MAX_FRAME_SIZE, a MaxSizeException will be raised. Parameters template (str)– Returns Return type str Raises • fileseq.exceptions.MaxSizeException – If frame size exceeds • fileseq.constants.MAX_FRAME_SIZE‘ frame(frame) Return a path for the given frame in the sequence. Numeric values or numeric strings are treated as a frame number and padding is applied, all other values are passed though.

Examples

>>> seq= FileSequence('/foo/bar.1-10#.exr') >>> seq.frame(1) '/foo/bar.0001.exr' >>> seq.frame("#") '/foo/bar.#.exr'

Parameters frame (int, float, decimal.Decimal or str) – the desired frame number or a char to pass through (ie. #) Returns Return type str framePadding() Return the the padding characters in the sequence. Returns sequence padding Return type str frameRange() Returns the string formatted frame range of the sequence. Will return an empty string if the sequence has no frame pattern. Returns Return type str frameSet() Return the FrameSet of the sequence if specified, otherwise None. Returns Return type FrameSet or None classmethod from_dict(state) Constructor to create a new sequence object from a state that was previously returned by FileSequence.to_dict()

11 Fileseq Documentation, Release 1.13.1

Parameters state (dict) – state returned from FileSequence.to_dict() Returns FileSequence classmethod getPaddingChars(num, pad_style=) Given a particular amount of padding, return the proper padding characters. Parameters • num (int) – required width of string with padding • pad_style (.PAD_STYLE_DEFAULT or .PAD_STYLE_HASH1 or .PAD_STYLE_HASH4) – padding style Returns Return type str classmethod getPaddingNum(chars, pad_style=) Given a supported group of padding characters, return the amount of padding. Parameters • chars (str) – a supported group of padding characters • pad_style (.PAD_STYLE_DEFAULT or .PAD_STYLE_HASH1 or .PAD_STYLE_HASH4) – padding style Returns Return type int Raises ValueError – if unsupported padding character is detected index(idx) Return the path to the file at the given index. Parameters idx (int) – the desired index Returns Return type str invertedFrameRange() Returns the inverse string formatted frame range of the sequence. Will return an empty string if the sequence has no frame pattern, or the frame range includes subframes. Returns Return type str Raises fileseq.exceptions.MaxSizeException – If new inverted range exceeded fileseq.constants.MAX_FRAME_SIZE padStyle() Return the the padding style of the sequence. See fileseq.constants.PAD_STYLE_HASH1 and file- seq.constants.PAD_STYLE_HASH4 Returns padding style Return type (.PAD_STYLE_DEFAULT or .PAD_STYLE_HASH1 or .PAD_STYLE_HASH4) padding() Return the the padding characters in the sequence. Returns sequence padding Return type str

12 Chapter 3. fileseq.filesequence module Fileseq Documentation, Release 1.13.1 setBasename(base) Set a new basename for the sequence. Parameters base (str) – the new base name setDirname(dirname) Set a new directory name for the sequence. Parameters dirname (str) – the new directory name setExtension(ext) Set a new file extension for the sequence.

Note: A leading period will be added if none is provided.

Parameters ext (str) – the new file extension setExtention(ext) Deprecated: use setExtension(). Parameters ext (str)– setFramePadding(padding) Set new padding characters for the frames of the sequence. i.e. “#” or “@@@” or ‘%04d’, or an empty string to disable range formatting. Parameters padding (str) – sequence padding to set setFrameRange(frange) Set a new frame range for the sequence. Parameters frange (str) – a properly formatted frame range, as per FrameSet setFrameSet(frameSet) Set a new FrameSet for the sequence. Parameters frameSet (FrameSet) – the new FrameSet object setPadStyle(pad_style) Set new padding style for the sequence. See fileseq.constants.PAD_STYLE_HASH1 and file- seq.constants.PAD_STYLE_HASH4 Parameters pad_style (.PAD_STYLE_DEFAULT or .PAD_STYLE_HASH1 or .PAD_STYLE_HASH4) – padding style to set setPadding(padding) Set new padding characters for the sequence. i.e. “#” or “@@@” or ‘%04d’, or an empty string to disable range formatting. Parameters padding (str) – sequence padding to set setSubframePadding(padding) Set new padding characters for the subframes in the sequence. i.e. “#” or “@@@”, or an empty string to disable range formatting. Parameters padding (str) – sequence padding to set () Split the FileSequence into contiguous pieces and return them as a list of FileSequence instances. Returns

13 Fileseq Documentation, Release 1.13.1

Return type list[FileSequence] start() Returns the start frame of the sequence’s FrameSet. Will return 0 if the sequence has no frame pattern. Returns Return type int subframePadding() Return the the padding characters for subframes in the sequence. Returns sequence padding Return type str to_dict() Convert sequence object into a state dict that is suitable for further serialization, such as to JSON Returns state of the current sequence object Return type dict classmethod yield_sequences_in_list(paths, using=None, pad_style=, allow_subframes=False) Yield the discrete sequences within paths. This does not try to determine if the files actually exist on disk, it assumes you already know that. A template FileSequence object can also be provided via the using parameter. Given this template, the dirname, basename, and extension values will be used to extract the frame value from the paths instead of parsing each path from scratch.

Examples

The using field can supply a template for extracting the frame component from the paths:

paths=[ '/dir/file_001.0001.ext', '/dir/file_002.0001.ext', '/dir/file_003.0001.ext', ] template= FileSequence('/dir/file_#.0001.ext') seqs= FileSequence.yield_sequences_in_list(paths, using) # []

Parameters • paths (list[str]) – a list of paths • using (FileSequence) – Optional sequence to use as template • pad_style (.PAD_STYLE_DEFAULT or .PAD_STYLE_HASH1 or .PAD_STYLE_HASH4) – padding style • allow_subframes (bool) – if True, handle subframe filenames Yields FileSequence

zfill() Returns the zfill depth (ie the number of zeroes to pad with). Returns

14 Chapter 3. fileseq.filesequence module Fileseq Documentation, Release 1.13.1

Return type int

15 Fileseq Documentation, Release 1.13.1

16 Chapter 3. fileseq.filesequence module CHAPTER 4

fileseq.frameset module

frameset - A set-like object representing a frame range for fileseq. class fileseq.frameset.FrameSet(frange) Bases: _abcoll.Set A FrameSet is an immutable representation of the ordered, unique set of frames in a given frame range. The frame range can be expressed in the following ways: • 1-5 • 1-5,10-20 • 1-100x5 (every fifth frame) • 1-100y5 (opposite of above, fills in missing frames) • 1-100:4 (same as 1-100x4,1-100x3,1-100x2,1-100) • 1-2x0.333333 (subframes) A FrameSet is effectively an ordered frozenset, with FrameSet-returning versions of frozenset methods:

>>> FrameSet('1-5').union(FrameSet('5-10')) FrameSet("1-10") >>> FrameSet('1-5').intersection(FrameSet('5-10')) FrameSet("5")

Because a FrameSet is hashable, it can be used as the key to a dictionary:

>>> d= {FrameSet("1-20"):'good'}

A FrameSet can be created from an iterable of frame numbers, and will construct an appropriate string repre- sentation:

>>> FrameSet([1,2,3,4,5]).frange '1-5' (continues on next page)

17 Fileseq Documentation, Release 1.13.1

(continued from previous page) >>> FrameSet([0,'0.1429','0.2857','0.4286','0.5714','0.7143','0.8571',1]).

˓→frange '0-1x0.142857'

Caveats: 1. Because the internal storage of a FrameSet contains the discreet values of the entire range, an exception will be thrown if the range exceeds a large reasonable limit, which could lead to huge memory allocations or memory failures. See fileseq.constants.MAX_FRAME_SIZE. 2. All frozenset operations return a normalized FrameSet: internal frames are in numerically increas- ing order. 3. Equality is based on the contents and order, NOT the frame range string (there are a finite, but poten- tially extremely large, number of strings that can represent any given range, only a “best guess” can be made). 4. Human-created frame ranges (ie 1-100x5) will be reduced to the actual internal frames (ie 1-96x5). 5. The “null” Frameset (FrameSet('')) is now a valid thing to create, it is required by set op- erations, but may cause confusion as both its start and end methods will raise IndexError. The is_null() property allows you to guard against this.

Parameters (str or FrameSet or collections.Iterable of str, int, float, or (frange) – decimal.Decimal): the frame range as a string (ie “1-100x5”) or iterable of frame numbers. Raises • ParseException – if the frame range (or a portion of it) could not be parsed. • fileseq.exceptions.MaxSizeException – if the range exceeds fileseq. constants.MAX_FRAME_SIZE

FRANGE_RE = <_sre.SRE_Pattern object> PAD_MAP = {'#': {: 1, : 4}, '@': {: 1, : 1}} PAD_RE = <_sre.SRE_Pattern object> __and__(other) Overloads the & operator. Returns a new FrameSet that holds only the frames self and other have in common.

Note: The order of operations is irrelevant: (self & other) == (other & self)

Parameters other (FrameSet)– Returns NotImplemented: if other fails to convert to a FrameSet Return type FrameSet

__contains__(item) Check if item is a member of this FrameSet. Parameters item (int) – the frame number to check for Returns

18 Chapter 4. fileseq.frameset module Fileseq Documentation, Release 1.13.1

Return type bool __eq__(other) Check if self == other via a comparison of the hash of their contents. If other is not a FrameSet, but is a set, frozenset, or is iterable, it will be cast to a FrameSet. Parameters other (FrameSet) – Also accepts an object that can be cast to a FrameSet Returns NotImplemented: if other fails to convert to a FrameSet Return type bool __ge__(other) Check if self >= other via a comparison of the contents. If other is not a FrameSet, but is a set, frozenset, or is iterable, it will be cast to a FrameSet. Parameters other (FrameSet) – Also accepts an object that can be cast to a FrameSet Returns NotImplemented: if other fails to convert to a FrameSet Return type bool __getitem__(index) Allows indexing into the ordered frames of this FrameSet. Parameters index (int) – the index to retrieve Returns Return type int Raises IndexError – if index is out of bounds __getstate__() Allows for serialization to a pickled FrameSet. Returns (frame range string, ) Return type tuple __gt__(other) Check if self > other via a comparison of the contents. If other is not a FrameSet, but is a set, frozenset, or is iterable, it will be cast to a FrameSet.

Note: A FrameSet is greater than other if the set of its contents are greater, OR if the contents are equal but the order is greater.

Listing 1: Same contents, but (1,2,3,4,5) sorts below (5,4,3,2,1) >>> FrameSet("1-5")> FrameSet("5-1") False

Parameters other (FrameSet) – Also accepts an object that can be cast to a FrameSet Returns NotImplemented: if other fails to convert to a FrameSet Return type bool

__hash__() Builds the hash of this FrameSet for equality checking and to allow use as a dictionary key. Returns

19 Fileseq Documentation, Release 1.13.1

Return type int __iter__() Allows for iteration over the ordered frames of this FrameSet. Returns Return type generator __le__(other) Check if self <= other via a comparison of the contents. If other is not a FrameSet, but is a set, frozenset, or is iterable, it will be cast to a FrameSet. Parameters other (FrameSet) – Also accepts an object that can be cast to a FrameSet Returns NotImplemented: if other fails to convert to a FrameSet Return type bool __len__() Returns the length of the ordered frames of this FrameSet. Returns Return type int __lt__(other) Check if self < other via a comparison of the contents. If other is not a FrameSet, but is a set, frozenset, or is iterable, it will be cast to a FrameSet.

Note: A FrameSet is less than other if the set of its contents are less, OR if the contents are equal but the order of the items is less.

Listing 2: Same contents, but (1,2,3,4,5) sorts below (5,4,3,2,1) >>> FrameSet("1-5")< FrameSet("5-1") True

Parameters other (FrameSet) – Can also be an object that can be cast to a FrameSet Returns NotImplemented: if other fails to convert to a FrameSet Return type bool

__ne__(other) Check if self != other via a comparison of the hash of their contents. If other is not a FrameSet, but is a set, frozenset, or is iterable, it will be cast to a FrameSet. Parameters other (FrameSet) – Also accepts an object that can be cast to a FrameSet Returns NotImplemented: if other fails to convert to a FrameSet Return type bool __or__(other) Overloads the | operator. Returns a new FrameSet that holds all the frames in self, other, or both.

Note: The order of operations is irrelevant: (self | other) == (other | self)

20 Chapter 4. fileseq.frameset module Fileseq Documentation, Release 1.13.1

Parameters other (FrameSet)– Returns NotImplemented: if other fails to convert to a FrameSet Return type FrameSet

__rand__(other) Overloads the & operator. Returns a new FrameSet that holds only the frames self and other have in common.

Note: The order of operations is irrelevant: (self & other) == (other & self)

Parameters other (FrameSet)– Returns NotImplemented: if other fails to convert to a FrameSet Return type FrameSet

__repr__() Returns a long-form representation of this FrameSet. Returns Return type str __reversed__() Allows for reversed iteration over the ordered frames of this FrameSet. Returns Return type generator __ror__(other) Overloads the | operator. Returns a new FrameSet that holds all the frames in self, other, or both.

Note: The order of operations is irrelevant: (self | other) == (other | self)

Parameters other (FrameSet)– Returns NotImplemented: if other fails to convert to a FrameSet Return type FrameSet

__rsub__(other) Overloads the - operator. Returns a new FrameSet that holds only the frames of other that are not in self.

Note: This is for right-hand subtraction (other - self).

Parameters other (FrameSet)– Returns NotImplemented: if other fails to convert to a FrameSet Return type FrameSet

21 Fileseq Documentation, Release 1.13.1

__rxor__(other) Overloads the ^ operator. Returns a new FrameSet that holds all the frames in self or other but not both.

Note: The order of operations is irrelevant: (self ^ other) == (other ^ self)

Parameters other (FrameSet)– Returns NotImplemented: if other fails to convert to a FrameSet Return type FrameSet

__setstate__(state) Allows for de-serialization from a pickled FrameSet. Parameters state (tuple or str or dict) – A string/dict can be used for backwards compatibility Raises ValueError – if state is not an appropriate type __str__() __sub__(other) Overloads the - operator. Returns a new FrameSet that holds only the frames of self that are not in other.

Note: This is for left-hand subtraction (self - other).

Parameters other (FrameSet)– Returns NotImplemented: if other fails to convert to a FrameSet Return type FrameSet

__xor__(other) Overloads the ^ operator. Returns a new FrameSet that holds all the frames in self or other but not both.

Note: The order of operations is irrelevant: (self ^ other) == (other ^ self)

Parameters other (FrameSet)– Returns NotImplemented: if other fails to convert to a FrameSet Return type FrameSet

copy() Create a deep copy of this FrameSet. Returns Return type FrameSet difference(*other) Returns a new FrameSet with elements in self but not in other. Parameters other (FrameSet) – or objects that can cast to FrameSet Returns

22 Chapter 4. fileseq.frameset module Fileseq Documentation, Release 1.13.1

Return type FrameSet end() The last frame in the FrameSet. Returns Return type int Raises IndexError – (with the empty FrameSet) frame(index) Return the frame at the given index. Parameters index (int) – the index to find the frame for Returns Return type int Raises IndexError – if index is out of bounds frameRange(zfill=0, decimal_places=None) Return the frame range used to create this FrameSet, padded if desired.

Examples

>>> FrameSet('1-100').frameRange() '1-100' >>> FrameSet('1-100').frameRange(5) '00001-00100' >>> FrameSet('1-100').frameRange(0,1) '1.0-100.0' >>> FrameSet('1.0-100.0').frameRange() '1.0-100.0'

Parameters • zfill (int) – the width to use to zero-pad the frame range string • decimal_places (int or None) – the number of decimal places to use in frame range string Returns Return type str static framesToFrameRange(frames, =True, zfill=0, compress=False) Converts an iterator of frames into a frame range string. Parameters • frames (collections.Iterable) – sequence of frames to process • sort (bool) – sort the sequence before processing • zfill (int) – width for zero padding • compress (bool) – remove any duplicates before processing Returns Return type str

23 Fileseq Documentation, Release 1.13.1

static framesToFrameRanges(frames, zfill=0) Converts a sequence of frames to a series of padded frame range strings. Parameters • frames (collections.Iterable) – sequence of frames to process • zfill (int) – width for zero padding Yields str frange Read-only access to the frame range used to create this FrameSet. Returns Return type str classmethod from_iterable(frames, sort=False) Build a FrameSet from an iterable of frames. Parameters • frames (collections.Iterable) – an iterable object containing frames as integers • sort (bool) – True to sort frames before creation, default is False Returns Return type FrameSet classmethod from_range(start, end, step=1) Build a FrameSet from given start and end frames. Parameters • start (int) – The first frame of the FrameSet. • end (int) – The last frame of the FrameSet. • step (int, optional) – Range step (default 1). Returns Return type FrameSet hasFrame(frame) Check if the FrameSet contains the frame or subframe Parameters frame (int) – the frame number to search for Returns Return type bool hasSubFrames() Check if the FrameSet contains any subframes Returns Return type bool index(frame) Return the index of the given frame number within the FrameSet. Parameters frame (int) – the frame number to find the index for Returns

24 Chapter 4. fileseq.frameset module Fileseq Documentation, Release 1.13.1

Return type int Raises ValueError – if frame is not in self intersection(*other) Returns a new FrameSet with the elements common to self and other. Parameters other (FrameSet) – or objects that can cast to FrameSet Returns Return type FrameSet invertedFrameRange(zfill=0, decimal_places=None) Return the inverse of the FrameSet ‘s frame range, padded if desired. The inverse is every frame within the full extent of the range.

Examples

>>> FrameSet('1-100x2').invertedFrameRange() '2-98x2' >>> FrameSet('1-100x2').invertedFrameRange(5) '00002-00098x2'

If the inverted frame size exceeds fileseq.constants.MAX_FRAME_SIZE, a MaxSizeException will be raised. Parameters • zfill (int) – the width to use to zero-pad the frame range string • decimal_places (int or None) – the number of decimal places to use in frame range string Returns Return type str Raises fileseq.exceptions.MaxSizeException isConsecutive() Return whether the frame range represents consecutive integers, as opposed to having a stepping >= 2

Examples

>>> FrameSet('1-100').isConsecutive() True >>> FrameSet('1-100x2').isConsecutive() False >>> FrameSet('1-50,60-100').isConsecutive() False

Returns Return type bool classmethod isFrameRange(frange) Return True if the given string is a frame range. Any padding characters, such as ‘#’ and ‘@’ are ignored. Parameters frange (str) – a frame range to

25 Fileseq Documentation, Release 1.13.1

Returns Return type bool is_null Read-only access to determine if the FrameSet is the null or empty FrameSet. Returns Return type bool isdisjoint(other) Check if the contents of :class:self has no common intersection with the contents of :class:other. Parameters other (FrameSet)– Returns NotImplemented: if other fails to convert to a FrameSet Return type bool issubset(other) Check if the contents of self is a subset of the contents of other. Parameters other (FrameSet)– Returns NotImplemented: if other fails to convert to a FrameSet Return type bool issuperset(other) Check if the contents of self is a superset of the contents of other. Parameters other (FrameSet)– Returns NotImplemented: if other fails to convert to a FrameSet Return type bool items Read-only access to the unique frames that form this FrameSet. Returns Return type frozenset normalize() Returns a new normalized (sorted and compacted) FrameSet. Returns Return type FrameSet order Read-only access to the ordered frames that form this FrameSet. Returns Return type tuple classmethod padFrameRange(frange, zfill, decimal_places=None) Return the zero-padded version of the frame range string. Parameters • frange (str) – a frame range to test • zfill (int)– • decimal_places (int or None)–

26 Chapter 4. fileseq.frameset module Fileseq Documentation, Release 1.13.1

Returns Return type str start() The first frame in the FrameSet. Returns Return type int Raises IndexError – (with the empty FrameSet) symmetric_difference(other) Returns a new FrameSet that contains all the elements in either self or other, but not both. Parameters other (FrameSet)– Returns Return type FrameSet union(*other) Returns a new FrameSet with the elements of self and of other. Parameters other (FrameSet) – or objects that can cast to FrameSet Returns Return type FrameSet

27 Fileseq Documentation, Release 1.13.1

28 Chapter 4. fileseq.frameset module Python Module Index

f fileseq,1 fileseq.exceptions,5 fileseq.filesequence,7 fileseq.frameset, 17

29 Fileseq Documentation, Release 1.13.1

30 Python Module Index Index

Symbols method),8 __and__() (fileseq.frameset.FrameSet method), 18 __contains__() (fileseq.frameset.FrameSet method), C 18 conformPadding() (file- __eq__() (fileseq.frameset.FrameSet method), 19 seq.filesequence.FileSequence class method), __ge__() (fileseq.frameset.FrameSet method), 19 8 __getitem__() (fileseq.filesequence.FileSequence copy() (fileseq.filesequence.FileSequence method),8 method),7 copy() (fileseq.frameset.FrameSet method), 22 __getitem__() (fileseq.frameset.FrameSet method), 19 D __getstate__() (fileseq.frameset.FrameSet method), decimalPlaces() (fileseq.filesequence.FileSequence 19 method),8 __gt__() (fileseq.frameset.FrameSet method), 19 difference() (fileseq.frameset.FrameSet method), 22 __hash__() (fileseq.frameset.FrameSet method), 19 dirname() (fileseq.filesequence.FileSequence method), __iter__() (fileseq.filesequence.FileSequence 8 method),8 DISK_RE (fileseq.filesequence.FileSequence attribute),7 __iter__() (fileseq.frameset.FrameSet method), 20 DISK_SUB_RE (fileseq.filesequence.FileSequence at- __le__() (fileseq.frameset.FrameSet method), 20 tribute),7 __len__() (fileseq.filesequence.FileSequence method), 8 E __len__() (fileseq.frameset.FrameSet method), 20 end() (fileseq.filesequence.FileSequence method),8 __lt__() (fileseq.frameset.FrameSet method), 20 end() (fileseq.frameset.FrameSet method), 23 __ne__() (fileseq.frameset.FrameSet method), 20 extension() (fileseq.filesequence.FileSequence __or__() (fileseq.frameset.FrameSet method), 20 method),9 __rand__() (fileseq.frameset.FrameSet method), 21 __repr__() (fileseq.frameset.FrameSet method), 21 F __reversed__() (fileseq.frameset.FrameSet method), fileseq (module),1 21 fileseq.exceptions (module),5 __ror__() (fileseq.frameset.FrameSet method), 21 fileseq.filesequence (module),7 __rsub__() (fileseq.frameset.FrameSet method), 21 fileseq.frameset (module), 17 __rxor__() (fileseq.frameset.FrameSet method), 21 FileSeqException,5 __setstate__() (fileseq.frameset.FrameSet method), FileSequence (class in fileseq.filesequence),7 22 findSequenceOnDisk() (file- __str__() (fileseq.frameset.FrameSet method), 22 seq.filesequence.FileSequence class method), __sub__() (fileseq.frameset.FrameSet method), 22 9 __xor__() (fileseq.frameset.FrameSet method), 22 findSequencesInList() (file- seq.filesequence.FileSequence class method), B 9 basename() (fileseq.filesequence.FileSequence

31 Fileseq Documentation, Release 1.13.1

findSequencesOnDisk() (file- isFrameRange() (fileseq.frameset.FrameSet class seq.filesequence.FileSequence class method), method), 25 10 issubset() (fileseq.frameset.FrameSet method), 26 format() (fileseq.filesequence.FileSequence method), issuperset() (fileseq.frameset.FrameSet method), 26 10 items (fileseq.frameset.FrameSet attribute), 26 frame() (fileseq.filesequence.FileSequence method), 11 frame() (fileseq.frameset.FrameSet method), 23 M framePadding() (fileseq.filesequence.FileSequence MaxSizeException,5 method), 11 frameRange() (fileseq.filesequence.FileSequence N method), 11 normalize() (fileseq.frameset.FrameSet method), 26 frameRange() (fileseq.frameset.FrameSet method), 23 FrameSet (class in fileseq.frameset), 17 O frameSet() (fileseq.filesequence.FileSequence order (fileseq.frameset.FrameSet attribute), 26 method), 11 framesToFrameRange() (fileseq.frameset.FrameSet P static method), 23 PAD_MAP (fileseq.filesequence.FileSequence attribute),7 framesToFrameRanges() (file- PAD_MAP (fileseq.frameset.FrameSet attribute), 18 seq.frameset.FrameSet static method), 23 PAD_RE (fileseq.frameset.FrameSet attribute), 18 frange (fileseq.frameset.FrameSet attribute), 24 padding() (fileseq.filesequence.FileSequence method), FRANGE_RE (fileseq.frameset.FrameSet attribute), 18 12 from_dict() (fileseq.filesequence.FileSequence class padFrameRange() (fileseq.frameset.FrameSet class method), 11 method), 26 from_iterable() (fileseq.frameset.FrameSet class padStyle() (fileseq.filesequence.FileSequence method), 24 method), 12 from_range() (fileseq.frameset.FrameSet class ParseException,5 method), 24 R G REVERSE_PAD_MAP (fileseq.filesequence.FileSequence getPaddingChars() (file- attribute),7 seq.filesequence.FileSequence class method), 12 S getPaddingNum() (fileseq.filesequence.FileSequence setBasename() (fileseq.filesequence.FileSequence class method), 12 method), 12 setDirname() (fileseq.filesequence.FileSequence H method), 13 hasFrame() (fileseq.frameset.FrameSet method), 24 setExtension() (fileseq.filesequence.FileSequence hasSubFrames() (fileseq.frameset.FrameSet method), method), 13 24 setExtention() (fileseq.filesequence.FileSequence method), 13 I setFramePadding() (file- index() (fileseq.filesequence.FileSequence method), 12 seq.filesequence.FileSequence method), index() (fileseq.frameset.FrameSet method), 24 13 intersection() (fileseq.frameset.FrameSet method), setFrameRange() (fileseq.filesequence.FileSequence 25 method), 13 invertedFrameRange() (file- setFrameSet() (fileseq.filesequence.FileSequence seq.filesequence.FileSequence method), method), 13 12 setPadding() (fileseq.filesequence.FileSequence invertedFrameRange() (fileseq.frameset.FrameSet method), 13 method), 25 setPadStyle() (fileseq.filesequence.FileSequence is_null (fileseq.frameset.FrameSet attribute), 26 method), 13 isConsecutive() (fileseq.frameset.FrameSet setSubframePadding() (file- method), 25 seq.filesequence.FileSequence method), isdisjoint() (fileseq.frameset.FrameSet method), 26 13

32 Index Fileseq Documentation, Release 1.13.1

split() (fileseq.filesequence.FileSequence method), 13 SPLIT_RE (fileseq.filesequence.FileSequence attribute), 7 SPLIT_SUB_RE (fileseq.filesequence.FileSequence at- tribute),7 start() (fileseq.filesequence.FileSequence method), 14 start() (fileseq.frameset.FrameSet method), 27 subframePadding() (file- seq.filesequence.FileSequence method), 14 symmetric_difference() (file- seq.frameset.FrameSet method), 27 T to_dict() (fileseq.filesequence.FileSequence method), 14 U union() (fileseq.frameset.FrameSet method), 27 Y yield_sequences_in_list() (file- seq.filesequence.FileSequence class method), 14 Z zfill() (fileseq.filesequence.FileSequence method), 14

Index 33