Skip to content

Commit aebb9f8

Browse files
authored
(A010) Use function keyword arguments (#420)
* update docstring of __init__.py - do not promote depreciated OMCSessionZMQ * reorder imports in __init__.py * [OMCSession] use function keyword arguments if possible
1 parent 4f056f2 commit aebb9f8

2 files changed

Lines changed: 24 additions & 17 deletions

File tree

OMPython/OMCSession.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def poll(self):
5050
return None if self.process.is_running() else True
5151

5252
def kill(self):
53-
return os.kill(self.pid, signal.SIGKILL)
53+
return os.kill(pid=self.pid, signal=signal.SIGKILL)
5454

5555
def wait(self, timeout):
5656
try:
@@ -854,10 +854,12 @@ def run_model_executable(self, cmd_run_data: OMCSessionRunData) -> int:
854854
return returncode
855855

856856
def execute(self, command: str):
857-
warnings.warn(message="This function is depreciated and will be removed in future versions; "
858-
"please use sendExpression() instead",
859-
category=DeprecationWarning,
860-
stacklevel=2)
857+
warnings.warn(
858+
message="This function is depreciated and will be removed in future versions; "
859+
"please use sendExpression() instead",
860+
category=DeprecationWarning,
861+
stacklevel=2,
862+
)
861863

862864
return self.sendExpression(command, parsed=False)
863865

OMPython/__init__.py

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
# -*- coding: utf-8 -*-
22
"""
33
OMPython is a Python interface to OpenModelica.
4-
To get started, create an OMCSessionZMQ object:
5-
from OMPython import OMCSessionZMQ
6-
omc = OMCSessionZMQ()
4+
To get started on a local OMC server, create an OMCSessionLocal object:
5+
6+
```
7+
import OMPython
8+
omc = OMPython.OMCSessionLocal()
79
omc.sendExpression("command")
10+
```
11+
812
"""
913

1014
from OMPython.ModelicaSystem import (
@@ -18,19 +22,20 @@
1822
OMCPath,
1923
OMCSession,
2024
OMCSessionCmd,
21-
OMCSessionException,
22-
OMCSessionRunData,
23-
OMCSessionZMQ,
24-
OMCSessionPort,
25-
OMCSessionLocal,
2625
OMCSessionDocker,
2726
OMCSessionDockerContainer,
27+
OMCSessionException,
28+
OMCSessionLocal,
29+
OMCSessionPort,
30+
OMCSessionRunData,
2831
OMCSessionWSL,
32+
OMCSessionZMQ,
2933
)
3034

3135
# global names imported if import 'from OMPython import *' is used
3236
__all__ = [
3337
'LinearizationResult',
38+
3439
'ModelicaSystem',
3540
'ModelicaSystemCmd',
3641
'ModelicaSystemDoE',
@@ -40,12 +45,12 @@
4045

4146
'OMCSession',
4247
'OMCSessionCmd',
48+
'OMCSessionDocker',
49+
'OMCSessionDockerContainer',
4350
'OMCSessionException',
44-
'OMCSessionRunData',
45-
'OMCSessionZMQ',
4651
'OMCSessionPort',
4752
'OMCSessionLocal',
48-
'OMCSessionDocker',
49-
'OMCSessionDockerContainer',
53+
'OMCSessionRunData',
5054
'OMCSessionWSL',
55+
'OMCSessionZMQ',
5156
]

0 commit comments

Comments
 (0)