# Path: tellurium/utils/omex.py
# MANIFEST_PATTERN = "manifest.xml"
# METADAT_PATTERN = "metadata.*"
# class Entry(object):
# class Creator(object):
#     def __init__(self, location, format=None, formatKey=None, master=False, description=None, creators=None):
#     def __str__(self):
#     def __init__(self, givenName, familyName, organization, email):
# def combineArchiveFromDirectory(directory, omexPath, creators=None, creators_for_all=False):
# def combineArchiveFromEntries(omexPath, entries, workingDir):
# def addEntriesToCombineArchive(omexPath, entries, workingDir):
# def _addEntriesToArchive(omexPath, entries, workingDir, add_entries):
# def extractCombineArchive(omexPath, directory, method="zip"):
# def getLocationsByFormat(omexPath, formatKey=None, method="omex"):
# def listContents(omexPath, method="omex"):
# def printContents(omexPath):
# 
# Path: tellurium/sedml/mathml.py
# def evaluableMathML(astnode, variables={}, array=False):
#     """ Create evaluable python string.
# 
#     """
#     # replace variables with provided values
#     for key, value in variables.items():
#         astnode.replaceArgument(key, libsbml.parseFormula(str(value)))
# 
#     # get formula
#     formula = libsbml.formulaToL3String(astnode)
# 
#     # <replacements>
#     # FIXME: these are not exhaustive, but are improved with examples
#     if array is False:
#         # scalar
#         formula = formula.replace("&&", 'and')
#         formula = formula.replace("||", 'or')
#     else:
#         # np.array
#         formula = formula.replace("max", 'np.nanmax')
#         formula = formula.replace("min", 'np.nanmin')
#         formula = formula.replace("sum", 'np.nansum')
#         formula = formula.replace("product", 'np.prod')
# 
#     return formula


import sys
import platform
import tempfile
import shutil
import traceback
import os.path
import warnings
import datetime
import zipfile
import re
import numpy as np
import jinja2
    import libsedml
    import tesedml as libsedml
import tellurium as te
    import pandas
    import matplotlib.pyplot as plt
    import mpl_toolkits.mplot3d
                    import os
    import os
    import matplotlib
from collections import namedtuple
from tellurium.utils import omex
from .mathml import evaluableMathML
        from tellurium.sedml.data import DataDescriptionParser
                from xml.etree import ElementTree
    from tellurium.tests.testdata import SEDML_TEST_DIR, OMEX_TEST_DIR

    :param omexPath: OMEX Combine archive
    :param workingDir: directory to extract archive to
    :param printPython: boolean switch to print executed python code
    :param createOutputs: boolean flag if outputs should be created, i.e. reports and plots
    :param saveOutputs: flag if the outputs should be saved to file
    :param outputDir: directory where the outputs should be written
    :param plottingEngin: string of which plotting engine to use; uses set plotting engine otherwise
    :return dictionary of sedmlFile:data generators
    """

    # combine archives are zip format
    if zipfile.is_zipfile(omexPath):
        try:
            tmp_dir = tempfile.mkdtemp()
            if workingDir is None:
                extractDir = tmp_dir
            else:
                if not os.path.exists(workingDir):
                    raise IOError("workingDir does not exist, make sure to create the directoy: '{}'".format(workingDir))
                extractDir = workingDir

            # extract
            omex.extractCombineArchive(omexPath=omexPath, directory=extractDir)

            # get sedml locations by omex
            sedml_locations = omex.getLocationsByFormat(omexPath=omexPath, formatKey="sed-ml", method="omex")
            if len(sedml_locations) == 0:

                # falling back to zip archive

# Path: tellurium/utils/omex.py
# MANIFEST_PATTERN = "manifest.xml"
# METADAT_PATTERN = "metadata.*"
# class Entry(object):
# class Creator(object):
#     def __init__(self, location, format=None, formatKey=None, master=False, description=None, creators=None):
#     def __str__(self):
#     def __init__(self, givenName, familyName, organization, email):
# def combineArchiveFromDirectory(directory, omexPath, creators=None, creators_for_all=False):
# def combineArchiveFromEntries(omexPath, entries, workingDir):
# def addEntriesToCombineArchive(omexPath, entries, workingDir):
# def _addEntriesToArchive(omexPath, entries, workingDir, add_entries):
# def extractCombineArchive(omexPath, directory, method="zip"):
# def getLocationsByFormat(omexPath, formatKey=None, method="omex"):
# def listContents(omexPath, method="omex"):
# def printContents(omexPath):
# 
# Path: tellurium/sedml/mathml.py
# def evaluableMathML(astnode, variables={}, array=False):
#     """ Create evaluable python string.
# 
#     """
#     # replace variables with provided values
#     for key, value in variables.items():
#         astnode.replaceArgument(key, libsbml.parseFormula(str(value)))
# 
#     # get formula
#     formula = libsbml.formulaToL3String(astnode)
# 
#     # <replacements>
#     # FIXME: these are not exhaustive, but are improved with examples
#     if array is False:
#         # scalar
#         formula = formula.replace("&&", 'and')
#         formula = formula.replace("||", 'or')
#     else:
#         # np.array
#         formula = formula.replace("max", 'np.nanmax')
#         formula = formula.replace("min", 'np.nanmin')
#         formula = formula.replace("sum", 'np.nansum')
#         formula = formula.replace("product", 'np.prod')
# 
#     return formula


# Path: tellurium/sedml/tesedml.py
import sys
import platform
import tempfile
import shutil
import traceback
import os.path
import warnings
import datetime
import zipfile
import re
import numpy as np
import jinja2
    import libsedml
    import tesedml as libsedml
import tellurium as te
    import pandas
    import matplotlib.pyplot as plt
    import mpl_toolkits.mplot3d
                    import os
    import os
    import matplotlib
from collections import namedtuple
from tellurium.utils import omex
from .mathml import evaluableMathML
        from tellurium.sedml.data import DataDescriptionParser
                from xml.etree import ElementTree
    from tellurium.tests.testdata import SEDML_TEST_DIR, OMEX_TEST_DIR


    :param omexPath: OMEX Combine archive
    :param workingDir: directory to extract archive to
    :param printPython: boolean switch to print executed python code
    :param createOutputs: boolean flag if outputs should be created, i.e. reports and plots
    :param saveOutputs: flag if the outputs should be saved to file
    :param outputDir: directory where the outputs should be written
    :param plottingEngin: string of which plotting engine to use; uses set plotting engine otherwise
    :return dictionary of sedmlFile:data generators
    """

    # combine archives are zip format
    if zipfile.is_zipfile(omexPath):
        try:
            tmp_dir = tempfile.mkdtemp()
            if workingDir is None:
                extractDir = tmp_dir
            else:
                if not os.path.exists(workingDir):
                    raise IOError("workingDir does not exist, make sure to create the directoy: '{}'".format(workingDir))
                extractDir = workingDir

            # extract
            omex.extractCombineArchive(omexPath=omexPath, directory=extractDir)

            # get sedml locations by omex
            sedml_locations = omex.getLocationsByFormat(omexPath=omexPath, formatKey="sed-ml", method="omex")
            if len(sedml_locations) == 0:

                # falling back to zip archive

                sedml_locations = omex.getLocationsByFormat(omexPath=omexPath, formatKey="sed-ml", method="zip")