monkeytoolbox 0.3.0__py3-none-any.whl → 1.0.0__py3-none-any.whl
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.
- CHANGELOG.md +10 -2
- monkeytoolbox/code_utils.py +3 -2
- monkeytoolbox/decorators.py +2 -1
- monkeytoolbox/file_utils.py +2 -1
- monkeytoolbox/network_utils.py +4 -3
- monkeytoolbox/secure_directory.py +18 -6
- monkeytoolbox/secure_file.py +19 -8
- monkeytoolbox/threading.py +2 -1
- {monkeytoolbox-0.3.0.dist-info → monkeytoolbox-1.0.0.dist-info}/METADATA +2 -1
- monkeytoolbox-1.0.0.dist-info/RECORD +17 -0
- {monkeytoolbox-0.3.0.dist-info → monkeytoolbox-1.0.0.dist-info}/WHEEL +1 -1
- monkeytoolbox-0.3.0.dist-info/RECORD +0 -17
- {monkeytoolbox-0.3.0.dist-info → monkeytoolbox-1.0.0.dist-info}/LICENSE +0 -0
CHANGELOG.md
CHANGED
|
@@ -7,12 +7,20 @@ Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to
|
|
|
7
7
|
the [PEP 440 version scheme](https://peps.python.org/pep-0440/#version-scheme).
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
## [
|
|
10
|
+
## [1.0.0] - 2024-07-09
|
|
11
|
+
This release is identical to 0.4.0.
|
|
12
|
+
|
|
13
|
+
## [0.4.0] - 2024-06-25
|
|
14
|
+
### Fixed
|
|
15
|
+
- Error that prevents monkeytoolbox from being imported on Darwin. #6
|
|
16
|
+
- Import error in `open_new_securely_permissioned_file()` on Windows. #6
|
|
17
|
+
|
|
18
|
+
## [0.3.0] - 2024-01-16
|
|
11
19
|
### Fixed
|
|
12
20
|
- The location of the `py.typed` file so that type checking is now properly
|
|
13
21
|
supported
|
|
14
22
|
|
|
15
|
-
## [
|
|
23
|
+
## [0.2.0] - 2024-01-04
|
|
16
24
|
### Added
|
|
17
25
|
- `get_os_version()`
|
|
18
26
|
- `get_hostname()`
|
monkeytoolbox/code_utils.py
CHANGED
|
@@ -4,7 +4,8 @@ import random
|
|
|
4
4
|
import secrets
|
|
5
5
|
import string
|
|
6
6
|
from threading import Event, Thread
|
|
7
|
-
from typing import Any,
|
|
7
|
+
from typing import Any, MutableMapping, Optional, TypeVar
|
|
8
|
+
from collections.abc import Iterable, Callable
|
|
8
9
|
|
|
9
10
|
T = TypeVar("T")
|
|
10
11
|
|
|
@@ -26,7 +27,7 @@ def apply_filters(filters: Iterable[Callable[[T], bool]], iterable: Iterable[T])
|
|
|
26
27
|
return filtered_iterable
|
|
27
28
|
|
|
28
29
|
|
|
29
|
-
def queue_to_list(q: queue.Queue) ->
|
|
30
|
+
def queue_to_list(q: queue.Queue) -> list[Any]:
|
|
30
31
|
list_ = []
|
|
31
32
|
try:
|
|
32
33
|
while True:
|
monkeytoolbox/decorators.py
CHANGED
monkeytoolbox/file_utils.py
CHANGED
monkeytoolbox/network_utils.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import ipaddress
|
|
2
2
|
from ipaddress import IPv4Address, IPv4Interface
|
|
3
|
-
from typing import
|
|
3
|
+
from typing import Optional
|
|
4
|
+
from collections.abc import Iterable, Sequence
|
|
4
5
|
|
|
5
6
|
import ifaddr
|
|
6
7
|
import psutil
|
|
@@ -10,7 +11,7 @@ def get_my_ip_addresses() -> Sequence[IPv4Address]:
|
|
|
10
11
|
return [interface.ip for interface in get_network_interfaces()]
|
|
11
12
|
|
|
12
13
|
|
|
13
|
-
def get_network_interfaces() ->
|
|
14
|
+
def get_network_interfaces() -> list[IPv4Interface]:
|
|
14
15
|
local_interfaces = []
|
|
15
16
|
for adapter in ifaddr.get_adapters():
|
|
16
17
|
for ip in _select_ipv4_ips(adapter.ips):
|
|
@@ -41,7 +42,7 @@ def port_is_used(
|
|
|
41
42
|
def get_connections(
|
|
42
43
|
ports: Optional[Sequence[int]] = None,
|
|
43
44
|
ip_addresses: Optional[Sequence[IPv4Address]] = None,
|
|
44
|
-
) ->
|
|
45
|
+
) -> list[psutil._common.sconn]:
|
|
45
46
|
connections = psutil.net_connections()
|
|
46
47
|
if ports:
|
|
47
48
|
connections = [connection for connection in connections if connection.laddr.port in ports]
|
|
@@ -1,17 +1,29 @@
|
|
|
1
1
|
import logging
|
|
2
2
|
import stat
|
|
3
|
+
import warnings
|
|
4
|
+
from collections.abc import Callable
|
|
3
5
|
from pathlib import Path
|
|
4
|
-
from typing import Callable
|
|
5
6
|
|
|
6
7
|
from monkeytypes import OperatingSystem
|
|
7
8
|
|
|
8
9
|
from . import get_os
|
|
9
10
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
try:
|
|
12
|
+
if get_os() == OperatingSystem.WINDOWS:
|
|
13
|
+
import win32file
|
|
14
|
+
import win32security
|
|
15
|
+
|
|
16
|
+
from .windows_permissions import get_security_descriptor_for_owner_only_permissions
|
|
17
|
+
except RuntimeError:
|
|
18
|
+
# The most likely cause of this error is that this module has been imported
|
|
19
|
+
# on MacOS (Darwin). While the code in this module may or may not function
|
|
20
|
+
# properly on Darwin, there is code within this package That is platform
|
|
21
|
+
# agnostic. This error, if not caught, will prevent this entire package
|
|
22
|
+
# from being imported, which is not the desired behavior.
|
|
23
|
+
warnings.warn(
|
|
24
|
+
"OS compatibility check failed: This package may not work properly on this OS.",
|
|
25
|
+
ImportWarning,
|
|
26
|
+
)
|
|
15
27
|
|
|
16
28
|
logger = logging.getLogger(__name__)
|
|
17
29
|
|
monkeytoolbox/secure_file.py
CHANGED
|
@@ -1,20 +1,31 @@
|
|
|
1
1
|
import logging
|
|
2
2
|
import os
|
|
3
3
|
import stat
|
|
4
|
+
import warnings
|
|
5
|
+
from collections.abc import Generator
|
|
4
6
|
from contextlib import contextmanager
|
|
5
|
-
from typing import Generator
|
|
6
7
|
|
|
7
8
|
from monkeytypes import OperatingSystem
|
|
8
9
|
|
|
9
10
|
from . import get_os
|
|
10
11
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
12
|
+
try:
|
|
13
|
+
if get_os() == OperatingSystem.WINDOWS:
|
|
14
|
+
import win32file
|
|
15
|
+
import win32job
|
|
16
|
+
import win32security
|
|
17
|
+
|
|
18
|
+
from .windows_permissions import get_security_descriptor_for_owner_only_permissions
|
|
19
|
+
except RuntimeError:
|
|
20
|
+
# The most likely cause of this error is that this module has been imported
|
|
21
|
+
# on MacOS (Darwin). While the code in this module may or may not function
|
|
22
|
+
# properly on Darwin, there is code within this package That is platform
|
|
23
|
+
# agnostic. This error, if not caught, will prevent this entire package
|
|
24
|
+
# from being imported, which is not the desired behavior.
|
|
25
|
+
warnings.warn(
|
|
26
|
+
"OS compatibility check failed: This package may not work properly on this OS.",
|
|
27
|
+
ImportWarning,
|
|
28
|
+
)
|
|
18
29
|
|
|
19
30
|
logger = logging.getLogger(__name__)
|
|
20
31
|
|
monkeytoolbox/threading.py
CHANGED
|
@@ -3,7 +3,8 @@ import threading
|
|
|
3
3
|
from functools import wraps
|
|
4
4
|
from itertools import count
|
|
5
5
|
from threading import Lock, Thread
|
|
6
|
-
from typing import Any,
|
|
6
|
+
from typing import Any, Iterator, Optional, Tuple, TypeVar
|
|
7
|
+
from collections.abc import Iterable, Callable
|
|
7
8
|
|
|
8
9
|
from monkeytypes import Event
|
|
9
10
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: monkeytoolbox
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 1.0.0
|
|
4
4
|
Summary: Miscellaneous convenience utilities for Python programs
|
|
5
5
|
Home-page: https://github.com/guardicode/monkeytoolbox
|
|
6
6
|
License: GPLv3
|
|
@@ -11,6 +11,7 @@ Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
|
|
|
11
11
|
Classifier: License :: Other/Proprietary License
|
|
12
12
|
Classifier: Programming Language :: Python :: 3
|
|
13
13
|
Classifier: Programming Language :: Python :: 3.11
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
14
15
|
Requires-Dist: egg-timer
|
|
15
16
|
Requires-Dist: ifaddr
|
|
16
17
|
Requires-Dist: monkey-types
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
CHANGELOG.md,sha256=5uhOTPjcfDbzrw1VRqz6aBG7CGDmgA6Nn5jf8fVdWkQ,849
|
|
2
|
+
README.md,sha256=ZOercnjzgT1CcA3bR_6Pg-i-p-xCUYsj7ShRZi_pfg0,309
|
|
3
|
+
monkeytoolbox/__init__.py,sha256=-m9QOksTBVV53-G7_E4Ykyw0QCVwntmKHV0m62P1JqE,873
|
|
4
|
+
monkeytoolbox/code_utils.py,sha256=ckVLP3LlQKRfq1gvgQiZorcyAENg7_i6tv9eDfK-Au0,5282
|
|
5
|
+
monkeytoolbox/decorators.py,sha256=SfdYY9FTDYEUsb4clOaWzIwetljnL-imRaGTgPLVHuY,2240
|
|
6
|
+
monkeytoolbox/environment.py,sha256=PozYy9gpHKghQnSStWM0ryFtcsmf02WPXmooelYDHDQ,1550
|
|
7
|
+
monkeytoolbox/file_utils.py,sha256=k1142R9FP94Hr193qYBlRZLzJXd_wEWSOR1uJXnDpOI,1895
|
|
8
|
+
monkeytoolbox/network_utils.py,sha256=QtskItC0E-CmhCmFBDBSLsCLbXxaHP8UvczyLK2-rCY,1685
|
|
9
|
+
monkeytoolbox/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
10
|
+
monkeytoolbox/secure_directory.py,sha256=_6CQyUrPXdftt8NY-XIoN7iIoCL4oLxK_6IOR6fqZek,3257
|
|
11
|
+
monkeytoolbox/secure_file.py,sha256=u7g_MQbl9Et3ok-sfHxy07IZXMFfOPHZ7h_sBMIHEGk,3259
|
|
12
|
+
monkeytoolbox/threading.py,sha256=M8gIFZQVdHhQBqzaTCWBdDLiyvXqtJ2LXpEzOYuwjiI,4740
|
|
13
|
+
monkeytoolbox/windows_permissions.py,sha256=jym55x5-fvH2t6_BsixUIGAbkk6ovKkHsGkHkjsqWFM,1845
|
|
14
|
+
monkeytoolbox-1.0.0.dist-info/LICENSE,sha256=8vSVUSGQNLw3jNk-6LogMp9dkBcAS103yGyzS78mIjs,35255
|
|
15
|
+
monkeytoolbox-1.0.0.dist-info/METADATA,sha256=xZnF053N5moHCNVPhkF38xdWM-dGK8rZ2TLgnFVIU-s,1129
|
|
16
|
+
monkeytoolbox-1.0.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
|
17
|
+
monkeytoolbox-1.0.0.dist-info/RECORD,,
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
CHANGELOG.md,sha256=DiqJ_RNfNl6h1Aqfc-PpuYOcpfv8tzuq36eGruZC0cQ,612
|
|
2
|
-
README.md,sha256=ZOercnjzgT1CcA3bR_6Pg-i-p-xCUYsj7ShRZi_pfg0,309
|
|
3
|
-
monkeytoolbox/__init__.py,sha256=-m9QOksTBVV53-G7_E4Ykyw0QCVwntmKHV0m62P1JqE,873
|
|
4
|
-
monkeytoolbox/code_utils.py,sha256=3JefNrkhMJnxsfFBtKN9Ki9Qa-t_cXeBi7Pu-RfmfOs,5261
|
|
5
|
-
monkeytoolbox/decorators.py,sha256=baXV_UuH-a-3j3RJ3NhFLq0MoVcu6efSblBvEKSilCA,2213
|
|
6
|
-
monkeytoolbox/environment.py,sha256=PozYy9gpHKghQnSStWM0ryFtcsmf02WPXmooelYDHDQ,1550
|
|
7
|
-
monkeytoolbox/file_utils.py,sha256=6fUtFd9k0Eb-5e38fDQAPPGMHqALcpvu8vezhWvH7R0,1868
|
|
8
|
-
monkeytoolbox/network_utils.py,sha256=grdmj8l5hBmTh1Fy9UO1j2j6gIBqsN4i09Zao0785E0,1664
|
|
9
|
-
monkeytoolbox/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
10
|
-
monkeytoolbox/secure_directory.py,sha256=h0gWiho_xSuNZrUp0Bxt_8uzdWkNo3sFMiN-0TFM5o4,2679
|
|
11
|
-
monkeytoolbox/secure_file.py,sha256=b1SVsjC7H6rJNn7eUU2bgeG-5ru0duaaiM1vv7py314,2678
|
|
12
|
-
monkeytoolbox/threading.py,sha256=QYmWERGsRRrFEAcM2pdlNzw3Z-9rTnevTf6LFDOLo8U,4713
|
|
13
|
-
monkeytoolbox/windows_permissions.py,sha256=jym55x5-fvH2t6_BsixUIGAbkk6ovKkHsGkHkjsqWFM,1845
|
|
14
|
-
monkeytoolbox-0.3.0.dist-info/LICENSE,sha256=8vSVUSGQNLw3jNk-6LogMp9dkBcAS103yGyzS78mIjs,35255
|
|
15
|
-
monkeytoolbox-0.3.0.dist-info/METADATA,sha256=dbA9m_djyx3av_liwNxcShiFSqltpXSMydQpKr-YqXA,1078
|
|
16
|
-
monkeytoolbox-0.3.0.dist-info/WHEEL,sha256=Zb28QaM1gQi8f4VCBhsUklF61CTlNYfs9YAZn-TOGFk,88
|
|
17
|
-
monkeytoolbox-0.3.0.dist-info/RECORD,,
|
|
File without changes
|