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 MediaTagCombinator2(MediaTagCombinator):

    VARIANT = 'MT2'


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

        self.__createPresets = createPresets

    def getVariant(self):
        return MediaTagCombinator2.VARIANT


    def getPayload(self):
        mediaTags = {'To': 'Fanz',
                        'Yolo': 'Holo'}
        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 ('To' in mediaTags.keys()
                ), "'To' not in media tag keys"
                assert (mediaTags.keys()['To'] == 'Fanz'
                ), "Media tag value not 'Fanz' for key 'To'"
                assert ('Yolo' in mediaTags.keys()
                ), "'Yolo' not in media tag keys"
                assert (mediaTags.keys()['Yolo'] == 'Holo'
                ), "Media tag value not 'Holo' for key 'Yolo'"

                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
