@@ -280,13 +280,13 @@ def is_file(self, *, follow_symlinks=True) -> bool:
280280 """
281281 Check if the path is a regular file.
282282 """
283- return self ._session .sendExpression (f'regularFileExists("{ self .as_posix ()} ")' )
283+ return self ._session .sendExpression (expr = f'regularFileExists("{ self .as_posix ()} ")' )
284284
285285 def is_dir (self , * , follow_symlinks = True ) -> bool :
286286 """
287287 Check if the path is a directory.
288288 """
289- return self ._session .sendExpression (f'directoryExists("{ self .as_posix ()} ")' )
289+ return self ._session .sendExpression (expr = f'directoryExists("{ self .as_posix ()} ")' )
290290
291291 def is_absolute (self ):
292292 """
@@ -304,7 +304,7 @@ def read_text(self, encoding=None, errors=None, newline=None) -> str:
304304 The additional arguments `encoding`, `errors` and `newline` are only defined for compatibility with Path()
305305 definition.
306306 """
307- return self ._session .sendExpression (f'readFile("{ self .as_posix ()} ")' )
307+ return self ._session .sendExpression (expr = f'readFile("{ self .as_posix ()} ")' )
308308
309309 def write_text (self , data : str , encoding = None , errors = None , newline = None ):
310310 """
@@ -317,7 +317,7 @@ def write_text(self, data: str, encoding=None, errors=None, newline=None):
317317 raise TypeError (f"data must be str, not { data .__class__ .__name__ } " )
318318
319319 data_omc = self ._session .escape_str (data )
320- self ._session .sendExpression (f'writeFile("{ self .as_posix ()} ", "{ data_omc } ", false);' )
320+ self ._session .sendExpression (expr = f'writeFile("{ self .as_posix ()} ", "{ data_omc } ", false);' )
321321
322322 return len (data )
323323
@@ -330,20 +330,20 @@ def mkdir(self, mode=0o777, parents=False, exist_ok=False):
330330 if self .is_dir () and not exist_ok :
331331 raise FileExistsError (f"Directory { self .as_posix ()} already exists!" )
332332
333- return self ._session .sendExpression (f'mkdir("{ self .as_posix ()} ")' )
333+ return self ._session .sendExpression (expr = f'mkdir("{ self .as_posix ()} ")' )
334334
335335 def cwd (self ):
336336 """
337337 Returns the current working directory as an OMCPath object.
338338 """
339- cwd_str = self ._session .sendExpression ('cd()' )
339+ cwd_str = self ._session .sendExpression (expr = 'cd()' )
340340 return OMCPath (cwd_str , session = self ._session )
341341
342342 def unlink (self , missing_ok : bool = False ) -> None :
343343 """
344344 Unlink (delete) the file or directory represented by this path.
345345 """
346- res = self ._session .sendExpression (f'deleteFile("{ self .as_posix ()} ")' )
346+ res = self ._session .sendExpression (expr = f'deleteFile("{ self .as_posix ()} ")' )
347347 if not res and not missing_ok :
348348 raise FileNotFoundError (f"Cannot delete file { self .as_posix ()} - it does not exists!" )
349349
@@ -373,12 +373,12 @@ def _omc_resolve(self, pathstr: str) -> str:
373373 Internal function to resolve the path of the OMCPath object using OMC functions *WITHOUT* changing the cwd
374374 within OMC.
375375 """
376- expression = ('omcpath_cwd := cd(); '
377- f'omcpath_check := cd("{ pathstr } "); ' # check requested pathstring
378- 'cd(omcpath_cwd)' )
376+ expr = ('omcpath_cwd := cd(); '
377+ f'omcpath_check := cd("{ pathstr } "); ' # check requested pathstring
378+ 'cd(omcpath_cwd)' )
379379
380380 try :
381- result = self ._session .sendExpression (command = expression , parsed = False )
381+ result = self ._session .sendExpression (expr = expr , parsed = False )
382382 result_parts = result .split ('\n ' )
383383 pathstr_resolved = result_parts [1 ]
384384 pathstr_resolved = pathstr_resolved [1 :- 1 ] # remove quotes
@@ -407,7 +407,7 @@ def size(self) -> int:
407407 if not self .is_file ():
408408 raise OMCSessionException (f"Path { self .as_posix ()} is not a file!" )
409409
410- res = self ._session .sendExpression (f'stat("{ self .as_posix ()} ")' )
410+ res = self ._session .sendExpression (expr = f'stat("{ self .as_posix ()} ")' )
411411 if res [0 ]:
412412 return int (res [1 ])
413413
@@ -582,7 +582,7 @@ def sendExpression(self, command: str, parsed: bool = True) -> Any:
582582 The complete error handling of the OMC result is done within this method using '"getMessagesStringInternal()'.
583583 Caller should only check for OMCSessionException.
584584 """
585- return self .omc_process .sendExpression (command = command , parsed = parsed )
585+ return self .omc_process .sendExpression (expr = command , parsed = parsed )
586586
587587
588588class PostInitCaller (type ):
@@ -701,7 +701,7 @@ def __post_init__(self) -> None:
701701 def __del__ (self ):
702702 if isinstance (self ._omc_zmq , zmq .Socket ):
703703 try :
704- self .sendExpression ("quit()" )
704+ self .sendExpression (expr = "quit()" )
705705 except OMCSessionException :
706706 pass
707707 finally :
@@ -759,7 +759,7 @@ def omcpath_tempdir(self, tempdir_base: Optional[OMCPath] = None) -> OMCPath:
759759 if sys .version_info < (3 , 12 ):
760760 tempdir_str = tempfile .gettempdir ()
761761 else :
762- tempdir_str = self .sendExpression ("getTempDirectoryPath()" )
762+ tempdir_str = self .sendExpression (expr = "getTempDirectoryPath()" )
763763 tempdir_base = self .omcpath (tempdir_str )
764764
765765 tempdir : Optional [OMCPath ] = None
@@ -823,7 +823,7 @@ def execute(self, command: str):
823823
824824 return self .sendExpression (command , parsed = False )
825825
826- def sendExpression (self , command : str , parsed : bool = True ) -> Any :
826+ def sendExpression (self , expr : str , parsed : bool = True ) -> Any :
827827 """
828828 Send an expression to the OMC server and return the result.
829829
@@ -840,12 +840,12 @@ def sendExpression(self, command: str, parsed: bool = True) -> Any:
840840 if self ._omc_zmq is None :
841841 raise OMCSessionException ("No OMC running. Please create a new instance of OMCSession!" )
842842
843- logger .debug ("sendExpression(%r , parsed=%r)" , command , parsed )
843+ logger .debug ("sendExpression(expr='%r' , parsed=%r)" , str ( expr ) , parsed )
844844
845845 attempts = 0
846846 while True :
847847 try :
848- self ._omc_zmq .send_string (str (command ), flags = zmq .NOBLOCK )
848+ self ._omc_zmq .send_string (str (expr ), flags = zmq .NOBLOCK )
849849 break
850850 except zmq .error .Again :
851851 pass
@@ -859,7 +859,7 @@ def sendExpression(self, command: str, parsed: bool = True) -> Any:
859859 raise OMCSessionException (f"No connection with OMC (timeout={ timeout } ). "
860860 f"Log-file says: \n { log_content } " )
861861 time .sleep (timeout / 50.0 )
862- if command == "quit()" :
862+ if expr == "quit()" :
863863 self ._omc_zmq .close ()
864864 self ._omc_zmq = None
865865 return None
@@ -869,13 +869,13 @@ def sendExpression(self, command: str, parsed: bool = True) -> Any:
869869 if result .startswith ('Error occurred building AST' ):
870870 raise OMCSessionException (f"OMC error: { result } " )
871871
872- if command == "getErrorString()" :
872+ if expr == "getErrorString()" :
873873 # no error handling if 'getErrorString()' is called
874874 if parsed :
875875 logger .warning ("Result of 'getErrorString()' cannot be parsed!" )
876876 return result
877877
878- if command == "getMessagesStringInternal()" :
878+ if expr == "getMessagesStringInternal()" :
879879 # no error handling if 'getMessagesStringInternal()' is called
880880 if parsed :
881881 logger .warning ("Result of 'getMessagesStringInternal()' cannot be parsed!" )
@@ -929,7 +929,7 @@ def sendExpression(self, command: str, parsed: bool = True) -> Any:
929929 log_level = log_raw [0 ][8 ]
930930 log_id = log_raw [0 ][9 ]
931931
932- msg_short = (f"[OMC log for 'sendExpression({ command } , { parsed } )']: "
932+ msg_short = (f"[OMC log for 'sendExpression(expr= { expr } , parsed= { parsed } )']: "
933933 f"[{ log_kind } :{ log_level } :{ log_id } ] { log_message } " )
934934
935935 # response according to the used log level
@@ -951,7 +951,7 @@ def sendExpression(self, command: str, parsed: bool = True) -> Any:
951951 msg_long_list .append (msg_long )
952952 if has_error :
953953 msg_long_str = '\n ' .join (f"{ idx :02d} : { msg } " for idx , msg in enumerate (msg_long_list ))
954- raise OMCSessionException (f"OMC error occurred for 'sendExpression({ command } , { parsed } ):\n "
954+ raise OMCSessionException (f"OMC error occurred for 'sendExpression(expr= { expr } , parsed= { parsed } ):\n "
955955 f"{ msg_long_str } " )
956956
957957 if parsed is False :
0 commit comments