MoDeNa  1.0
Software framework facilitating sequential multi-scale modelling
__init__.py
Go to the documentation of this file.
1 
31 
32 
39 
40 import os, sys
41 from pkg_resources import get_distribution
42 
43 __version__ = get_distribution('modena').version
44 
45 MODENA_INSTALL_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
46 MODENA_WORKING_DIR = os.path.realpath(os.getcwd())
47 
48 from Strategy import BackwardMappingScriptTask, ModenaFireTask
49 from SurrogateModel import CFunction, IndexSet, \
50  SurrogateModel, ForwardMappingModel, BackwardMappingModel, \
51  ModenaFireTask, MODENA_PARSED_URI
52 
53 
58 def find_module(target, startsearch=MODENA_WORKING_DIR):
59 
60  pth = os.path.abspath(startsearch)
61  while target not in os.listdir(pth):
62  pth = os.path.abspath(os.path.join(pth,'..')) # step back a directory
63  if os.path.ismount(pth): # break if we hit "root"
64  pth = None
65  break
66 
67  if pth is not None:
68  sys.path.insert(0, os.path.join(pth,target))
69  else:
70  print "Could not find directory: %s" %(target)
71 
72 def import_helper():
73  from os.path import dirname
74  import imp
75 
76 
77  fp = None
78  try:
79  fp, pathname, description = imp.find_module(
80  'libmodena',
81  [ find_module("modena", os.path.join(MODENA_INSTALL_DIR, "..","..")) ]
82  )
83  except ImportError:
84  import libmodena
85  return libmodena
86  if fp is not None:
87  try:
88  _mod = imp.load_module('libmodena', fp, pathname, description)
89  finally:
90  fp.close()
91  return _mod
92 
93 
94 find_module("MoDeNaModels") # Look for a models directory
95 libmodena = import_helper()
96 del import_helper
97 
98 
101