@@ -268,7 +268,7 @@ def getClassNames(self, className=None, recursive=False, qualified=False, sort=F
268268 return self ._ask (question = 'getClassNames' , opt = opt )
269269
270270
271- class OMCPathReal (pathlib .PurePosixPath ):
271+ class OMCPath (pathlib .PurePosixPath ):
272272 """
273273 Implementation of a basic Path object which uses OMC as backend. The connection to OMC is provided via a
274274 OMCSessionZMQ session object.
@@ -413,46 +413,6 @@ def size(self) -> int:
413413 raise OMCSessionException (f"Error reading file size for path { self .as_posix ()} !" )
414414
415415
416- if sys .version_info < (3 , 12 ):
417-
418- class OMCPathCompatibility (pathlib .Path ):
419- """
420- Compatibility class for OMCPath in Python < 3.12. This allows to run all code which uses OMCPath (mainly
421- ModelicaSystem) on these Python versions. There is one remaining limitation: only OMCProcessLocal will work as
422- OMCPathCompatibility is based on the standard pathlib.Path implementation.
423- """
424-
425- # modified copy of pathlib.Path.__new__() definition
426- def __new__ (cls , * args , ** kwargs ):
427- logger .warning ("Python < 3.12 - using a version of class OMCPath "
428- "based on pathlib.Path for local usage only." )
429-
430- if cls is OMCPathCompatibility :
431- cls = OMCPathCompatibilityWindows if os .name == 'nt' else OMCPathCompatibilityPosix
432- self = cls ._from_parts (args )
433- if not self ._flavour .is_supported :
434- raise NotImplementedError ("cannot instantiate %r on your system"
435- % (cls .__name__ ,))
436- return self
437-
438- def size (self ) -> int :
439- """
440- Needed compatibility function to have the same interface as OMCPathReal
441- """
442- return self .stat ().st_size
443-
444- class OMCPathCompatibilityPosix (pathlib .PosixPath , OMCPathCompatibility ):
445- pass
446-
447- class OMCPathCompatibilityWindows (pathlib .WindowsPath , OMCPathCompatibility ):
448- pass
449-
450- OMCPath = OMCPathCompatibility
451-
452- else :
453- OMCPath = OMCPathReal
454-
455-
456416class OMCSessionZMQ :
457417
458418 def __init__ (
@@ -511,16 +471,7 @@ def omcpath(self, *path) -> OMCPath:
511471 """
512472 Create an OMCPath object based on the given path segments and the current OMC session.
513473 """
514-
515- # fallback solution for Python < 3.12; a modified pathlib.Path object is used as OMCPath replacement
516- if sys .version_info < (3 , 12 ):
517- if isinstance (self .omc_process , OMCProcessLocal ):
518- # noinspection PyArgumentList
519- return OMCPath (* path )
520- else :
521- raise OMCSessionException ("OMCPath is supported for Python < 3.12 only if OMCProcessLocal is used!" )
522- else :
523- return OMCPath (* path , session = self )
474+ return OMCPath (* path , session = self )
524475
525476 def omcpath_tempdir (self , tempdir_base : Optional [OMCPath ] = None ) -> OMCPath :
526477 """
@@ -530,11 +481,7 @@ def omcpath_tempdir(self, tempdir_base: Optional[OMCPath] = None) -> OMCPath:
530481 names = [str (uuid .uuid4 ()) for _ in range (100 )]
531482
532483 if tempdir_base is None :
533- # fallback solution for Python < 3.12; a modified pathlib.Path object is used as OMCPath replacement
534- if sys .version_info < (3 , 12 ):
535- tempdir_str = tempfile .gettempdir ()
536- else :
537- tempdir_str = self .sendExpression ("getTempDirectoryPath()" )
484+ tempdir_str = self .sendExpression ("getTempDirectoryPath()" )
538485 tempdir_base = self .omcpath (tempdir_str )
539486
540487 tempdir : Optional [OMCPath ] = None
0 commit comments