diff --git a/OMPython/__init__.py b/OMPython/__init__.py index 7aa07fa13..c5ad682e8 100644 --- a/OMPython/__init__.py +++ b/OMPython/__init__.py @@ -32,11 +32,6 @@ import warnings -if sys.platform == 'darwin': - # On Mac let's assume omc is installed here and there might be a broken omniORB installed in a bad place - sys.path.append('/opt/local/lib/python2.7/site-packages/') - sys.path.append('/opt/openmodelica/lib/python2.7/site-packages/') - # TODO: replace this with the new parser from OMPython import OMTypedParser, OMParser @@ -103,6 +98,10 @@ def wait(self, timeout): class OMCSessionBase(metaclass=abc.ABCMeta): + def __init__(self, readonly=False): + self._readonly = readonly + self._omc_cache = {} + def clearOMParserResult(self): OMParser.result = {} @@ -130,10 +129,10 @@ def sendExpression(self, command, parsed=True): def ask(self, question, opt=None, parsed=True): p = (question, opt, parsed) - if self.readonly and question != 'getErrorString': + if self._readonly and question != 'getErrorString': # can use cache if readonly - if p in self.omc_cache: - return self.omc_cache[p] + if p in self._omc_cache: + return self._omc_cache[p] if opt: expression = f'{question}({opt})' @@ -149,7 +148,7 @@ def ask(self, question, opt=None, parsed=True): raise # save response - self.omc_cache[p] = res + self._omc_cache[p] = res return res @@ -334,10 +333,10 @@ def __init__(self, readonly=False, timeout=10.00, if dockerExtraArgs is None: dockerExtraArgs = [] + super().__init__(readonly=readonly) + self.omhome = self._get_omhome(omhome=omhome) - self.readonly = readonly - self.omc_cache = {} self._omc_process = None self._omc_command = None self._omc = None @@ -1466,7 +1465,7 @@ def convertMo2Fmu(self, version="2.0", fmuType="me_cs", fileNamePrefix=">> convertMo2Fmu() - >>> convertMo2Fmu(version="2.0", fmuType="me|cs|me_cs", fileNamePrefix="", includeResources=true) + >>> convertMo2Fmu(version="2.0", fmuType="me|cs|me_cs", fileNamePrefix="", includeResources=True) """ if fileNamePrefix == "":