How to use the fileseq.frameset.FrameSet function in Fileseq

To help you get started, we’ve selected a few Fileseq examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github justinfx / fileseq / src / fileseq / filesequence.py View on Github external
if placeholder in sequence:
                        msg = "Failed to parse FileSequence: {0}"
                        raise ParseException(msg.format(sequence))
                # edge case 2; we've got a single frame of a sequence
                a_frame = DISK_RE.match(sequence)
                if a_frame:
                    self._dir, self._base, frames, self._ext = a_frame.groups()
                    # edge case 3: we've got a single versioned file, not a sequence
                    if frames and not self._base.endswith('.'):
                        self._base = self._base + frames
                        self._pad = ''
                    elif not frames:
                        self._pad = ''
                        self._frameSet = None
                    else:
                        self._frameSet = FrameSet(frames)
                        if self._frameSet:
                            self._pad = FileSequence.getPaddingChars(len(frames))
                        else:
                            self._pad = ''
                            self._frameSet = None
                # edge case 4; we've got a solitary file, not a sequence
                else:
                    path, self._ext = os.path.splitext(sequence)
                    self._dir, self._base = os.path.split(path)
                    self._pad = ''

        if self._dir:
            self.setDirname(self._dir)

        self._zfill = self.__class__.getPaddingNum(self._pad)
github justinfx / fileseq / src / fileseq / filesequence.py View on Github external
Returns:
            str or :obj:`FileSequence`:

        Raises:
            :class:`IndexError`: If slice is outside the range of the sequence
        """
        if not self._frameSet:
            return utils.asString(self)

        frames = self._frameSet[idx]

        if not hasattr(idx, 'start'):
            return self.frame(frames)

        fset = FrameSet(frames)
        if fset.is_null:
            raise IndexError("slice is out of range and returns no frames")

        fs = self.copy()
        fs.setFrameSet(fset)
        return fs
github justinfx / fileseq / src / fileseq / __init__.py View on Github external
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 PARTICULAR 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 SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
"""
from __future__ import absolute_import

from fileseq.exceptions import ParseException, FileSeqException
from fileseq.frameset import FrameSet
from fileseq.filesequence import FileSequence

padFrameRange = FrameSet.padFrameRange
framesToFrameRange = FrameSet.framesToFrameRange

getPaddingChars = FileSequence.getPaddingChars
getPaddingNum = FileSequence.getPaddingNum
findSequencesInList = FileSequence.findSequencesInList
findSequenceOnDisk = FileSequence.findSequenceOnDisk
findSequencesOnDisk = FileSequence.findSequencesOnDisk
github justinfx / fileseq / src / fileseq / filesequence.py View on Github external
def setFrameRange(self, frange):
        """
        Set a new frame range for the sequence.

        Args:
            frange (str): a properly formatted frame range, as per :class:`.FrameSet`
        """
        self._frameSet = FrameSet(frange)
github justinfx / fileseq / src / fileseq / filesequence.py View on Github external
dirname, basename, frame, ext = match.groups()
            if not basename and not ext:
                continue
            key = (dirname, basename, ext)
            seqs.setdefault(key, set())
            if frame:
                seqs[key].add(frame)

        for (dirname, basename, ext), frames in iteritems(seqs):
            # build the FileSequence behind the scenes, rather than dupe work
            seq = FileSequence.__new__(FileSequence)
            seq._dir = dirname or ''
            seq._base = basename or ''
            seq._ext = ext or ''
            if frames:
                seq._frameSet = FrameSet(set(map(int, frames))) if frames else None
                seq._pad = FileSequence.getPaddingChars(min(map(len, frames)))
            else:
                seq._frameSet = None
                seq._pad = ''
            seq.__init__(utils.asString(seq))
            yield seq
github justinfx / fileseq / src / fileseq / __init__.py View on Github external
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 PARTICULAR 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 SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
"""
from __future__ import absolute_import

from fileseq.exceptions import ParseException, FileSeqException
from fileseq.frameset import FrameSet
from fileseq.filesequence import FileSequence

padFrameRange = FrameSet.padFrameRange
framesToFrameRange = FrameSet.framesToFrameRange

getPaddingChars = FileSequence.getPaddingChars
getPaddingNum = FileSequence.getPaddingNum
findSequencesInList = FileSequence.findSequencesInList
findSequenceOnDisk = FileSequence.findSequenceOnDisk
findSequencesOnDisk = FileSequence.findSequencesOnDisk