Пример #1
0
    def _build_frange_part(start, stop, stride, zfill=0):
        """
        Private method: builds a proper and padded
        :class:`fileseq.framerange.FrameRange` string.

        :type start: int
        :param start: first frame
        :type stop: int
        :param stop: last frame
        :type stride: int
        :param stride: increment
        :type zfill: int
        :param zfill: width for zero padding
        :rtype: str
        """
        if stop is None:
            return ''
        pad_start = pad(start, zfill)
        pad_stop = pad(stop, zfill)
        if stride is None or start == stop:
            return '{0}'.format(pad_start)
        elif abs(stride) == 1:
            return '{0}-{1}'.format(pad_start, pad_stop)
        else:
            return '{0}-{1}x{2}'.format(pad_start, pad_stop, stride)
Пример #2
0
    def _build_frange_part(start, stop, stride, zfill=0):
        """
        Private method: builds a proper and padded
        :class:`fileseq.framerange.FrameRange` string.

        :type start: int
        :param start: first frame
        :type stop: int
        :param stop: last frame
        :type stride: int
        :param stride: increment
        :type zfill: int
        :param zfill: width for zero padding
        :rtype: str
        """
        if stop is None:
            return ''
        pad_start = pad(start, zfill)
        pad_stop = pad(stop, zfill)
        if stride is None or start == stop:
            return '{0}'.format(pad_start)
        elif abs(stride) == 1:
            return '{0}-{1}'.format(pad_start, pad_stop)
        else:
            return '{0}-{1}x{2}'.format(pad_start, pad_stop, stride)
Пример #3
0
 def _do_pad(match):
     """
     Substitutes padded for unpadded frames.
     """
     result = list(match.groups())
     result[1] = pad(result[1], zfill)
     if result[4]:
         result[4] = pad(result[4], zfill)
     return ''.join((i for i in result if i))
Пример #4
0
 def _do_pad(match):
     """
     Substitutes padded for unpadded frames.
     """
     result = list(match.groups())
     result[1] = pad(result[1], zfill)
     if result[4]:
         result[4] = pad(result[4], zfill)
     return ''.join((i for i in result if i))
Пример #5
0
        def _do_pad(match):
            """
            Substitutes padded for unpadded frames.
            """
            result = list(match.groups())

            neg, start = result[:2]
            result[:2] = [pad(neg+start, zfill, decimal_places)]

            neg, end = result[2:4]
            if end:
                result[2:4] = [pad(neg+end, zfill, decimal_places)]

            return ''.join((i for i in result if i))
Пример #6
0
    def framesToFrameRange(frames, sort=True, zfill=0, compress=False):
        """
        Converts an iterator of frames into a
        :class:`fileseq.framerange.FrameRange`.

        :type frames: iterable
        :param frames: sequence of frames to process
        :type sort: bool
        :param sort: sort the sequence before processing
        :type zfill: int
        :param zfill: width for zero padding
        :type compress: bool
        :param compress: remove any duplicates before processing
        :rtype: str
        """
        if compress:
            frames = unique(set(), frames)
        frames = list(frames)
        if not frames:
            return ''
        if len(frames) == 1:
            return pad(frames[0], zfill)
        if sort:
            frames.sort()
        return ','.join(FrameSet.framesToFrameRanges(frames, zfill))
Пример #7
0
    def framesToFrameRange(frames, sort=True, zfill=0, compress=False):
        """
        Converts an iterator of frames into a
        frame range string.

        Args:
            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:
            str:
        """
        if compress:
            frames = unique(set(), frames)
        frames = list(frames)
        if not frames:
            return ''
        if len(frames) == 1:
            return pad(frames[0], zfill)
        if sort:
            frames.sort()
        ret = ','.join(FrameSet.framesToFrameRanges(frames, zfill))
        return futils.native_str(ret)
Пример #8
0
    def framesToFrameRange(frames, sort=True, zfill=0, compress=False):
        """
        Converts an iterator of frames into a
        :class:`fileseq.framerange.FrameRange`.

        :type frames: iterable
        :param frames: sequence of frames to process
        :type sort: bool
        :param sort: sort the sequence before processing
        :type zfill: int
        :param zfill: width for zero padding
        :type compress: bool
        :param compress: remove any duplicates before processing
        :rtype: str
        """
        if compress:
            frames = unique(set(), frames)
        frames = list(frames)
        if not frames:
            return ''
        if len(frames) == 1:
            return pad(frames[0], zfill)
        if sort:
            frames.sort()
        return ','.join(FrameSet.framesToFrameRanges(frames, zfill))
