Skip to content

Commit 0135cdc

Browse files
committed
[OMParser] use a single entry point for OMParser
1 parent f6ac6cb commit 0135cdc

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

OMPython/OMCSession.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252

5353
# TODO: replace this with the new parser
5454
from OMPython import OMTypedParser
55-
from OMPython import OMParser
55+
from OMPython.OMParser import om_parser_basic
5656

5757

5858
# define logger using the current module name as ID
@@ -81,9 +81,6 @@ def __init__(self, readonly=False):
8181
self._readonly = readonly
8282
self._omc_cache = {}
8383

84-
def clearOMParserResult(self):
85-
OMParser.result = {}
86-
8784
def execute(self, command):
8885
warnings.warn("This function is depreciated and will be removed in future versions; "
8986
"please use sendExpression() instead", DeprecationWarning, stacklevel=1)
@@ -246,8 +243,7 @@ def getComponentModifierValue(self, className, componentName):
246243
logger.warning('OMTypedParser error: %s', ex.message)
247244
result = self.ask('getComponentModifierValue', f'{className}, {componentName}', parsed=False)
248245
try:
249-
answer = OMParser.check_for_values(result)
250-
OMParser.result = {}
246+
answer = om_parser_basic(result)
251247
return answer[2:]
252248
except (TypeError, UnboundLocalError) as ex:
253249
logger.warning('OMParser error: %s', ex)
@@ -264,8 +260,7 @@ def getExtendsModifierValue(self, className, extendsName, modifierName):
264260
logger.warning('OMTypedParser error: %s', ex.message)
265261
result = self.ask('getExtendsModifierValue', f'{className}, {extendsName}, {modifierName}', parsed=False)
266262
try:
267-
answer = OMParser.check_for_values(result)
268-
OMParser.result = {}
263+
answer = om_parser_basic(result)
269264
return answer[2:]
270265
except (TypeError, UnboundLocalError) as ex:
271266
logger.warning('OMParser error: %s', ex)

OMPython/OMParser.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -892,3 +892,15 @@ def check_for_values(string):
892892
check_for_values(next_set)
893893

894894
return result
895+
896+
897+
# TODO: hack to be able to use one entry point wich also resets the (global) variable results
898+
# this should be checked such that the content of this file can be used as class with correct handling of
899+
# variable usage
900+
def om_parser_basic(string: str):
901+
result_return = check_for_values(string=string)
902+
903+
global result
904+
result = {}
905+
906+
return result_return

0 commit comments

Comments
 (0)