<s> """<STR_LIT>""" <EOL> from __future__ import print_function <EOL> __version__ = '<STR_LIT>' <EOL> __author__ = '<STR_LIT>' <EOL> import traceback <EOL> import sys <EOL> import os <EOL> from . configure import Configure , Configureable , ConfigValue , BadConf <EOL> from . data import Data , DataUser , propertyTypes <EOL> from . dataObject import DataObject <EOL> from . pProperty import Property <EOL> from . simpleProperty import SimpleProperty <EOL> from . cell import Cell <EOL> from . network import Network <EOL> from . neuron import Neuron <EOL> from . worm import Worm <EOL> from . relationship import Relationship <EOL> from . evidence import Evidence , EvidenceError <EOL> from . muscle import Muscle <EOL> from . quantity import Quantity <EOL> from . my_neuroml import NeuroML <EOL> from . connection import Connection <EOL> from . experiment import Experiment <EOL> from . channel import Channel <EOL> from . channelworm import ChannelModel , PatchClampExperiment <EOL> from . plot import Plot <EOL> __import__ ( '<STR_LIT:__main__>' ) . connected = False <EOL> def get_data ( path ) : <EOL> from sysconfig import get_path <EOL> from pkgutil import get_loader <EOL> from glob import glob <EOL> package_paths = glob ( os . path . join ( get_path ( '<STR_LIT>' ) , '<STR_LIT:*>' ) ) <EOL> sys . path = package_paths + sys . path <EOL> installed_package_root = get_loader ( '<STR_LIT>' ) . filename <EOL> sys . path = sys . path [ len ( package_paths ) : ] <EOL> filename = os . path . join ( installed_package_root , path ) <EOL> return filename <EOL> def config ( key = None ) : <EOL> """<STR_LIT>""" <EOL> if key is None : <EOL> return Configureable . conf <EOL> else : <EOL> return Configureable . conf [ key ] <EOL> def loadConfig ( f ) : <EOL> """<STR_LIT>""" <EOL> Configureable . conf = Data . open ( f ) <EOL> return Configureable . conf <EOL> def disconnect ( c = False ) : <EOL> """<STR_LIT>""" <EOL> m = __import__ ( '<STR_LIT:__main__>' ) <EOL> if not m . connected : <EOL> return <EOL> if not c : <EOL> c = Configureable . conf <EOL> if c : <EOL> c . closeDatabase ( ) <EOL> from . dataObject import disconnect as DODisconnect <EOL> from . dataObject import PropertyTypes <EOL> DODisconnect ( ) <EOL> assert ( len ( PropertyTypes ) == <NUM_LIT:0> ) <EOL> m . connected = False <EOL> def loadData ( <EOL> data = '<STR_LIT>' , <EOL> dataFormat = '<STR_LIT>' , <EOL> skipIfNewer = False ) : <EOL> """<STR_LIT>""" <EOL> if not os . path . isfile ( data ) : <EOL> raise Exception ( "<STR_LIT>" + data ) <EOL> if skipIfNewer : <EOL> try : <EOL> db_file_name = config ( '<STR_LIT>' ) <EOL> if os . path . isfile ( db_file_name ) : <EOL> data_file_time = os . path . getmtime ( data ) <EOL> db_file_time = os . path . getmtime ( config ( '<STR_LIT>' ) ) <EOL> if data_file_time < db_file_time : <EOL> return <EOL> except : <EOL> pass <EOL> sys . stderr . write ( <EOL> "<STR_LIT>" ) <EOL> config ( '<STR_LIT>' ) . parse ( data , format = dataFormat ) <EOL> def connect ( configFile = False , <EOL> conf = False , <EOL> do_logging = False , <EOL> data = False , <EOL> dataFormat = '<STR_LIT>' ) : <EOL> """<STR_LIT>""" <EOL> import logging <EOL> import atexit <EOL> m = __import__ ( '<STR_LIT:__main__>' ) <EOL> if m . connected : <EOL> print ( "<STR_LIT>" ) <EOL> return <EOL> if do_logging : <EOL> logging . basicConfig ( level = logging . DEBUG ) <EOL> if conf : <EOL> if not isinstance ( conf , Data ) : <EOL> Configureable . conf = Data ( conf ) <EOL> else : <EOL> Configureable . conf = conf <EOL> elif configFile : <EOL> loadConfig ( configFile ) <EOL> else : <EOL> Configureable . conf = Data ( { <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : get_data ( '<STR_LIT>' ) , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : <NUM_LIT:50> <EOL> } ) <EOL> Configureable . conf . openDatabase ( ) <EOL> logging . info ( "<STR_LIT>" ) <EOL> atexit . register ( disconnect ) <EOL> DataObject . register ( ) <EOL> Cell . register ( ) <EOL> Network . register ( ) <EOL> Neuron . register ( ) <EOL> Worm . register ( ) <EOL> Evidence . register ( ) <EOL> Muscle . register ( ) <EOL> Connection . register ( ) <EOL> SimpleProperty . register ( ) <EOL> Property . register ( ) <EOL> Relationship . register ( ) <EOL> Channel . register ( ) <EOL> ChannelModel . register ( ) <EOL> Experiment . register ( ) <EOL> PatchClampExperiment . register ( ) <EOL> Plot . register ( ) <EOL> m . connected = True <EOL> if data : <EOL> loadData ( data , dataFormat ) </s>