Пример #9
0
 def _build_frange_part(start, stop, stride, zfill=0):
     """
     Private method: builds a proper and padded FrameRange string.
     :param start: first frame (int)
     :param stop: last frame (int)
     :param stride: increment (int)
     :param zfill: width for zero padding (int)
     :return: str
     """
     if stop is None:
         return ''
     pad_start = pad(start, zfill)
     pad_stop = pad(stop, zfill)
     if stride is None or start == stop:
         return '{0}'.format(pad_start)
     elif abs(stride) == 1:
         return '{0}-{1}'.format(pad_start, pad_stop)
     else:
         return '{0}-{1}x{2}'.format(pad_start, pad_stop, stride)
Пример #10
0
    def _build_frange_part(start, stop, stride, zfill=0):
        """
        Private method: builds a proper and padded frame range string.

        Args:
            start (int): first frame
            stop (int or None): last frame
            stride (int or None): increment
            zfill (int): width for zero padding

        Returns:
            str:
        """
        if stop is None:
            return ''
        pad_start = pad(start, zfill)
        pad_stop = pad(stop, zfill)
        if stride is None or start == stop:
            return '{0}'.format(pad_start)
        elif abs(stride) == 1:
            return '{0}-{1}'.format(pad_start, pad_stop)
        else:
            stride = normalizeFrame(stride)
            return '{0}-{1}x{2}'.format(pad_start, pad_stop, stride)
Пример #11
0
    def _build_frange_part(start, stop, stride, zfill=0):
        """
        Private method: builds a proper and padded
        frame range string.

        Args:
            start (int): first frame
            stop (int or None): last frame
            stride (int or None): increment
            zfill (int): width for zero padding

        Returns:
            str:
        """
        if stop is None:
            return u''
        pad_start = pad(start, zfill)
        pad_stop = pad(stop, zfill)
        if stride is None or start == stop:
            return u'{0}'.format(pad_start)
        elif abs(stride) == 1:
            return u'{0}-{1}'.format(pad_start, pad_stop)
        else:
            return u'{0}-{1}x{2}'.format(pad_start, pad_stop, stride)
Пример #12
0
 def framesToFrameRange(frames, sort=True, zfill=0, compress=False):
     """
     Converts an iterator of frames into a FrameRange.
     :param frames: sequence of frames to process (iter)
     :param sort: sort the sequence before processing (bool)
     :param zfill: width for zero padding (int)
     :param compress: remove any duplicates before processing (bool)
     :return: str
     """
     if compress:
         frames = unique(set(), frames)
     frames = list(frames)
     if not frames:
         return ''
     if len(frames) == 1:
         return pad(frames[0], zfill)
     if sort:
         frames.sort()
     return ','.join(FrameSet.framesToFrameRanges(frames, zfill))
Пример #13
0
    def frame(self, 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'

        Args:
            frame (int, float, decimal.Decimal or str): the desired frame number
                or a char to pass through (ie. #)

        Returns:
            str:
        """
        if self._zfill == 0:
            # There may have been no placeholder for frame IDs in
            # the sequence, in which case we don't want to insert
            # a frame ID
            zframe = ""
        else:
            zframe = None
            if not isinstance(frame, futils.integer_types +
                              (float, decimal.Decimal)):
                try:
                    frame = int(frame)
                except ValueError:
                    try:
                        frame = decimal.Decimal(frame)
                    except decimal.DecimalException:
                        zframe = frame
            if zframe is None:
                zframe = utils.pad(frame, self._zfill, self._decimal_places)

        return futils.native_str("".join(
            (self._dir, self._base, zframe, self._ext)))
Пример #14
0
    def framesToFrameRange(frames, sort=True, zfill=0, compress=False):
        """
        Converts an iterator of frames into a
        frame range string.

        Args:
            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:
            str:
        """
        if compress:
            frames = unique(set(), frames)
        frames = list(frames)
        if not frames:
            return u''
        if len(frames) == 1:
            return pad(frames[0], zfill)
        if sort:
            frames.sort()
        return u','.join(FrameSet.framesToFrameRanges(frames, zfill))