Skip to content

Commit 9b338bb

Browse files
committed
[OMCSession*] fix docstrings
1 parent 686710c commit 9b338bb

1 file changed

Lines changed: 28 additions & 27 deletions

File tree

OMPython/OMCSession.py

Lines changed: 28 additions & 27 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

@@ -649,21 +649,22 @@ class OMCSessionMeta(abc.ABCMeta, PostInitCaller):
649649

650650
class OMCSession(metaclass=OMCSessionMeta):
651651
"""
652-
Base class for an OMC session. This class contains common functionality for all OMC sessions.
652+
Base class for an OMC session started via ZMQ. This class contains common functionality for all variants of an
653+
OMC session definition.
653654
654655
The main method is sendExpression() which is used to send commands to the OMC process.
655656
656-
The class expects an OMCProcess* on initialisation. It defines the type of OMC process to use:
657+
The following variants are defined:
657658
658-
* OMCProcessLocal
659+
* OMCSessionLocal
659660
660-
* OMCProcessPort
661+
* OMCSessionPort
661662
662-
* OMCProcessDocker
663+
* OMCSessionDocker
663664
664-
* OMCProcessDockerContainer
665+
* OMCSessionDockerContainer
665666
666-
* OMCProcessWSL
667+
* OMCSessionWSL
667668
668669
If no OMC process is defined, a local OMC process is initialized.
669670
"""
@@ -674,12 +675,12 @@ def __init__(
674675
**kwargs,
675676
) -> None:
676677
"""
677-
Initialisation for OMCProcess
678+
Initialisation for OMCSession
678679
"""
679680

680681
# store variables
681682
self._timeout = timeout
682-
# generate a random string for this session
683+
# generate a random string for this instance of OMC
683684
self._random_string = uuid.uuid4().hex
684685
# get a temporary directory
685686
self._temp_dir = pathlib.Path(tempfile.gettempdir())
@@ -763,15 +764,15 @@ def escape_str(value: str) -> str:
763764

764765
def omcpath(self, *path) -> OMCPath:
765766
"""
766-
Create an OMCPath object based on the given path segments and the current OMC session.
767+
Create an OMCPath object based on the given path segments and the current OMCSession* class.
767768
"""
768769

769770
# fallback solution for Python < 3.12; a modified pathlib.Path object is used as OMCPath replacement
770771
if sys.version_info < (3, 12):
771772
if isinstance(self, OMCSessionLocal):
772773
# noinspection PyArgumentList
773774
return OMCPath(*path)
774-
raise OMCSessionException("OMCPath is supported for Python < 3.12 only if OMCProcessLocal is used!")
775+
raise OMCSessionException("OMCPath is supported for Python < 3.12 only if OMCSessionLocal is used!")
775776
return OMCPath(*path, session=self)
776777

777778
def omcpath_tempdir(self, tempdir_base: Optional[OMCPath] = None) -> OMCPath:
@@ -865,7 +866,7 @@ def sendExpression(self, command: str, parsed: bool = True) -> Any:
865866
timeout = 1.0
866867

867868
if self._omc_zmq is None:
868-
raise OMCSessionException("No OMC running. Please create a new instance of OMCProcess!")
869+
raise OMCSessionException("No OMC running. Please create a new instance of OMCSession!")
869870

870871
logger.debug("sendExpression(%r, parsed=%r)", command, parsed)
871872

@@ -995,7 +996,7 @@ def sendExpression(self, command: str, parsed: bool = True) -> Any:
995996

