Example #1
0
def format_seq(seq, format_string, fps, tc_start, index):
    """ takes in seq and formats it based on format string """

    ret = []

    seq_len = seq.frame_amount()
    head = seq.head
    tail = seq.tail
    seq_name = str(seq)

    for clip in seq.clips:

        start = clip["start"]
        end = clip["end"]
        padding = clip["padding"]
        increment = clip["increment"]
        clip_name = Filesequence(head, [clip], tail).export()
        clip_len = Filesequence.get_clip_len(
            seq, clip
        )  # running helper function from inside object passing objects data to it!

        subst = subst_strings(
            format_string,
            fps,
            tc_start,
            seq_name,
            clip_name,
            head,
            tail,
            start,
            end,
            padding,
            increment,
            seq_len,
            clip_len,
            index,
        )

        ret_string = substitute_wildcards(format_string, subst)

        # If custom format returns similar results for many clips in a sequence output only one
        # This can happen if format is for example print total length of sequence "%L"
        try:
            if ret[-1] != ret_string:
                ret.append(ret_string)
        except IndexError:
            ret.append(ret_string)

    return ret