import os, sys, importlib, glob, inspect, itertools

from ffx.track_type import TrackType

from ffx.track_descriptor import TrackDescriptor
from ffx.media_descriptor import MediaDescriptor

from .media_tag_combinator import MediaTagCombinator


class MediaTagCombinator0(MediaTagCombinator):

    VARIANT = 'MT0'


    def __init__(self, context = None,
                    createPresets: bool = False):
        super().__init__(context)

        self.__createPresets = createPresets

    def getVariant(self):
        return MediaTagCombinator0.VARIANT


    def getPayload(self):
        mediaTags = {}
        if self.__createPresets:
            mediaTags['THIS_IS'] = 'FFX'
        return mediaTags


    def createAssertFunc(self):

        if self.__createPresets:

            def f(assertObj: dict = {}):

                if not 'tracks' in assertObj.keys():
                    raise KeyError("assertObj does not contain key 'tags'")
                mediaTags = assertObj['tags']

                assert ('THIS_IS' in mediaTags.keys() and mediaTags.keys()['THIS_IS'] == 'FFX'
                ), "Media tag 'THIS_IS' was not preserved"

        else:

            def f(assertObj: dict = {}):
                pass

        return f


    def shouldFail(self):
        return False
