# Path: Graphyne/DatabaseDrivers/SQLDictionary.py
# class SyntaxDefSQLite(object):
# class SyntaxDefMSSQL(object):
# class SyntaxSAPHana(object):
#     def createRuntimeDB(self, db):
#     def resetRuntimeDB(self, db):
#     def createTestDB(self, db):
#     def createRuntimeDB(self, db):
#     def resetRuntimeDB(self, db):
#     def createTestDB(self, db):
# 
# Path: Graphyne/Exceptions.py
# class TagError(ValueError):
# class TraverseFilterError(ValueError):
# class EmptyFileError(ValueError):
# class UndefinedPersistenceError(ValueError):
# class PersistenceQueryError(ValueError):
# class EnhancementError(ValueError):
# class EventScriptFailure(ValueError):
# class XMLSchemavalidationError(ValueError):
# class UndefinedValueListError(ValueError):
# class DuplicateValueListError(ValueError):
# class UndefinedOperatorError(ValueError):
# class DisallowedCloneError(ValueError):
# class UndefinedUUIDError(ValueError):
# class TemplatePathError(ValueError):
# class MetaMemePropertyNotDefinedError(ValueError):
# class MemePropertyValidationError(ValueError):
# class MemePropertyValueError(ValueError):
# class MemePropertyValueTypeError(ValueError):
# class MemePropertyValueOutOfBoundsError(ValueError):
# class MemeMembershipValidationError(ValueError):
# class NonInstantiatedSingletonError(ValueError):
# class MemeMemberCardinalityError(ValueError):
# class EntityPropertyMissingValueError(ValueError):
# class EntityPropertyValueTypeError(ValueError):
# class EntityPropertyDuplicateError(ValueError):
# class EntityPropertyValueOutOfBoundsError(ValueError):
# class EntityMemberDuplicateError(ValueError):
# class EntityMemberMissingError(ValueError):
# class EntityInitializationError(ValueError):
# class UnknownLinkError(ValueError):
# class UnanchoredReferenceError(ValueError):
# class UndefinedReferenceDirectionalityError(ValueError):
# class UndefinedReferenceValueComparisonOperator(ValueError):
# class ScriptError(ValueError):
# class GeneratorError(ValueError):
# class StateEventScriptInitError(ValueError):
# class SourceMemeManipulationError(ValueError):
# class EntityNotInLinkError(ValueError):
# class EntityLinkFailureError(ValueError):
# class EntityDuplicateLinkError(ValueError):
# class QueueError(ValueError):
# class NoSuchZoneError(ValueError):
# class NoSuchEntityError(ValueError):
# class MissingImlpicitMemeDatabase(ValueError):
# class UndefinedSQLSyntax(Exception):
# class InconsistentPersistenceArchitecture(Exception): 
# class MalformedArgumentPathError(ValueError):
# class MismatchedArgumentPathError(ValueError):
# class MissingArgumentError(ValueError):
# class MissingAgentPathError(ValueError):
# class MissingAgentError(ValueError):
# class MalformedConditionalError(ValueError):
# class UtilityError(Exception):
#     def __init__(self, persistenceType, persistenceArg, nestedTraceback = None):
#     def __str__(self):
# 
# Path: Graphyne/Condition.py
# class Condition(threading.Thread):
#     ''' An abstract class for defining the three types of conditions, String, Int and Float '''
#     className = "Condition"
#     entityLock = threading.RLock()
# 
#     def initializeCondition(self, conditionContainerUUID, path, operator, valueList = None):
#         self.uuid = conditionContainerUUID
#         self.meme = path
#         self.valueList = valueList
#         self.operator = operator
# 
# Path: Graphyne/Fileutils.py
# def ensureDirectory(targetDir):
# def getModuleFromResolvedPath(fullModuleName):
# def listFromFile(listFileName):
# def getCodePageFromFile(fileURI):
# def walkDirectory(workingDir, packagePath):
# def walkRepository(dataLocation, pathSet, dynamicPackage = None):
# def defaultCSS():
# def smart_str(s, encoding='utf-8', strings_only=False, errors='strict'):
# class Promise(object):


from ast import Str
from uuid import UUID
from xml.dom import minidom
from os.path import expanduser
from .DatabaseDrivers import SQLDictionary
from Graphyne import Exceptions
from Graphyne import Condition
from Graphyne import Fileutils
    from . import Logger
        from .DatabaseDrivers import NonPersistent as persistenceNone
                from .DatabaseDrivers import RelationalDatabase  as persistenceMemory
                from .DatabaseDrivers import RelationalDatabase as persistenceExisting
                from .DatabaseDrivers import RelationalDatabase as persistenceNew
                from .DatabaseDrivers import RelationalDatabase as persistenceMSSQL
