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

class MediaTagCombinator():

    IDENTIFIER = 'mediaTag'

    def __init__(self, context = None):
        self._context = context
        self._logger = context['logger']
        self._reportLogger = context['report_logger']

    def getIdentifier(self):
        return MediaTagCombinator.IDENTIFIER

    @staticmethod    
    def list():
        basePath = os.path.dirname(__file__)
        return [os.path.basename(p)[21:-3]
                for p
                in glob.glob(f"{ basePath }/media_tag_combinator_*.py", recursive = True)
                if p != __file__]

    @staticmethod
    def getClassReference(identifier):
        module_name = f"tests.legacy.media_tag_combinator_{ identifier }"
        importlib.import_module(module_name)
        for name, obj in inspect.getmembers(sys.modules[module_name]):
            #HINT: Excluding MediaCombinator as it seems to be included by import (?)
            if inspect.isclass(obj) and name != 'MediaTagCombinator' and name.startswith('MediaTagCombinator'):
                return obj

    @staticmethod
    def getAllClassReferences():
        return [MediaTagCombinator.getClassReference(i) for i in MediaTagCombinator.list()]
