示例#1
0
def merge(a, b):
	""" take in two sequences and return combined version if they fit together
		eats errors incase of 'None' input or strings """

	ret = Filesequence("", [], "")

	if compare_seqs(a, b):
			ret.head = a.head
			ret.tail = b.tail

			ret.clips = a.clips + b.clips

			return ret
	else:
		return None
示例#2
0
def stringtofs(s):
	""" takes in string and tries to return Filesequence object, most of the heavylifting is done by the object itself. Input might be messy so 
		we have fallback to returning pure strings (single files not part of filesequence)
		This wrapper is needed because we support two string definitions. a simple string and mapped string in format seq1 -> seq2 """

	splitted_s = s.split(' -> ')
	if len(splitted_s) > 1:
		
		try:
			original = Filesequence.from_string(splitted_s[0])
		except ValueError:
			original = splitted_s[0]
		try:
			modified = Filesequence.from_string(splitted_s[1])
		except ValueError:
			modified = splitted_s[1]	
		return original, modified
	else:
		try:
			return None, Filesequence.from_string(s)
		except:
			return None, s
示例#3
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
示例#4
0
def single_seq(s, negative=False):
	""" takes in single string and tries to force it to one frame seq.
		This means that sequence has at least some digits
		Taking the ugly way out and using Filesequence object from_string constructor to figure out sequence formatting """

	splitted = split_alphanum(s, negative)

	matched = None
	modified = []

	for item in splitted[::-1]: # note reversed list
		if not matched and re.match('.*\d+', item): # item contains digits and can start with -
			matched = 1
			item = '[' + item + '-' + item + (len(item) * '@') + ']'
		modified.append(item) 

	modified.reverse()

	try:
		return [Filesequence.from_string(''.join(modified))]
	except:
		return None