996997
def get_port(self) -> Optional[str]:
997998
"""
998-
Get the port to connect to the OMC process.
999+
Get the port to connect to the OMC session.
9991000
"""
10001001
if not isinstance(self._omc_port, str):
10011002
raise OMCSessionException(f"Invalid port to connect to OMC process: {self._omc_port}")
@@ -1027,7 +1028,7 @@ def _get_portfile_path(self) -> Optional[pathlib.Path]:
10271028
@abc.abstractmethod
10281029
def omc_run_data_update(self, omc_run_data: OMCSessionRunData) -> OMCSessionRunData:
10291030
"""
1030-
Update the OMCSessionRunData object based on the selected OMCProcess implementation.
1031+
Update the OMCSessionRunData object based on the selected OMCSession implementation.
10311032
10321033
The main point is the definition of OMCSessionRunData.cmd_model_executable which contains the specific command
10331034
to run depending on the selected system.
@@ -1039,7 +1040,7 @@ def omc_run_data_update(self, omc_run_data: OMCSessionRunData) -> OMCSessionRunD
10391040

10401041
class OMCSessionPort(OMCSession):
10411042
"""
1042-
OMCProcess implementation which uses a port to connect to an already running OMC server.
1043+
OMCSession implementation which uses a port to connect to an already running OMC server.
10431044
"""
10441045

10451046
def __init__(
@@ -1051,14 +1052,14 @@ def __init__(
10511052

10521053
def omc_run_data_update(self, omc_run_data: OMCSessionRunData) -> OMCSessionRunData:
10531054
"""
1054-
Update the OMCSessionRunData object based on the selected OMCProcess implementation.
1055+
Update the OMCSessionRunData object based on the selected OMCSession implementation.
10551056
"""
1056-
raise OMCSessionException("OMCProcessPort does not support omc_run_data_update()!")
1057+
raise OMCSessionException("OMCSessionPort does not support omc_run_data_update()!")
10571058

10581059

10591060
class OMCSessionLocal(OMCSession):
10601061
"""
1061-
OMCProcess implementation which runs the OMC server locally on the machine (Linux / Windows).
1062+
OMCSession implementation which runs the OMC server locally on the machine (Linux / Windows).
10621063
"""
10631064

10641065
def __init__(
@@ -1141,7 +1142,7 @@ def _omc_port_get(self) -> str:
11411142

11421143
def omc_run_data_update(self, omc_run_data: OMCSessionRunData) -> OMCSessionRunData:
11431144
"""
1144-
Update the OMCSessionRunData object based on the selected OMCProcess implementation.
1145+
Update the OMCSessionRunData object based on the selected OMCSession implementation.
11451146
"""
11461147
# create a copy of the data
11471148
omc_run_data_copy = dataclasses.replace(omc_run_data)
@@ -1184,7 +1185,7 @@ def omc_run_data_update(self, omc_run_data: OMCSessionRunData) -> OMCSessionRunD
11841185

11851186
class OMCSessionDockerHelper(OMCSession):
11861187
"""
1187-
Base class for OMCProcess implementations which run the OMC server in a Docker container.
1188+
Base class for OMCSession implementations which run the OMC server in a Docker container.
11881189
"""
11891190

11901191
def __init__(
@@ -1298,7 +1299,7 @@ def get_docker_container_id(self) -> str:
12981299

12991300
def omc_run_data_update(self, omc_run_data: OMCSessionRunData) -> OMCSessionRunData:
13001301
"""
1301-
Update the OMCSessionRunData object based on the selected OMCProcess implementation.
1302+
Update the OMCSessionRunData object based on the selected OMCSession implementation.
13021303
"""
13031304
omc_run_data_copy = dataclasses.replace(omc_run_data)
13041305

@@ -1643,7 +1644,7 @@ def _omc_port_get(self) -> str:
16431644

16441645
def omc_run_data_update(self, omc_run_data: OMCSessionRunData) -> OMCSessionRunData:
16451646
"""
1646-
Update the OMCSessionRunData object based on the selected OMCProcess implementation.
1647+
Update the OMCSessionRunData object based on the selected OMCSession implementation.
16471648
"""
16481649
omc_run_data_copy = dataclasses.replace(omc_run_data)
16491650

0 commit comments

Comments
 (0)