@@ -274,13 +274,13 @@ def is_file(self, *, follow_symlinks=True) -> bool:
274274 """
275275 Check if the path is a regular file.
276276 """
277- return self ._session .sendExpression (f'regularFileExists("{ self .as_posix ()} ")' )
277+ return self ._session .sendExpression (expr = f'regularFileExists("{ self .as_posix ()} ")' )
278278
279279 def is_dir (self , * , follow_symlinks = True ) -> bool :
280280 """
281281 Check if the path is a directory.
282282 """
283- return self ._session .sendExpression (f'directoryExists("{ self .as_posix ()} ")' )
283+ return self ._session .sendExpression (expr = f'directoryExists("{ self .as_posix ()} ")' )
284284
285285 def is_absolute (self ):
286286 """
@@ -298,7 +298,7 @@ def read_text(self, encoding=None, errors=None, newline=None) -> str:
298298 The additional arguments `encoding`, `errors` and `newline` are only defined for compatibility with Path()
299299 definition.
300300 """
301- return self ._session .sendExpression (f'readFile("{ self .as_posix ()} ")' )
301+ return self ._session .sendExpression (expr = f'readFile("{ self .as_posix ()} ")' )
302302
303303 def write_text (self , data : str , encoding = None , errors = None , newline = None ):
304304 """
@@ -311,7 +311,7 @@ def write_text(self, data: str, encoding=None, errors=None, newline=None):
311311 raise TypeError (f"data must be str, not { data .__class__ .__name__ } " )
312312
313313 data_omc = self ._session .escape_str (data )
314- self ._session .sendExpression (f'writeFile("{ self .as_posix ()} ", "{ data_omc } ", false);' )
314+ self ._session .sendExpression (expr = f'writeFile("{ self .as_posix ()} ", "{ data_omc } ", false);' )
315315
316316 return len (data )
317317
@@ -324,20 +324,20 @@ def mkdir(self, mode=0o777, parents=False, exist_ok=False):
324324 if self .is_dir () and not exist_ok :
325325 raise FileExistsError (f"Directory { self .as_posix ()} already exists!" )
326326
327- return self ._session .sendExpression (f'mkdir("{ self .as_posix ()} ")' )
327+ return self ._session .sendExpression (expr = f'mkdir("{ self .as_posix ()} ")' )
328328
329329 def cwd (self ):
330330 """
331331 Returns the current working directory as an OMCPath object.
332332 """
333- cwd_str = self ._session .sendExpression ('cd()' )
333+ cwd_str = self ._session .sendExpression (expr = 'cd()' )
334334 return OMCPath (cwd_str , session = self ._session )
335335
336336 def unlink (self , missing_ok : bool = False ) -> None :
337337 """
338338 Unlink (delete) the file or directory represented by this path.
339339 """
340- res = self ._session .sendExpression (f'deleteFile("{ self .as_posix ()} ")' )
340+ res = self ._session .sendExpression (expr = f'deleteFile("{ self .as_posix ()} ")' )
341341 if not res and not missing_ok :
342342 raise FileNotFoundError (f"Cannot delete file { self .as_posix ()} - it does not exists!" )
343343
@@ -367,12 +367,12 @@ def _omc_resolve(self, pathstr: str) -> str:
367367 Internal function to resolve the path of the OMCPath object using OMC functions *WITHOUT* changing the cwd
368368 within OMC.
369369 """
370- expression = ('omcpath_cwd := cd(); '
371- f'omcpath_check := cd("{ pathstr } "); ' # check requested pathstring
372- 'cd(omcpath_cwd)' )
370+ expr = ('omcpath_cwd := cd(); '
371+ f'omcpath_check := cd("{ pathstr } "); ' # check requested pathstring
372+ 'cd(omcpath_cwd)' )
373373
374374 try :
375- result = self ._session .sendExpression (command = expression , parsed = False )
375+ result = self ._session .sendExpression (expr = expr , parsed = False )
376376 result_parts = result .split ('\n ' )
377377 pathstr_resolved = result_parts [1 ]
378378 pathstr_resolved = pathstr_resolved [1 :- 1 ] # remove quotes
@@ -401,7 +401,7 @@ def size(self) -> int:
401401 if not self .is_file ():
402402 raise OMCSessionException (f"Path { self .as_posix ()} is not a file!" )
403403
404- res = self ._session .sendExpression (f'stat("{ self .as_posix ()} ")' )
404+ res = self ._session .sendExpression (expr = f'stat("{ self .as_posix ()} ")' )
405405 if res [0 ]:
406406 return int (res [1 ])
407407
@@ -573,7 +573,7 @@ def sendExpression(self, command: str, parsed: bool = True) -> Any:
573573 The complete error handling of the OMC result is done within this method using '"getMessagesStringInternal()'.
574574 Caller should only check for OMCSessionException.
575575 """
576- return self .omc_process .sendExpression (command = command , parsed = parsed )
576+ return self .omc_process .sendExpression (expr = command , parsed = parsed )
577577
578578
579579class PostInitCaller (type ):
@@ -695,7 +695,7 @@ def __post_init__(self) -> None:
695695 def __del__ (self ):
696696 if isinstance (self ._omc_zmq , zmq .Socket ):
697697 try :
698- self .sendExpression ("quit()" )
698+ self .sendExpression (expr = "quit()" )
699699 except OMCSessionException as exc :
700700 logger .warning (f"Exception on sending 'quit()' to OMC: { exc } ! Continue nevertheless ..." )
701701 finally :
@@ -791,7 +791,7 @@ def omcpath_tempdir(self, tempdir_base: Optional[OMCPath] = None) -> OMCPath:
791791 if sys .version_info < (3 , 12 ):
792792 tempdir_str = tempfile .gettempdir ()
793793 else :
794- tempdir_str = self .sendExpression ("getTempDirectoryPath()" )
794+ tempdir_str = self .sendExpression (expr = "getTempDirectoryPath()" )
795795 tempdir_base = self .omcpath (tempdir_str )
796796
797797 tempdir : Optional [OMCPath ] = None
@@ -858,7 +858,7 @@ def execute(self, command: str):
858858
859859 return self .sendExpression (command , parsed = False )
860860
861- def sendExpression (self , command : str , parsed : bool = True ) -> Any :
861+ def sendExpression (self , expr : str , parsed : bool = True ) -> Any :
862862 """
863863 Send an expression to the OMC server and return the result.
864864
@@ -869,12 +869,12 @@ def sendExpression(self, command: str, parsed: bool = True) -> Any:
869869 if self ._omc_zmq is None :
870870 raise OMCSessionException ("No OMC running. Please create a new instance of OMCSession!" )
871871
872- logger .debug ("sendExpression(%r , parsed=%r)" , command , parsed )
872+ logger .debug ("sendExpression(expr='%r' , parsed=%r)" , str ( expr ) , parsed )
873873
874874 loop = self ._timeout_loop (timestep = 0.05 )
875875 while next (loop ):
876876 try :
877- self ._omc_zmq .send_string (str (command ), flags = zmq .NOBLOCK )
877+ self ._omc_zmq .send_string (str (expr ), flags = zmq .NOBLOCK )
878878 break
879879 except zmq .error .Again :
880880 pass
@@ -888,7 +888,7 @@ def sendExpression(self, command: str, parsed: bool = True) -> Any:
888888 logger .error (f"OMC did not start. Log-file says:\n { log_content } " )
889889 raise OMCSessionException (f"No connection with OMC (timeout={ self ._timeout } )." )
890890
891- if command == "quit()" :
891+ if expr == "quit()" :
892892 self ._omc_zmq .close ()
893893 self ._omc_zmq = None
894894 return None
@@ -898,13 +898,13 @@ def sendExpression(self, command: str, parsed: bool = True) -> Any:
898898 if result .startswith ('Error occurred building AST' ):
899899 raise OMCSessionException (f"OMC error: { result } " )
900900
901- if command == "getErrorString()" :
901+ if expr == "getErrorString()" :
902902 # no error handling if 'getErrorString()' is called
903903 if parsed :
904904 logger .warning ("Result of 'getErrorString()' cannot be parsed!" )
905905 return result
906906
907- if command == "getMessagesStringInternal()" :
907+ if expr == "getMessagesStringInternal()" :
908908 # no error handling if 'getMessagesStringInternal()' is called
909909 if parsed :
910910 logger .warning ("Result of 'getMessagesStringInternal()' cannot be parsed!" )
@@ -958,7 +958,7 @@ def sendExpression(self, command: str, parsed: bool = True) -> Any:
958958 log_level = log_raw [0 ][8 ]
959959 log_id = log_raw [0 ][9 ]
960960
961- msg_short = (f"[OMC log for 'sendExpression({ command } , { parsed } )']: "
961+ msg_short = (f"[OMC log for 'sendExpression(expr= { expr } , parsed= { parsed } )']: "
962962 f"[{ log_kind } :{ log_level } :{ log_id } ] { log_message } " )
963963
964964 # response according to the used log level
@@ -980,7 +980,7 @@ def sendExpression(self, command: str, parsed: bool = True) -> Any:
980980 msg_long_list .append (msg_long )
981981 if has_error :
982982 msg_long_str = '\n ' .join (f"{ idx :02d} : { msg } " for idx , msg in enumerate (msg_long_list ))
983- raise OMCSessionException (f"OMC error occurred for 'sendExpression({ command } , { parsed } ):\n "
983+ raise OMCSessionException (f"OMC error occurred for 'sendExpression(expr= { expr } , parsed= { parsed } ):\n "
984984 f"{ msg_long_str } " )
985985
986986 if not parsed :
0 commit comments