Skip to content

Commit 5c90309

Browse files
committed
documentation, +changes with docs, licence
1 parent c9815f7 commit 5c90309

16 files changed

+5621
-64
lines changed

docs/index.html

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<!doctype html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<meta http-equiv="refresh" content="0; url=./pysapscript.html"/>
6+
</head>
7+
</html>

docs/pysapscript.html

+338
Large diffs are not rendered by default.

docs/pysapscript/pysapscript.html

+929
Large diffs are not rendered by default.

docs/pysapscript/types_.html

+238
Large diffs are not rendered by default.

docs/pysapscript/types_/exceptions.html

+382
Large diffs are not rendered by default.

docs/pysapscript/types_/types.html

+374
Large diffs are not rendered by default.

docs/pysapscript/utils.html

+237
Large diffs are not rendered by default.

docs/pysapscript/utils/utils.html

+374
Large diffs are not rendered by default.

docs/pysapscript/window.html

+1,693
Large diffs are not rendered by default.

docs/search.js

+46
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

licence.txt

+674
Large diffs are not rendered by default.

poetry.lock

+237-50
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

+18-5
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,28 @@
1+
[build-system]
2+
requires = ["wheel"]
3+
4+
[project]
5+
authors = [
6+
{name = "Kamil Democko", email = "[email protected]"}
7+
]
8+
description = "Automate SAP with python!"
9+
readme = {file = "README.md", content-type = "text/markdown"}
10+
licence = {file = "licence.txt", content-type = "text"}
11+
keywords = ["sap", "sap script", "sapscript", "automation", "robot"]
12+
13+
[project.urls]
14+
Repository = "https://github.com/kamildemocko/pysapscript"
15+
116
[tool.poetry]
217
name = "pysapscript"
3-
version = "2.1.2"
4-
description = ""
18+
version = "2.1.3"
19+
description = "Automate SAP with python!"
520
authors = ["Kamil Democko <[email protected]>"]
621
readme = "README.md"
722

823
[tool.poetry.dependencies]
924
python = "^3.8"
1025
pandas = "^2.0.0"
1126
pywin32 = "^306"
12-
13-
[tool.poetry.group.dev.dependencies]
14-
sphinx = "^7.2.6"
27+
pdoc = "^14.3.0"
1528

pysapscript/__init__.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
"""
2+
.. include:: ../README.md
3+
"""
4+
15
from .pysapscript import Sapscript
26
from .window import Window
3-
from .window import NavigateAction
7+
from .window import NavigateAction

pysapscript/pysapscript.py

+28-7
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212

1313
class Sapscript:
1414
def __init__(self, default_window_title: str = "SAP Easy Access"):
15-
self.sap_gui_auto = None
16-
self.application = None
15+
self._sap_gui_auto = None
16+
self._application = None
1717
self.default_window_title = default_window_title
1818

