Skip to content

Commit fa448ea

Browse files
committed
[OMCSession*] fix docstrings
1 parent e4fd725 commit fa448ea

File tree

1 file changed

+28
-29
lines changed

1 file changed

+28
-29
lines changed

OMPython/OMCSession.py

Lines changed: 28 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -286,8 +286,8 @@ def getClassNames(self, className=None, recursive=False, qualified=False, sort=F
286286

287287
class OMCPathReal(pathlib.PurePosixPath):
288288
"""
289-
Implementation of a basic (PurePosix)Path object which uses OMC as backend. The connection to OMC is provided via a
290-
OMCSessionZMQ session object.
289+
Implementation of a basic (PurePosix)Path object which uses OMC as backend. The connection to OMC is provided via an
290+
instances of OMCSession* classes.
291291
292292
PurePosixPath is selected to cover usage of OMC in docker or via WSL. Usage of specialised function could result in
293293
errors as well as usage on a Windows system due to slightly different definitions (PureWindowsPath).
@@ -301,7 +301,7 @@ def with_segments(self, *pathsegments):
301301
"""
302302
Create a new OMCPath object with the given path segments.
303303
304-
The original definition of Path is overridden to ensure session is set.
304+
The original definition of Path is overridden to ensure the OMC session is set.
305305
"""
306306
return type(self)(*pathsegments, session=self._session)
307307

@@ -539,7 +539,7 @@ def get_cmd(self) -> list[str]:
539539

540540
class OMCSessionZMQ:
541541
"""
542-
This class is handling an OMC session. It is a compatibility class for the new schema using OMCProcess* classes.
542+
This class is a compatibility layer for the new schema using OMCSession* classes.
543543
"""
544544

545545
def __init__(
@@ -574,7 +574,7 @@ def escape_str(value: str) -> str:
574574

575575
def omcpath(self, *path) -> OMCPath:
576576
"""
577-
Create an OMCPath object based on the given path segments and the current OMC session.
577+
Create an OMCPath object based on the given path segments and the current OMC process definition.
578578
"""
579579
return self.omc_process.omcpath(*path)
580580

@@ -652,23 +652,22 @@ class OMCSessionMeta(abc.ABCMeta, PostInitCaller):
652652

653653
class OMCSession(metaclass=OMCSessionMeta):
654654
"""
655-
Base class for an OMC session. This class contains common functionality for all OMC sessions.
655+
Base class for an OMC session started via ZMQ. This class contains common functionality for all variants of an
656+
OMC session definition.
656657
657658
The main method is sendExpression() which is used to send commands to the OMC process.
658659
659-
The class expects an OMCProcess* on initialisation. It defines the type of OMC process to use:
660+
The following variants are defined:
660661
661-
* OMCProcessLocal
662+
* OMCSessionLocal
662663
663-
* OMCProcessPort
664+
* OMCSessionPort
664665
665-
* OMCProcessDocker
666+
* OMCSessionDocker
666667
667-
* OMCProcessDockerContainer
668+
* OMCSessionDockerContainer
668669
669-
* OMCProcessWSL
670-
671-
If no OMC process is defined, a local OMC process is initialized.
670+
* OMCSessionWSL
672671
"""
673672

674673
def __init__(
@@ -677,12 +676,12 @@ def __init__(
677676
**kwargs,
678677
) -> None:
679678
"""
680-
Initialisation for OMCProcess
679+
Initialisation for OMCSession
681680
"""
682681

683682
# store variables
684683
self._timeout = timeout
685-
# generate a random string for this session
684+
# generate a random string for this instance of OMC
686685
self._random_string = uuid.uuid4().hex
687686
# get a temporary directory
688687
self._temp_dir = pathlib.Path(tempfile.gettempdir())
@@ -766,15 +765,15 @@ def escape_str(value: str) -> str:
766765

767766
def omcpath(self, *path) -> OMCPath:
768767
"""
769-
Create an OMCPath object based on the given path segments and the current OMC session.
768+
Create an OMCPath object based on the given path segments and the current OMCSession* class.
770769
"""
771770

772771
# fallback solution for Python < 3.12; a modified pathlib.Path object is used as OMCPath replacement
773772
if sys.version_info < (3, 12):
774773
if isinstance(self, OMCSessionLocal):
775774
# noinspection PyArgumentList
776775
return OMCPath(*path)
777-
raise OMCSessionException("OMCPath is supported for Python < 3.12 only if OMCProcessLocal is used!")
776+
raise OMCSessionException("OMCPath is supported for Python < 3.12 only if OMCSessionLocal is used!")
778777
return OMCPath(*path, session=self)
779778

780779
def omcpath_tempdir(self, tempdir_base: Optional[OMCPath] = None) -> OMCPath:
@@ -868,7 +867,7 @@ def sendExpression(self, command: str, parsed: bool = True) -> Any:
868867
timeout = 1.0
869868

870869
if self._omc_zmq is None:
871-
raise OMCSessionException("No OMC running. Please create a new instance of OMCProcess!")
870+
raise OMCSessionException("No OMC running. Please create a new instance of OMCSession!")
872871

873872
logger.debug("sendExpression(%r, parsed=%r)", command, parsed)
874873

@@ -998,7 +997,7 @@ def sendExpression(self, command: str, parsed: bool = True) -> Any:
998997

999998
def get_port(self) -> Optional[str]:
1000999
"""
1001-
Get the port to connect to the OMC process.
1000+
Get the port to connect to the OMC session.
10021001
"""
10031002
if not isinstance(self._omc_port, str):
10041003
raise OMCSessionException(f"Invalid port to connect to OMC process: {self._omc_port}")
@@ -1030,7 +1029,7 @@ def _get_portfile_path(self) -> Optional[pathlib.Path]:
10301029
@abc.abstractmethod
10311030
def omc_run_data_update(self, omc_run_data: OMCSessionRunData) -> OMCSessionRunData:
10321031
"""
1033-
Update the OMCSessionRunData object based on the selected OMCProcess implementation.
1032+
Update the OMCSessionRunData object based on the selected OMCSession implementation.
10341033
10351034
The main point is the definition of OMCSessionRunData.cmd_model_executable which contains the specific command
10361035
to run depending on the selected system.
@@ -1042,7 +1041,7 @@ def omc_run_data_update(self, omc_run_data: OMCSessionRunData) -> OMCSessionRunD
10421041

10431042
class OMCSessionPort(OMCSession):
10441043
"""
1045-
OMCProcess implementation which uses a port to connect to an already running OMC server.
1044+
OMCSession implementation which uses a port to connect to an already running OMC server.
10461045
"""
10471046

10481047
def __init__(
@@ -1054,14 +1053,14 @@ def __init__(
10541053

10551054
def omc_run_data_update(self, omc_run_data: OMCSessionRunData) -> OMCSessionRunData:
10561055
"""
1057-
Update the OMCSessionRunData object based on the selected OMCProcess implementation.
1056+
Update the OMCSessionRunData object based on the selected OMCSession implementation.
10581057
"""
1059-
raise OMCSessionException("OMCProcessPort does not support omc_run_data_update()!")
1058+
raise OMCSessionException("OMCSessionPort does not support omc_run_data_update()!")
10601059

10611060

10621061
class OMCSessionLocal(OMCSession):
10631062
"""
1064-
OMCProcess implementation which runs the OMC server locally on the machine (Linux / Windows).
1063+
OMCSession implementation which runs the OMC server locally on the machine (Linux / Windows).
10651064
"""
10661065

10671066
def __init__(
@@ -1144,7 +1143,7 @@ def _omc_port_get(self) -> str:
11441143

11451144
def omc_run_data_update(self, omc_run_data: OMCSessionRunData) -> OMCSessionRunData:
11461145
"""
1147-
Update the OMCSessionRunData object based on the selected OMCProcess implementation.
1146+
Update the OMCSessionRunData object based on the selected OMCSession implementation.
11481147
"""
11491148
# create a copy of the data
11501149
omc_run_data_copy = dataclasses.replace(omc_run_data)
@@ -1187,7 +1186,7 @@ def omc_run_data_update(self, omc_run_data: OMCSessionRunData) -> OMCSessionRunD
11871186

11881187
class OMCSessionDockerHelper(OMCSession):
11891188
"""
1190-
Base class for OMCProcess implementations which run the OMC server in a Docker container.
1189+
Base class for OMCSession implementations which run the OMC server in a Docker container.
11911190
"""
11921191

11931192
def __init__(
@@ -1301,7 +1300,7 @@ def get_docker_container_id(self) -> str:
13011300

13021301
def omc_run_data_update(self, omc_run_data: OMCSessionRunData) -> OMCSessionRunData:
13031302
"""
1304-
Update the OMCSessionRunData object based on the selected OMCProcess implementation.
1303+
Update the OMCSessionRunData object based on the selected OMCSession implementation.
13051304
"""
13061305
omc_run_data_copy = dataclasses.replace(omc_run_data)
13071306

@@ -1646,7 +1645,7 @@ def _omc_port_get(self) -> str:
16461645

16471646
def omc_run_data_update(self, omc_run_data: OMCSessionRunData) -> OMCSessionRunData:
16481647
"""
1649-
Update the OMCSessionRunData object based on the selected OMCProcess implementation.
1648+
Update the OMCSessionRunData object based on the selected OMCSession implementation.
16501649
"""
16511650
omc_run_data_copy = dataclasses.replace(omc_run_data)
16521651

0 commit comments

Comments
 (0)