# Path: skema/api.py
# class SkemaSuiteIf(object):
#     """
#     Skema test suite.
# 
#     Abstract class for skema test suite classes.
#     """
# 
#     @abstractmethod
#     def install(self):
#         """
#         Install the test suite.
# 
#         This creates an install directory under the user's XDG_DATA_HOME
#         directory to mark that the suite is installed.  The installer's
#         install() method is then called from this directory to complete any
#         test specific install that may be needed.
#         """
# 
#     @abstractmethod
#     def uninstall(self):
#         """
#         Uninstall the test suite.
# 
#         Uninstalling just recursively removes the test specific directory under
#         the user's XDG_DATA_HOME directory.  This will both mark the suite as
#         removed, and clean up any files that were installed under that
#         directory.  Dependencies are intentionally not removed by this.
#         """
# 
#     @abstractmethod
#     def run(self, quiet=False, output=None):
#         # TODO: Document me
#         pass
# 
#     @abstractmethod
#     def parse(self, resultname):
#         # TODO: Document me
#         pass
# 
# Path: skema/config.py
# def get_config():
#     global _config
#     if _config is not None:
#         return _config
#     _config = SkemaConfig()
#     return _config
# 
# Path: skema/suiteutils.py
# def run_suite(scriptpath):
# 
#     tree = et()
#     tree.parse(scriptpath)
#     titer = tree.iter()
# 
#     config = get_config()
# 
#     suites = []
#     cases = []
#     errors = dict()
#     last_tag = dict()
#     case = ""
#     for elem in titer:
# 
#         if elem.tag == "Suite":
#             continue
# 
#         if elem.tag == "Case":
#             case  = elem.get('name')
#             log_line ("Use Case : '%s'"  % case)
#             cases.append(case)
#             errors[case] = 0
#             result = 0
#             continue
# 
#         if result == 0:
#             tag_func = get_tag(elem.tag)
#             if not tag_func:
#                 log_line ("Tag '%s' not found. Exiting."  % elem.tag)
#                 sys.exit(1)
# 
#             result = tag_func.run(elem, config)
#             if result != 0:
#                 log_result (elem.tag, get_string_from_il_enum(result, "OMX_Error"))
#                 errors[case] = result
#             last_tag[case] = elem.tag
# 
#     if result != 0:
#         config.base_profile_mgr.stop()
# 
#     log_line()
#     log_line()
#     log_line("-------------------------------------------------------------------")
#     msg = "SUITE EXECUTION SUMMARY : " + str(len(cases)) + " test cases executed"
#     log_result (msg, get_string_from_il_enum(result, "OMX_Error"))
#     last_error = 0
#     for case in cases:
#         msg = "CASE : " + case + " (last tag was '" + last_tag[case] + "')"
#         log_result (msg, get_string_from_il_enum(errors[case], "OMX_Error"))
#         if errors[case] != 0:
#             last_error = errors[case]
#     log_line()
#     log_line("-------------------------------------------------------------------")
#     log_line()
# 
#     return last_error
# 
# Path: skema/utils.py
# def log_line(line="", tabs=0):
#     if (line == ""):
#         lansi = "[skema] "
#         l = ""
#     else:
#         l = ('\t' * tabs) + "[" + line + "]"
#         lansi = "[skema] " + bcolors.WARNING + l + bcolors.ENDC
#     logging.info(l)
#     printit (lansi)
# 
# Path: skema/utils.py
# def log_result(tag, err):
#     log_line ()
#     if (err == "OMX_ErrorNone"):
#         l = "[" + tag + " -> '" + err + "']"
#         lansi = "[skema] " + bcolors.OKGREEN + l + bcolors.ENDC
#         logging.info(l)
#     else:
#         l = "[" + tag + " -> '" + err + "']"
#         lansi = "[skema] " + bcolors.FAIL + l + bcolors.ENDC
#         logging.error(l)
# 
#     printit (lansi)
# 
# Path: skema/omxil12.py
# def get_string_from_il_enum(enum, hint):
#     from skema import omxil12
#     for name, val in omxil12.__dict__.iteritems():
#         if enum == val:
#             if name.startswith(hint):
#                 return name
#     raise AttributeError