import uuid
import decimal
import copy
import re
import threading
import sys
import os
import queue
import functools
import platform
import json
import time
                import sqlite3 as dbDriverMemory
                import sqlite3 as dbDriverExisting
                import sqlite3 as dbDriverNew
                import pyodbc as dbDriverMSSQL
                            import TestUtils   
                            import sqlite3 as dtDBDriverSQLiteDT
                        import sqlite3 as dtDBDriverSQLite2
            metameme.mergeExtensions()
        except Exception as e:
            errorMsg = "Problem extending metameme %s list: %s.  Traceback = %s" %(metameme.path.fullTemplatePath, metameme.extends, e)
            logQ.put( [logType , logLevel.WARNING , method , errorMsg])
    for metameme in metamemes:
        try:
            templateRepository.catalogTemplate(metameme.path, metameme) 
        except Exception as e:
            errorMsg = "Problem cataloging metameme %s.  Traceback = %s" %(metameme.path.fullTemplatePath, e)
            logQ.put( [logType , logLevel.WARNING , method , errorMsg])
    #Finished loading metamemes
    #logQ.put( [logType , logLevel.DEBUG , method , 'Finished loading meta-memes from XML in queue.  Metameme Queue now empty.']) 

    #Before we can start instantiating any entities (or catalog implicit memes) - including singletnns and pre-archived entities - we need to start the repo
    #Initialize Entity Repository    
    if persistenceType == "none":
        #"none" - no persistence
        print("Warning!  No persistence declared.  Deaulting to in-memory transient persistentce")
        logQ.put( [logType , logLevel.WARNING , method , "Warning!  No persistence declared.  Deaulting to in-memory transient persistentce"])
        #persistenceNone.initialize(api, repoLocations, logQ, persistenceArg)
        persistenceNone.initialize(api, templateRepository, logQ, persistenceArg)
        entityRepository = persistenceNone.entityRepository
        linkRepository = persistenceNone.linkRepository
    elif persistenceType == "sqlite":
        if persistenceArg is None:
            persistenceArg = "memory"
        try:
            if persistenceArg == "memory":
                #"memory" - Use SQLite in in-memory mode (connection = ":memory:")
                persistenceDB = dbDriverMemory

# Path: Graphyne/DatabaseDrivers/SQLDictionary.py
# class SyntaxDefSQLite(object):
# class SyntaxDefMSSQL(object):
# class SyntaxSAPHana(object):
#     def createRuntimeDB(self, db):
#     def resetRuntimeDB(self, db):
#     def createTestDB(self, db):
#     def createRuntimeDB(self, db):
#     def resetRuntimeDB(self, db):
#     def createTestDB(self, db):
# 
# Path: Graphyne/Exceptions.py
# class TagError(ValueError):
# class TraverseFilterError(ValueError):
# class EmptyFileError(ValueError):
# class UndefinedPersistenceError(ValueError):
# class PersistenceQueryError(ValueError):
# class EnhancementError(ValueError):
# class EventScriptFailure(ValueError):
# class XMLSchemavalidationError(ValueError):
# class UndefinedValueListError(ValueError):
# class DuplicateValueListError(ValueError):
# class UndefinedOperatorError(ValueError):
# class DisallowedCloneError(ValueError):
# class UndefinedUUIDError(ValueError):
# class TemplatePathError(ValueError):
# class MetaMemePropertyNotDefinedError(ValueError):
# class MemePropertyValidationError(ValueError):
# class MemePropertyValueError(ValueError):
# class MemePropertyValueTypeError(ValueError):
# class MemePropertyValueOutOfBoundsError(ValueError):
# class MemeMembershipValidationError(ValueError):
# class NonInstantiatedSingletonError(ValueError):
# class MemeMemberCardinalityError(ValueError):
# class EntityPropertyMissingValueError(ValueError):
# class EntityPropertyValueTypeError(ValueError):
# class EntityPropertyDuplicateError(ValueError):
# class EntityPropertyValueOutOfBoundsError(ValueError):
# class EntityMemberDuplicateError(ValueError):
# class EntityMemberMissingError(ValueError):
# class EntityInitializationError(ValueError):
# class UnknownLinkError(ValueError):
# class UnanchoredReferenceError(ValueError):
# class UndefinedReferenceDirectionalityError(ValueError):
# class UndefinedReferenceValueComparisonOperator(ValueError):
# class ScriptError(ValueError):
# class GeneratorError(ValueError):
# class StateEventScriptInitError(ValueError):
# class SourceMemeManipulationError(ValueError):
# class EntityNotInLinkError(ValueError):
# class EntityLinkFailureError(ValueError):
# class EntityDuplicateLinkError(ValueError):
# class QueueError(ValueError):
# class NoSuchZoneError(ValueError):
# class NoSuchEntityError(ValueError):
# class MissingImlpicitMemeDatabase(ValueError):
# class UndefinedSQLSyntax(Exception):
# class InconsistentPersistenceArchitecture(Exception): 
# class MalformedArgumentPathError(ValueError):
# class MismatchedArgumentPathError(ValueError):
# class MissingArgumentError(ValueError):
# class MissingAgentPathError(ValueError):
# class MissingAgentError(ValueError):
# class MalformedConditionalError(ValueError):
# class UtilityError(Exception):
#     def __init__(self, persistenceType, persistenceArg, nestedTraceback = None):
#     def __str__(self):
# 
# Path: Graphyne/Condition.py
# class Condition(threading.Thread):
#     ''' An abstract class for defining the three types of conditions, String, Int and Float '''
#     className = "Condition"
#     entityLock = threading.RLock()
# 
#     def initializeCondition(self, conditionContainerUUID, path, operator, valueList = None):
#         self.uuid = conditionContainerUUID
#         self.meme = path
#         self.valueList = valueList
#         self.operator = operator
# 
# Path: Graphyne/Fileutils.py
# def ensureDirectory(targetDir):
# def getModuleFromResolvedPath(fullModuleName):
# def listFromFile(listFileName):
# def getCodePageFromFile(fileURI):
# def walkDirectory(workingDir, packagePath):
# def walkRepository(dataLocation, pathSet, dynamicPackage = None):
# def defaultCSS():
# def smart_str(s, encoding='utf-8', strings_only=False, errors='strict'):
# class Promise(object):


