pytabs.etabs_config
1# pyTABS - ETABS .NET API python wrapper 2# ETABS Configuration - ETABS API DLL handler 3__all__ = ['etabs', 'pytabs_config'] 4 5# general library imports 6import pytabs.pytabs_config as config 7import warnings 8import sys 9# import pythonnet clr-loader 10import clr 11 12 13# Mock for pdoc pipeline where dependency is not available 14# reference: https://blog.rtwilson.com/how-to-make-your-sphinx-documentation-compile-with-readthedocs-when-youre-using-numpy-and-scipy/ 15MOCK_MODULES = ['ETABSv1'] 16class Mock(object): 17 __qualname__ = 'mock' 18 19 def __init__(self, *args, **kwargs): 20 pass 21 22 def __call__(self, *args, **kwargs): 23 return Mock() 24 25 @classmethod 26 def __getattr__(cls, name): 27 if name in ('__file__', '__path__'): 28 return '/dev/null' 29 elif name[0] == name[0].upper(): 30 # return type(name, (), {}) 31 return None 32 else: 33 return Mock() 34 35 36# read pytabs config file 37pytabs_config = config.read_config() 38 39# try import of ETABS API DLL path from config file 40etabs_api_path = pytabs_config['ETABS']['API_DLL_PATH'] 41 42# pythonnet clr-loader import of Marshal - ETABS API requirement 43clr.AddReference("System.Runtime.InteropServices") 44from System.Runtime.InteropServices import Marshal 45 46# pythonnet clr-loader try import of ETABS API DLL (ETABSv1.dll) else load Mock 47warnings.filterwarnings('default') 48try: 49 clr.AddReference(etabs_api_path) 50 import ETABSv1 as etabs 51except: 52 for mod_name in MOCK_MODULES: 53 sys.modules[mod_name] = Mock() 54 import ETABSv1 as etabs 55 warnings.warn("ETABS API DLL file (ETABSv1.dll) not found in configured location, check pytabs_config.ini", ImportWarning)
etabs = <module 'ETABSv1'>
pytabs_config = <configparser.ConfigParser object>