import os
import glob
import re
import shutil
import time
import logging
from commands import getstatusoutput
from datetime import datetime
from uuid import uuid1
from skema.api import SkemaSuiteIf
from skema.config import get_config
from skema.suiteutils import run_suite
from skema.utils import log_line
from skema.utils import log_result
from skema.omxil12 import get_string_from_il_enum
    This can be used by test definition files to create an object that contains
    the building blocks for installing tests, running them, and parsing the
    results.

    suitename - name of the test suite
    version - version of the test suite
    installer - SkemaInstaller instance to use
    runner - SkemaRunner instance to use
    parser - SkemaParser instance to use
    """
    def __init__(self, suitename, version="", installer=None, runner=None,
                 parser=None):
        self.suitename = suitename
        self.version = version
        self.installer = installer
        self.runner = runner
        self.parser = parser
        self.origdir = os.path.abspath(os.curdir)

    def install(self):
        """Install the test suite.

        This creates an install directory under the user's XDG_DATA_HOME
        directory to mark that the test is installed.  The installer's
        install() method is then called from this directory to complete any
        test specific install that may be needed.
        """
        if not self.installer:
            raise RuntimeError("no installer defined for '%s'" %
                                self.suitename)

# Path: skema/api.py
# class SkemaSuiteIf(object):
#     """
#     Skema test suite.
# 
#     Abstract class for skema test suite classes.
#     """
# 
#     @abstractmethod
#     def install(self):
#         """
#         Install the test suite.
# 
#         This creates an install directory under the user's XDG_DATA_HOME
#         directory to mark that the suite is installed.  The installer's
#         install() method is then called from this directory to complete any
#         test specific install that may be needed.
#         """
# 
#     @abstractmethod
#     def uninstall(self):
#         """
#         Uninstall the test suite.
# 
#         Uninstalling just recursively removes the test specific directory under
#         the user's XDG_DATA_HOME directory.  This will both mark the suite as
#         removed, and clean up any files that were installed under that
#         directory.  Dependencies are intentionally not removed by this.
#         """
# 
#     @abstractmethod
#     def run(self, quiet=False, output=None):
#         # TODO: Document me
#         pass
# 
#     @abstractmethod
#     def parse(self, resultname):
#         # TODO: Document me
#         pass
# 
# Path: skema/config.py
# def get_config():
#     global _config
#     if _config is not None:
#         return _config
#     _config = SkemaConfig()
#     return _config
# 
# Path: skema/suiteutils.py
# def run_suite(scriptpath):
# 
#     tree = et()
#     tree.parse(scriptpath)
#     titer = tree.iter()
# 
#     config = get_config()
# 
#     suites = []
#     cases = []
#     errors = dict()
#     last_tag = dict()
#     case = ""
#     for elem in titer:
# 
#         if elem.tag == "Suite":
#             continue
# 
#         if elem.tag == "Case":
#             case  = elem.get('name')
#             log_line ("Use Case : '%s'"  % case)
#             cases.append(case)
#             errors[case] = 0
#             result = 0
#             continue
# 
#         if result == 0:
#             tag_func = get_tag(elem.tag)
#             if not tag_func:
#                 log_line ("Tag '%s' not found. Exiting."  % elem.tag)
#                 sys.exit(1)
# 
#             result = tag_func.run(elem, config)
#             if result != 0:
#                 log_result (elem.tag, get_string_from_il_enum(result, "OMX_Error"))
#                 errors[case] = result
#             last_tag[case] = elem.tag
# 
#     if result != 0:
#         config.base_profile_mgr.stop()
# 
#     log_line()
#     log_line()
#     log_line("-------------------------------------------------------------------")
#     msg = "SUITE EXECUTION SUMMARY : " + str(len(cases)) + " test cases executed"
#     log_result (msg, get_string_from_il_enum(result, "OMX_Error"))
#     last_error = 0
#     for case in cases:
#         msg = "CASE : " + case + " (last tag was '" + last_tag[case] + "')"
#         log_result (msg, get_string_from_il_enum(errors[case], "OMX_Error"))
#         if errors[case] != 0:
#             last_error = errors[case]
#     log_line()
#     log_line("-------------------------------------------------------------------")
#     log_line()
# 
#     return last_error
# 
# Path: skema/utils.py
# def log_line(line="", tabs=0):
#     if (line == ""):
#         lansi = "[skema] "
#         l = ""
#     else:
#         l = ('\t' * tabs) + "[" + line + "]"
#         lansi = "[skema] " + bcolors.WARNING + l + bcolors.ENDC
#     logging.info(l)
#     printit (lansi)
# 
# Path: skema/utils.py
# def log_result(tag, err):
#     log_line ()
#     if (err == "OMX_ErrorNone"):
#         l = "[" + tag + " -> '" + err + "']"
#         lansi = "[skema] " + bcolors.OKGREEN + l + bcolors.ENDC
#         logging.info(l)
#     else:
#         l = "[" + tag + " -> '" + err + "']"
#         lansi = "[skema] " + bcolors.FAIL + l + bcolors.ENDC
#         logging.error(l)
# 
#     printit (lansi)
# 
# Path: skema/omxil12.py
# def get_string_from_il_enum(enum, hint):
#     from skema import omxil12
#     for name, val in omxil12.__dict__.iteritems():
#         if enum == val:
#             if name.startswith(hint):
#                 return name
#     raise AttributeError


# Path: skema/suite.py
import os
import glob
import re
import shutil
import time
import logging
from commands import getstatusoutput
from datetime import datetime
from uuid import uuid1
from skema.api import SkemaSuiteIf
from skema.config import get_config
from skema.suiteutils import run_suite
from skema.utils import log_line
from skema.utils import log_result
from skema.omxil12 import get_string_from_il_enum

    This can be used by test definition files to create an object that contains
    the building blocks for installing tests, running them, and parsing the
    results.

    suitename - name of the test suite
    version - version of the test suite
    installer - SkemaInstaller instance to use
    runner - SkemaRunner instance to use
    parser - SkemaParser instance to use
    """
    def __init__(self, suitename, version="", installer=None, runner=None,
                 parser=None):
        self.suitename = suitename
        self.version = version
        self.installer = installer
        self.runner = runner
        self.parser = parser
        self.origdir = os.path.abspath(os.curdir)

    def install(self):
        """Install the test suite.

        This creates an install directory under the user's XDG_DATA_HOME
        directory to mark that the test is installed.  The installer's
        install() method is then called from this directory to complete any
        test specific install that may be needed.
        """
        if not self.installer:
            raise RuntimeError("no installer defined for '%s'" %
                                self.suitename)

        config = get_config()