monkeytoolbox 0.3.0__py3-none-any.whl → 0.4.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 CHANGED
@@ -7,12 +7,17 @@ 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
- ## [v0.3.0 - 2024-01-16]
10
+ ## [0.4.0]
11
+ ### Fixed
12
+ - Error that prevents monkeytoolbox from being imported on Darwin. #6
13
+ - Import error in `open_new_securely_permissioned_file()` on Windows. #6
14
+
15
+ ## [0.3.0] - 2024-01-16
11
16
  ### Fixed
12
17
  - The location of the `py.typed` file so that type checking is now properly
13
18
  supported
14
19
 
15
- ## [v0.2.0 - 2024-01-04]
20
+ ## [0.2.0] - 2024-01-04
16
21
  ### Added
17
22
  - `get_os_version()`
18
23
  - `get_hostname()`
@@ -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, Callable, Iterable, List, MutableMapping, Optional, TypeVar
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) -> List[Any]:
30
+ def queue_to_list(q: queue.Queue) -> list[Any]:
30
31
  list_ = []
31
32
  try:
32
33
  while True:
@@ -1,6 +1,7 @@
1
1
  import threading
2
2
  from functools import wraps
3
- from typing import Any, Callable
3
+ from typing import Any
4
+ from collections.abc import Callable
4
5
 
5
6
  from eggtimer import EggTimer
6
7
 
@@ -4,7 +4,8 @@ import logging
4
4
  import os
5
5
  import shutil
6
6
  from pathlib import Path
7
- from typing import BinaryIO, Iterable
7
+ from typing import BinaryIO
8
+ from collections.abc import Iterable
8
9
 
9
10
  logger = logging.getLogger(__name__)
10
11
 
@@ -1,6 +1,7 @@
1
1
  import ipaddress
2
2
  from ipaddress import IPv4Address, IPv4Interface
3
- from typing import Iterable, List, Optional, Sequence
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() -> List[IPv4Interface]:
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
- ) -> List[psutil._common.sconn]:
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
- if get_os() == OperatingSystem.WINDOWS:
11
- import win32file
12
- import win32security
13
-
14
- from .windows_permissions import get_security_descriptor_for_owner_only_permissions
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
 
@@ -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
- if get_os() == OperatingSystem.WINDOWS:
12
- import win32file
13
- import win32job
14
- import win32security
15
-
16
- from .windows_permissions import get_security_descriptor_for_owner_only_permissions
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
 
@@ -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, Callable, Iterable, Iterator, Optional, Tuple, TypeVar
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.0
3
+ Version: 0.4.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=Tqt2Ef7bml5W7K8oJUMpX1IRmFUWVWEwpUNgzpjxsTk,775
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-0.4.0.dist-info/LICENSE,sha256=8vSVUSGQNLw3jNk-6LogMp9dkBcAS103yGyzS78mIjs,35255
15
+ monkeytoolbox-0.4.0.dist-info/METADATA,sha256=9ZOnsdywR8FFidVAc1kcsvceeuNZd6v_VrtPCyFCUK4,1129
16
+ monkeytoolbox-0.4.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
17
+ monkeytoolbox-0.4.0.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: poetry-core 1.6.1
2
+ Generator: poetry-core 1.9.0
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
@@ -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,,