@@ -284,7 +284,7 @@ def getClassNames(self, className=None, recursive=False, qualified=False, sort=F
284284 return self ._ask (question = 'getClassNames' , opt = opt )
285285
286286
287- class OMCPathReal (pathlib .PurePosixPath ):
287+ class OMCPath (pathlib .PurePosixPath ):
288288 """
289289 Implementation of a basic (PurePosix)Path object which uses OMC as backend. The connection to OMC is provided via a
290290 OMCSessionZMQ session object.
@@ -450,49 +450,6 @@ def stat(self):
450450 "use size() to get the file size." )
451451
452452
453- if sys .version_info < (3 , 12 ):
454-
455- class OMCPathCompatibility (pathlib .Path ):
456- """
457- Compatibility class for OMCPath in Python < 3.12. This allows to run all code which uses OMCPath (mainly
458- ModelicaSystem) on these Python versions. There is one remaining limitation: only OMCProcessLocal will work as
459- OMCPathCompatibility is based on the standard pathlib.Path implementation.
460- """
461-
462- # modified copy of pathlib.Path.__new__() definition
463- def __new__ (cls , * args , ** kwargs ):
464- logger .warning ("Python < 3.12 - using a version of class OMCPath "
465- "based on pathlib.Path for local usage only." )
466-
467- if cls is OMCPathCompatibility :
468- cls = OMCPathCompatibilityWindows if os .name == 'nt' else OMCPathCompatibilityPosix
469- self = cls ._from_parts (args )
470- if not self ._flavour .is_supported :
471- raise NotImplementedError (f"cannot instantiate { cls .__name__ } on your system" )
472- return self
473-
474- def size (self ) -> int :
475- """
476- Needed compatibility function to have the same interface as OMCPathReal
477- """
478- return self .stat ().st_size
479-
480- class OMCPathCompatibilityPosix (pathlib .PosixPath , OMCPathCompatibility ):
481- """
482- Compatibility class for OMCPath on Posix systems (Python < 3.12)
483- """
484-
485- class OMCPathCompatibilityWindows (pathlib .WindowsPath , OMCPathCompatibility ):
486- """
487- Compatibility class for OMCPath on Windows systems (Python < 3.12)
488- """
489-
490- OMCPath = OMCPathCompatibility
491-
492- else :
493- OMCPath = OMCPathReal
494-
495-
496453@dataclasses .dataclass
497454class OMCSessionRunData :
498455 """
@@ -615,13 +572,6 @@ def omcpath(self, *path) -> OMCPath:
615572 """
616573 Create an OMCPath object based on the given path segments and the current OMC session.
617574 """
618-
619- # fallback solution for Python < 3.12; a modified pathlib.Path object is used as OMCPath replacement
620- if sys .version_info < (3 , 12 ):
621- if isinstance (self .omc_process , OMCProcessLocal ):
622- # noinspection PyArgumentList
623- return OMCPath (* path )
624- raise OMCSessionException ("OMCPath is supported for Python < 3.12 only if OMCProcessLocal is used!" )
625575 return OMCPath (* path , session = self )
626576
627577 def omcpath_tempdir (self , tempdir_base : Optional [OMCPath ] = None ) -> OMCPath :
@@ -632,11 +582,7 @@ def omcpath_tempdir(self, tempdir_base: Optional[OMCPath] = None) -> OMCPath:
632582 names = [str (uuid .uuid4 ()) for _ in range (100 )]
633583
634584 if tempdir_base is None :
635- # fallback solution for Python < 3.12; a modified pathlib.Path object is used as OMCPath replacement
636- if sys .version_info < (3 , 12 ):
637- tempdir_str = tempfile .gettempdir ()
638- else :
639- tempdir_str = self .sendExpression ("getTempDirectoryPath()" )
585+ tempdir_str = self .sendExpression ("getTempDirectoryPath()" )
640586 tempdir_base = self .omcpath (tempdir_str )
641587
642588 tempdir : Optional [OMCPath ] = None
0 commit comments