Package animio
[hide private]
[frames] | no frames]

Source Code for Package animio

 1  # -*- coding: utf-8 -*- 
 2  import os 
 3  import sys 
 4  import glob  
 5   
 6  #{ Initialization 
 7   
8 -def _get_ext_path():
9 """:return: path containing our external packages""" 10 return os.path.join(os.path.dirname(__file__), 'ext')
11
12 -def _setup_ext_path():
13 """Put our external directory into the path to allow contained packages to be found""" 14 sys.path.insert(0, _get_ext_path())
15
16 -def _assure_mrv_is_available():
17 """Assure we have access to mrv 18 :raise ImportError: if mrv is not available or does not have a compatible version""" 19 import info 20 21 # if we have non-mrv submodules, definitely add ext to the path. 22 module_dirs = glob.glob(_get_ext_path() + "/*") 23 if len(module_dirs) > 1 or (len(module_dirs) == 1 and not module_dirs[0].endswith('mrv')): 24 _setup_ext_path() 25 # END setup externals 26 27 try: 28 import mrv.info as mrvinfo 29 except ImportError: 30 # its not installed by default, try to use it as external 31 _setup_ext_path() 32 try: 33 import mrv.info as mrvinfo 34 except ImportError: 35 raise ImportError("could not import mrv, please make sure it exists in your PYTHONPATH") 36 # END exception handling, 2nd attempt 37 # END exception handling - try import mrv 38 39 40 # CHECK MRV VERSION 41 ################### 42 # check the version 43 mmajor, mminor, mmicro = info.mrv_min_version 44 major, minor, micro = mrvinfo.version[:3] 45 if major < mmajor or minor < mminor or micro < mmicro: 46 raise EnvironmentError( "%s requires MRV version %i.%i.%i or higher, got %i.%i.%i instead" % ((project_name, ) + info.mrv_min_version + mrvinfo.version[:3]))
47 # END verify MRV version 48 49 50 #} END initilization 51 52 _assure_mrv_is_available() 53