monkeytoolbox 0.2.0__tar.gz → 0.4.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.
@@ -7,7 +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.2.0 - 2024-01-04]
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
16
+ ### Fixed
17
+ - The location of the `py.typed` file so that type checking is now properly
18
+ supported
19
+
20
+ ## [0.2.0] - 2024-01-04
11
21
  ### Added
12
22
  - `get_os_version()`
13
23
  - `get_hostname()`
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: monkeytoolbox
3
- Version: 0.2.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
@@ -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,8 +1,9 @@
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
- from egg_timer import EggTimer
6
+ from eggtimer import EggTimer
6
7
 
7
8
 
8
9
  def request_cache(ttl: float):
@@ -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]
File without changes
@@ -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
 
@@ -43,7 +43,7 @@ paths = ["monkeytoolbox", "vulture_allowlist.py"]
43
43
 
44
44
  [tool.poetry]
45
45
  name = "monkeytoolbox"
46
- version = "v0.2.0"
46
+ version = "v0.4.0"
47
47
  description = "Miscellaneous convenience utilities for Python programs"
48
48
  authors = [
49
49
  "Ilija Lazoroski <ilija.la@live.com>",
File without changes
File without changes