# Path: Graphyne/Graph.py
from ast import Str
from uuid import UUID
from xml.dom import minidom
from os.path import expanduser
from .DatabaseDrivers import SQLDictionary
from Graphyne import Exceptions
from Graphyne import Condition
from Graphyne import Fileutils
    from . import Logger
        from .DatabaseDrivers import NonPersistent as persistenceNone
                from .DatabaseDrivers import RelationalDatabase  as persistenceMemory
                from .DatabaseDrivers import RelationalDatabase as persistenceExisting
                from .DatabaseDrivers import RelationalDatabase as persistenceNew
                from .DatabaseDrivers import RelationalDatabase as persistenceMSSQL
import uuid
import decimal
import copy
import re
import threading
import sys
import os
import queue
import functools
import platform
import json
import time
                import sqlite3 as dbDriverMemory
                import sqlite3 as dbDriverExisting
                import sqlite3 as dbDriverNew
                import pyodbc as dbDriverMSSQL
                            import TestUtils   
                            import sqlite3 as dtDBDriverSQLiteDT
                        import sqlite3 as dtDBDriverSQLite2

            metameme.mergeExtensions()
        except Exception as e:
            errorMsg = "Problem extending metameme %s list: %s.  Traceback = %s" %(metameme.path.fullTemplatePath, metameme.extends, e)
            logQ.put( [logType , logLevel.WARNING , method , errorMsg])
    for metameme in metamemes:
        try:
            templateRepository.catalogTemplate(metameme.path, metameme) 
        except Exception as e:
            errorMsg = "Problem cataloging metameme %s.  Traceback = %s" %(metameme.path.fullTemplatePath, e)
            logQ.put( [logType , logLevel.WARNING , method , errorMsg])
    #Finished loading metamemes
    #logQ.put( [logType , logLevel.DEBUG , method , 'Finished loading meta-memes from XML in queue.  Metameme Queue now empty.']) 

    #Before we can start instantiating any entities (or catalog implicit memes) - including singletnns and pre-archived entities - we need to start the repo
    #Initialize Entity Repository    
    if persistenceType == "none":
        #"none" - no persistence
        print("Warning!  No persistence declared.  Deaulting to in-memory transient persistentce")
        logQ.put( [logType , logLevel.WARNING , method , "Warning!  No persistence declared.  Deaulting to in-memory transient persistentce"])
        #persistenceNone.initialize(api, repoLocations, logQ, persistenceArg)
        persistenceNone.initialize(api, templateRepository, logQ, persistenceArg)
        entityRepository = persistenceNone.entityRepository
        linkRepository = persistenceNone.linkRepository
    elif persistenceType == "sqlite":
        if persistenceArg is None:
            persistenceArg = "memory"
        try:
            if persistenceArg == "memory":
                #"memory" - Use SQLite in in-memory mode (connection = ":memory:")
                persistenceDB = dbDriverMemory

                sqlSyntax = SQLDictionary.SyntaxDefSQLite()