osascript2 1.0.0__tar.gz → 1.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: osascript2
3
- Version: 1.0.0
3
+ Version: 1.2.0
4
4
  Summary: A tiny python osascript wrapper
5
5
  License: GPLv3
6
6
  Project-URL: Homepage, https://github.com/zwimer/osascript2
@@ -19,6 +19,7 @@ Install via:
19
19
  pip install osascript2
20
20
  ```
21
21
 
22
+ Usage:
22
23
  ```python
23
24
  import osascript
24
25
 
@@ -6,6 +6,7 @@ Install via:
6
6
  pip install osascript2
7
7
  ```
8
8
 
9
+ Usage:
9
10
  ```python
10
11
  import osascript
11
12
 
@@ -0,0 +1,5 @@
1
+ from .osascript import run
2
+
3
+ __version__ = "1.2.0"
4
+
5
+ __all__ = ("__version__", "run", "run_bytes")
@@ -0,0 +1,36 @@
1
+ from tempfile import NamedTemporaryFile
2
+ from pathlib import Path
3
+ from typing import cast
4
+ import subprocess
5
+
6
+ __all__ = ("run", "run_bytes")
7
+
8
+
9
+ def _sub_run(path: str | Path, text: bool) -> tuple[int, str, str] | tuple[int, bytes, bytes]:
10
+ p = subprocess.run(["osascript", path], text=text, capture_output=True, check=False)
11
+ return p.returncode, p.stdout, p.stderr
12
+
13
+
14
+ def _run(cmd: str | Path, text: bool) -> tuple[int, str, str] | tuple[int, bytes, bytes]:
15
+ if isinstance(cmd, Path):
16
+ return _sub_run(cmd, text)
17
+ with NamedTemporaryFile("w", delete_on_close=False) as f:
18
+ f.write(cmd)
19
+ f.close()
20
+ return _sub_run(f.name, text)
21
+
22
+
23
+ def run(cmd: str | Path) -> tuple[int, str, str]:
24
+ """
25
+ Execute the given applescript command or file (run with subprocess' text=True)
26
+ Return the (return code, stdout, and stderr)
27
+ """
28
+ return cast(tuple[int, str, str], _run(cmd, True))
29
+
30
+
31
+ def run_bytes(cmd: str | Path) -> tuple[int, bytes, bytes]:
32
+ """
33
+ Execute the given applescript command or file (run with subprocess' text=False)
34
+ Return the (return code, stdout, and stderr)
35
+ """
36
+ return cast(tuple[int, bytes, bytes], _run(cmd, False))
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: osascript2
3
- Version: 1.0.0
3
+ Version: 1.2.0
4
4
  Summary: A tiny python osascript wrapper
5
5
  License: GPLv3
6
6
  Project-URL: Homepage, https://github.com/zwimer/osascript2
@@ -19,6 +19,7 @@ Install via:
19
19
  pip install osascript2
20
20
  ```
21
21
 
22
+ Usage:
22
23
  ```python
23
24
  import osascript
24
25
 
@@ -1,5 +0,0 @@
1
- from .osascript import run
2
-
3
- __version__ = "1.0.0"
4
-
5
- __all__ = ("__version__", "run")
@@ -1,23 +0,0 @@
1
- from tempfile import NamedTemporaryFile
2
- from pathlib import Path
3
- import subprocess
4
-
5
- __all__ = ("run",)
6
-
7
-
8
- def _run(path: str | Path) -> tuple[int, bytes, bytes]:
9
- p = subprocess.run(["osascript", path], capture_output=True, check=False)
10
- return p.returncode, p.stdout, p.stderr
11
-
12
-
13
- def run(cmd: str | Path) -> tuple[int, bytes, bytes]:
14
- """
15
- Execute the given applescript command or file
16
- Return the (return code, stdout, and stderr)
17
- """
18
- if isinstance(cmd, Path):
19
- return _run(cmd)
20
- with NamedTemporaryFile("w", delete_on_close=False) as f:
21
- f.write(cmd)
22
- f.close()
23
- return _run(f.name)
@@ -1 +0,0 @@
1
- PARTIAL
File without changes
File without changes
File without changes