@@ -64,7 +64,7 @@ class OMCSessionException(Exception):
6464 """
6565
6666
67- class OMPathBase (pathlib .PurePosixPath , metaclass = abc .ABCMeta ):
67+ class PathBase (pathlib .PurePosixPath , metaclass = abc .ABCMeta ):
6868 """
6969 Implementation of a basic (PurePosix)Path object to be used within OMPython. The derived classes can use OMC as
7070 backend and - thus - work on different configurations like docker or WSL. The connection to OMC is provided via an
@@ -75,7 +75,7 @@ class OMPathBase(pathlib.PurePosixPath, metaclass=abc.ABCMeta):
7575 compared to standard pathlib.Path objects.
7676 """
7777
78- def __init__ (self , * path , session : OMSessionBase ) -> None :
78+ def __init__ (self , * path , session : SessionBase ) -> None :
7979 super ().__init__ (* path )
8080 self ._session = session
8181
@@ -164,7 +164,7 @@ def size(self) -> int:
164164 """
165165
166166
167- class _OMCPath (OMPathBase ):
167+ class _OMCPath (PathBase ):
168168 """
169169 Implementation of a OMPathBase using OMC as backend. The connection to OMC is provided via an instances of an
170170 OMCSession* classes.
@@ -290,7 +290,7 @@ def size(self) -> int:
290290 raise OMCSessionException (f"Error reading file size for path { self .as_posix ()} !" )
291291
292292
293- class _OMPathRunner ( OMPathBase ):
293+ class _PathRunner ( PathBase ):
294294 """
295295 Implementation of OMPathBase which does not use the session data at all. Thus, this implementation can run locally
296296 without any usage of OMC.
@@ -373,7 +373,7 @@ def size(self) -> int:
373373 return path .stat ().st_size
374374
375375
376- class OMPathCompatibility (pathlib .Path ):
376+ class PathCompatibility (pathlib .Path ):
377377 """
378378 Compatibility class for OMPathBase in Python < 3.12. This allows to run all code which uses OMPathBase (mainly
379379 ModelicaSystem) on these Python versions. There are remaining limitation as only local execution is possible.
@@ -384,8 +384,8 @@ def __new__(cls, *args, **kwargs):
384384 logger .warning ("Python < 3.12 - using a version of class OMCPath "
385385 "based on pathlib.Path for local usage only." )
386386
387- if cls is OMPathCompatibility :
388- cls = OMPathCompatibilityWindows if os .name == 'nt' else OMPathCompatibilityPosix
387+ if cls is PathCompatibility :
388+ cls = PathCompatibilityWindows if os .name == 'nt' else PathCompatibilityPosix
389389 self = cls ._from_parts (args )
390390 if not self ._flavour .is_supported :
391391 raise NotImplementedError (f"cannot instantiate { cls .__name__ } on your system" )
@@ -398,24 +398,24 @@ def size(self) -> int:
398398 return self .stat ().st_size
399399
400400
401- class OMPathCompatibilityPosix (pathlib .PosixPath , OMPathCompatibility ):
401+ class PathCompatibilityPosix (pathlib .PosixPath , PathCompatibility ):
402402 """
403403 Compatibility class for OMCPath on Posix systems (Python < 3.12)
404404 """
405405
406406
407- class OMPathCompatibilityWindows (pathlib .WindowsPath , OMPathCompatibility ):
407+ class PathCompatibilityWindows (pathlib .WindowsPath , PathCompatibility ):
408408 """
409409 Compatibility class for OMCPath on Windows systems (Python < 3.12)
410410 """
411411
412412
413413if sys .version_info < (3 , 12 ):
414- OMCPath = OMPathCompatibility
415- OMCPathDummy = OMPathCompatibility
414+ OMCPath = PathCompatibility
415+ OMCPathDummy = PathCompatibility
416416else :
417417 OMCPath = _OMCPath
418- OMCPathDummy = _OMPathRunner
418+ OMCPathDummy = _PathRunner
419419
420420
421421# TODO: OMCSessionCMd => separate file; based on OMCSessionZMQ?
@@ -455,13 +455,13 @@ def escape_str(value: str) -> str:
455455 """
456456 return OMCSession .escape_str (value = value )
457457
458- def omcpath (self , * path ) -> OMPathBase :
458+ def omcpath (self , * path ) -> PathBase :
459459 """
460460 Create an OMCPath object based on the given path segments and the current OMC process definition.
461461 """
462462 return self .omc_process .omcpath (* path )
463463
464- def omcpath_tempdir (self , tempdir_base : Optional [OMPathBase ] = None ) -> OMPathBase :
464+ def omcpath_tempdir (self , tempdir_base : Optional [PathBase ] = None ) -> PathBase :
465465 """
466466 Get a temporary directory using OMC. It is our own implementation as non-local usage relies on OMC to run all
467467 filesystem related access.
@@ -510,7 +510,7 @@ def __call__(cls, *args, **kwargs):
510510
511511# TODO: define BaseSession / RunnerSession(BaseSession)
512512# TODO: define OMCSession(BaseSession)
513- class OMSessionMeta (abc .ABCMeta , PostInitCaller ):
513+ class SessionMeta (abc .ABCMeta , PostInitCaller ):
514514 """
515515 Helper class to get a combined metaclass of ABCMeta and PostInitCaller.
516516
@@ -519,7 +519,7 @@ class OMSessionMeta(abc.ABCMeta, PostInitCaller):
519519 """
520520
521521
522- class OMSessionBase (metaclass = OMSessionMeta ):
522+ class SessionBase (metaclass = SessionMeta ):
523523 """
524524 This class implements the basic structure a OMPython session definition needs. It provides the structure for an
525525 implementation using OMC as backend (via ZMQ) or a dummy implementation which just runs a model executable.
@@ -554,7 +554,7 @@ def escape_str(value: str) -> str:
554554 return value .replace ("\\ " , "\\ \\ " ).replace ('"' , '\\ "' )
555555
556556 @abc .abstractmethod
557- def model_execution_prefix (self , cwd : Optional [OMPathBase ] = None ) -> list [str ]:
557+ def model_execution_prefix (self , cwd : Optional [PathBase ] = None ) -> list [str ]:
558558 """
559559 Helper function which returns a command prefix.
560560 """
@@ -566,28 +566,28 @@ def get_version(self) -> str:
566566 """
567567
568568 @abc .abstractmethod
569- def set_workdir (self , workdir : OMPathBase ) -> None :
569+ def set_workdir (self , workdir : PathBase ) -> None :
570570 """
571571 Set the workdir for this session.
572572 """
573573
574574 @abc .abstractmethod
575- def omcpath (self , * path ) -> OMPathBase :
575+ def omcpath (self , * path ) -> PathBase :
576576 """
577577 Create an OMPathBase object based on the given path segments and the current class.
578578 """
579579
580580 @abc .abstractmethod
581- def omcpath_tempdir (self , tempdir_base : Optional [OMCPath ] = None ) -> OMPathBase :
581+ def omcpath_tempdir (self , tempdir_base : Optional [OMCPath ] = None ) -> PathBase :
582582 """
583583 Get a temporary directory based on the specific definition for this session.
584584 """
585585
586586 @staticmethod
587- def _tempdir (tempdir_base : OMPathBase ) -> OMPathBase :
587+ def _tempdir (tempdir_base : PathBase ) -> PathBase :
588588 names = [str (uuid .uuid4 ()) for _ in range (100 )]
589589
590- tempdir : Optional [OMPathBase ] = None
590+ tempdir : Optional [PathBase ] = None
591591 for name in names :
592592 # create a unique temporary directory name
593593 tempdir = tempdir_base / name
@@ -610,7 +610,7 @@ def sendExpression(self, command: str, parsed: bool = True) -> Any:
610610 """
611611
612612
613- class OMCSession (OMSessionBase ):
613+ class OMCSession (SessionBase ):
614614 """
615615 Base class for an OMC session started via ZMQ. This class contains common functionality for all variants of an
616616 OMC session definition.
@@ -727,7 +727,7 @@ def escape_str(value: str) -> str:
727727 """
728728 return value .replace ("\\ " , "\\ \\ " ).replace ('"' , '\\ "' )
729729
730- def model_execution_prefix (self , cwd : Optional [OMPathBase ] = None ) -> list [str ]:
730+ def model_execution_prefix (self , cwd : Optional [PathBase ] = None ) -> list [str ]:
731731 """
732732 Helper function which returns a command prefix needed for docker and WSL. It defaults to an empty list.
733733 """
@@ -739,14 +739,14 @@ def get_version(self) -> str:
739739 """
740740 return self .sendExpression ("getVersion()" , parsed = True )
741741
742- def set_workdir (self , workdir : OMPathBase ) -> None :
742+ def set_workdir (self , workdir : PathBase ) -> None :
743743 """
744744 Set the workdir for this session.
745745 """
746746 exp = f'cd("{ workdir .as_posix ()} ")'
747747 self .sendExpression (exp )
748748
749- def omcpath (self , * path ) -> OMPathBase :
749+ def omcpath (self , * path ) -> PathBase :
750750 """
751751 Create an OMCPath object based on the given path segments and the current OMCSession* class.
752752 """
@@ -759,7 +759,7 @@ def omcpath(self, *path) -> OMPathBase:
759759 raise OMCSessionException ("OMCPath is supported for Python < 3.12 only if OMCSessionLocal is used!" )
760760 return OMCPath (* path , session = self )
761761
762- def omcpath_tempdir (self , tempdir_base : Optional [OMPathBase ] = None ) -> OMPathBase :
762+ def omcpath_tempdir (self , tempdir_base : Optional [PathBase ] = None ) -> PathBase :
763763 """
764764 Get a temporary directory using OMC. It is our own implementation as non-local usage relies on OMC to run all
765765 filesystem related access.
@@ -776,10 +776,10 @@ def omcpath_tempdir(self, tempdir_base: Optional[OMPathBase] = None) -> OMPathBa
776776 return self ._tempdir (tempdir_base = tempdir_base )
777777
778778 @staticmethod
779- def _tempdir (tempdir_base : OMPathBase ) -> OMPathBase :
779+ def _tempdir (tempdir_base : PathBase ) -> PathBase :
780780 names = [str (uuid .uuid4 ()) for _ in range (100 )]
781781
782- tempdir : Optional [OMPathBase ] = None
782+ tempdir : Optional [PathBase ] = None
783783 for name in names :
784784 # create a unique temporary directory name
785785 tempdir = tempdir_base / name
@@ -980,7 +980,7 @@ def _get_portfile_path(self) -> Optional[pathlib.Path]:
980980 return portfile_path
981981
982982
983- class OMSessionRunner ( OMSessionBase ):
983+ class SessionRunner ( SessionBase ):
984984 """
985985 Dummy OMCSession implementation without any use of an OMC server.
986986 """
@@ -999,7 +999,7 @@ def __post_init__(self) -> None:
999999 No connection to an OMC server is created by this class!
10001000 """
10011001
1002- def model_execution_prefix (self , cwd : Optional [OMPathBase ] = None ) -> list [str ]:
1002+ def model_execution_prefix (self , cwd : Optional [PathBase ] = None ) -> list [str ]:
10031003 """
10041004 Helper function which returns a command prefix.
10051005 """
@@ -1012,19 +1012,19 @@ def get_version(self) -> str:
10121012 """
10131013 return self ._version
10141014
1015- def set_workdir (self , workdir : OMPathBase ) -> None :
1015+ def set_workdir (self , workdir : PathBase ) -> None :
10161016 """
10171017 Set the workdir for this session.
10181018 """
10191019 os .chdir (workdir .as_posix ())
10201020
1021- def omcpath (self , * path ) -> OMPathBase :
1021+ def omcpath (self , * path ) -> PathBase :
10221022 """
10231023 Create an OMCPath object based on the given path segments and the current OMCSession* class.
10241024 """
10251025 return OMCPathDummy (* path , session = self )
10261026
1027- def omcpath_tempdir (self , tempdir_base : Optional [OMPathBase ] = None ) -> OMPathBase :
1027+ def omcpath_tempdir (self , tempdir_base : Optional [PathBase ] = None ) -> PathBase :
10281028 """
10291029 Get a temporary directory without using OMC.
10301030 """
@@ -1252,15 +1252,15 @@ def get_docker_container_id(self) -> str:
12521252
12531253 return self ._docker_container_id
12541254
1255- def model_execution_prefix (self , cwd : Optional [OMPathBase ] = None ) -> list [str ]:
1255+ def model_execution_prefix (self , cwd : Optional [PathBase ] = None ) -> list [str ]:
12561256 """
12571257 Helper function which returns a command prefix needed for docker and WSL. It defaults to an empty list.
12581258 """
12591259 docker_cmd = [
12601260 "docker" , "exec" ,
12611261 "--user" , str (self ._getuid ()),
1262- ]
1263- if isinstance (cwd , OMPathBase ):
1262+ ]
1263+ if isinstance (cwd , PathBase ):
12641264 docker_cmd += ["--workdir" , cwd .as_posix ()]
12651265 docker_cmd += self ._docker_extra_args
12661266 if isinstance (self ._docker_container_id , str ):
@@ -1530,7 +1530,7 @@ def __init__(
15301530 # connect to the running omc instance using ZMQ
15311531 self ._omc_port = self ._omc_port_get ()
15321532
1533- def model_execution_prefix (self , cwd : Optional [OMPathBase ] = None ) -> list [str ]:
1533+ def model_execution_prefix (self , cwd : Optional [PathBase ] = None ) -> list [str ]:
15341534 """
15351535 Helper function which returns a command prefix needed for docker and WSL. It defaults to an empty list.
15361536 """
@@ -1540,7 +1540,7 @@ def model_execution_prefix(self, cwd: Optional[OMPathBase] = None) -> list[str]:
15401540 wsl_cmd += ['--distribution' , self ._wsl_distribution ]
15411541 if isinstance (self ._wsl_user , str ):
15421542 wsl_cmd += ['--user' , self ._wsl_user ]
1543- if isinstance (cwd , OMPathBase ):
1543+ if isinstance (cwd , PathBase ):
15441544 wsl_cmd += ['--cd' , cwd .as_posix ()]
15451545 wsl_cmd += ['--' ]
15461546
@@ -1553,7 +1553,8 @@ def _omc_process_get(self) -> subprocess.Popen:
15531553 self ._wsl_omc ,
15541554 "--locale=C" ,
15551555 "--interactive=zmq" ,
1556- f"-z={ self ._random_string } " ]
1556+ f"-z={ self ._random_string } " ,
1557+ ]
15571558
15581559 omc_process = subprocess .Popen (omc_command ,
15591560 stdout = self ._omc_loghandle ,
0 commit comments