@@ -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 as exc :
706706 logger .warning (f"Exception on sending 'quit()' to OMC: { exc } ! Continue nevertheless ..." )
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
@@ -825,7 +825,7 @@ def execute(self, command: str):
825825
826826 return self .sendExpression (command , parsed = False )
827827
828- def sendExpression (self , command : str , parsed : bool = True ) -> Any :
828+ def sendExpression (self , expr : str , parsed : bool = True ) -> Any :
829829 """
830830 Send an expression to the OMC server and return the result.
831831
@@ -842,12 +842,12 @@ def sendExpression(self, command: str, parsed: bool = True) -> Any:
842842 if self ._omc_zmq is None :
843843 raise OMCSessionException ("No OMC running. Please create a new instance of OMCSession!" )
844844
845- logger .debug ("sendExpression(%r , parsed=%r)" , command , parsed )
845+ logger .debug ("sendExpression(expr='%r' , parsed=%r)" , str ( expr ) , parsed )
846846
847847 attempts = 0
848848 while True :
849849 try :
850- self ._omc_zmq .send_string (str (command ), flags = zmq .NOBLOCK )
850+ self ._omc_zmq .send_string (str (expr ), flags = zmq .NOBLOCK )
851851 break
852852 except zmq .error .Again :
853853 pass
@@ -861,7 +861,7 @@ def sendExpression(self, command: str, parsed: bool = True) -> Any:
861861 raise OMCSessionException (f"No connection with OMC (timeout={ timeout } ). "
862862 f"Log-file says: \n { log_content } " )
863863 time .sleep (timeout / 50.0 )
864- if command == "quit()" :
864+ if expr == "quit()" :
865865 self ._omc_zmq .close ()
866866 self ._omc_zmq = None
867867 return None
@@ -871,13 +871,13 @@ def sendExpression(self, command: str, parsed: bool = True) -> Any:
871871 if result .startswith ('Error occurred building AST' ):
872872 raise OMCSessionException (f"OMC error: { result } " )
873873
874- if command == "getErrorString()" :
874+ if expr == "getErrorString()" :
875875 # no error handling if 'getErrorString()' is called
876876 if parsed :
877877 logger .warning ("Result of 'getErrorString()' cannot be parsed!" )
878878 return result
879879
880- if command == "getMessagesStringInternal()" :
880+ if expr == "getMessagesStringInternal()" :
881881 # no error handling if 'getMessagesStringInternal()' is called
882882 if parsed :
883883 logger .warning ("Result of 'getMessagesStringInternal()' cannot be parsed!" )
@@ -931,7 +931,7 @@ def sendExpression(self, command: str, parsed: bool = True) -> Any:
931931 log_level = log_raw [0 ][8 ]
932932 log_id = log_raw [0 ][9 ]
933933
934- msg_short = (f"[OMC log for 'sendExpression({ command } , { parsed } )']: "
934+ msg_short = (f"[OMC log for 'sendExpression(expr= { expr } , parsed= { parsed } )']: "
935935 f"[{ log_kind } :{ log_level } :{ log_id } ] { log_message } " )
936936
937937 # response according to the used log level
@@ -953,7 +953,7 @@ def sendExpression(self, command: str, parsed: bool = True) -> Any:
953953 msg_long_list .append (msg_long )
954954 if has_error :
955955 msg_long_str = '\n ' .join (f"{ idx :02d} : { msg } " for idx , msg in enumerate (msg_long_list ))
956- raise OMCSessionException (f"OMC error occurred for 'sendExpression({ command } , { parsed } ):\n "
956+ raise OMCSessionException (f"OMC error occurred for 'sendExpression(expr= { expr } , parsed= { parsed } ):\n "
957957 f"{ msg_long_str } " )
958958
959959 if parsed is False :
0 commit comments