1919
def launch_sap(self, *, root_sap_dir: Path = Path(r"C:\Program Files (x86)\SAP\FrontEnd\SAPgui"),
@@ -34,6 +34,16 @@ def launch_sap(self, *, root_sap_dir: Path = Path(r"C:\Program Files (x86)\SAP\F
3434
3535
Raises:
3636
WindowDidNotAppearException: No SAP window appeared
37+
38+
Example:
39+
```
40+
pss.launch_sap(
41+
sid="SQ4",
42+
client="012",
43+
user="robot_t",
44+
password=os.getenv("secret")
45+
)
46+
```
3747
"""
3848

3949
self._launch(
@@ -79,6 +89,11 @@ def attach_window(self, connection: int, session: int) -> window.Window:
7989
Raises:
8090
AttributeError: srong connection or session
8191
AttachException: could not attach to SAP window
92+
93+
Example:
94+
```
95+
main_window = pss.attach_window(0, 0)
96+
```
8297
"""
8398

8499
if not isinstance(connection, int):
@@ -87,14 +102,14 @@ def attach_window(self, connection: int, session: int) -> window.Window:
87102
if not isinstance(session, int):
88103
raise AttributeError("Wrong session argument!")
89104

90-
if not isinstance(self.sap_gui_auto, win32com.client.CDispatch):
91-
self.sap_gui_auto = win32com.client.GetObject("SAPGUI")
105+
if not isinstance(self._sap_gui_auto, win32com.client.CDispatch):
106+
self._sap_gui_auto = win32com.client.GetObject("SAPGUI")
92107

93-
if not isinstance(self.application, win32com.client.CDispatch):
94-
self.application = self.sap_gui_auto.GetScriptingEngine
108+
if not isinstance(self._application, win32com.client.CDispatch):
109+
self._application = self._sap_gui_auto.GetScriptingEngine
95110

96111
try:
97-
connection_handle = self.application.Children(connection)
112+
connection_handle = self._application.Children(connection)
98113

99114
except Exception:
100115
raise exceptions.AttachException("Could not attach connection %s!" % connection)
@@ -125,6 +140,12 @@ def open_new_window(self, window_to_handle_opening: window.Window):
125140
126141
Raises:
127142
WindowDidNotAppearException: no SAP window appeared
143+
144+
Example:
145+
```
146+
main_window = pss.attach_window(0, 0)
147+
pss.open_new_window(main_window)
148+
```
128149
"""
129150

130151
window_to_handle_opening.session_handle.createSession()

pysapscript/window.py

+41-1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ def navigate(self, action: NavigateAction):
4747
4848
Raises:
4949
ActionException: wrong navigation action
50+
51+
Example:
52+
```
53+
main_window.navigate(NavigateAction.enter)
54+
```
5055
"""
5156

5257
if action == NavigateAction.enter:
@@ -84,6 +89,11 @@ def press(self, element: str):
8489
8590
Raises:
8691
ActionException: error clicking element
92+
93+
Example:
94+
```
95+
main_window.press("wnd[0]/usr/tabsTABTC/tabxTAB03/subIncl/SAPML03")
96+
```
8797
"""
8898

8999
try:
@@ -96,13 +106,18 @@ def press(self, element: str):
96106

97107
def select(self, element: str):
98108
"""
99-
Presses element
109+
Selects element or menu item
100110
101111
Args:
102112
element (str): element to select - tabs, menu items
103113
104114
Raises:
105115
ActionException: error selecting element
116+
117+
Example:
118+
```
119+
main_window.select("wnd[2]/tbar[0]/btn[1]")
120+
```
106121
"""
107122

108123
try:
@@ -121,6 +136,11 @@ def write(self, element: str, text: str):
121136
122137
Raises:
123138
ActionException: Error writing to element
139+
140+
Example:
141+
```
142+
main_window.write("wnd[0]/usr/tabsTABTC/tabxTAB03/subIncl/SAPML03", "VALUE")
143+
```
124144
"""
125145

126146
try:
@@ -138,6 +158,11 @@ def read(self, element: str) -> str:
138158
139159
Raises:
140160
ActionException: Error reading element
161+
162+
Example:
163+
```
164+
value = main_window.read("wnd[0]/usr/tabsTABTC/tabxTAB03/subIncl/SAPML03")
165+
```
141166
"""
142167

143168
try:
@@ -181,6 +206,11 @@ def read_shell_table(self, element: str, load_table: bool = True) -> pandas.Data
181206
182207
Raises:
183208
ActionException: Error reading table
209+
210+
Example:
211+
```
212+
table = main_window.read_shell_table("wnd[0]/usr/shellContent/shell")
213+
```
184214
"""
185215

186216
try:
@@ -256,6 +286,11 @@ def press_shell_button(self, element: str, button: str):
256286
257287
Raises:
258288
ActionException: error pressing shell button
289+
290+
Example:
291+
```
292+
main_window.press_shell_button("wnd[0]/usr/shellContent/shell", "%OPENDWN")
293+
```
259294
"""
260295

261296
try:
@@ -275,6 +310,11 @@ def change_shell_checkbox(self, element: str, checkbox: str, flag: bool):
275310
276311
Raises:
277312
ActionException: error setting shell checkbox
313+
314+
Example:
315+
```
316+
main_window.change_shell_checkbox("wnd[0]/usr/cntlALV_CONT/shellcont/shell/rows[1]", "%CHBX", True)
317+
```
278318
"""
279319

280320
try:

0 commit comments

Comments
 (0)