valetudo-map-parser 0.1.8__py3-none-any.whl → 0.1.9__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.
Files changed (30) hide show
  1. valetudo_map_parser/__init__.py +28 -13
  2. valetudo_map_parser/config/async_utils.py +93 -0
  3. valetudo_map_parser/config/auto_crop.py +312 -123
  4. valetudo_map_parser/config/color_utils.py +105 -0
  5. valetudo_map_parser/config/colors.py +662 -13
  6. valetudo_map_parser/config/drawable.py +613 -268
  7. valetudo_map_parser/config/drawable_elements.py +292 -0
  8. valetudo_map_parser/config/enhanced_drawable.py +324 -0
  9. valetudo_map_parser/config/optimized_element_map.py +406 -0
  10. valetudo_map_parser/config/rand256_parser.py +395 -0
  11. valetudo_map_parser/config/shared.py +94 -11
  12. valetudo_map_parser/config/types.py +105 -52
  13. valetudo_map_parser/config/utils.py +1025 -0
  14. valetudo_map_parser/hypfer_draw.py +464 -148
  15. valetudo_map_parser/hypfer_handler.py +366 -259
  16. valetudo_map_parser/hypfer_rooms_handler.py +599 -0
  17. valetudo_map_parser/map_data.py +56 -66
  18. valetudo_map_parser/rand256_handler.py +674 -0
  19. valetudo_map_parser/reimg_draw.py +68 -84
  20. valetudo_map_parser/rooms_handler.py +474 -0
  21. valetudo_map_parser-0.1.9.dist-info/METADATA +93 -0
  22. valetudo_map_parser-0.1.9.dist-info/RECORD +27 -0
  23. {valetudo_map_parser-0.1.8.dist-info → valetudo_map_parser-0.1.9.dist-info}/WHEEL +1 -1
  24. valetudo_map_parser/config/rand25_parser.py +0 -398
  25. valetudo_map_parser/images_utils.py +0 -398
  26. valetudo_map_parser/rand25_handler.py +0 -455
  27. valetudo_map_parser-0.1.8.dist-info/METADATA +0 -23
  28. valetudo_map_parser-0.1.8.dist-info/RECORD +0 -20
  29. {valetudo_map_parser-0.1.8.dist-info → valetudo_map_parser-0.1.9.dist-info}/LICENSE +0 -0
  30. {valetudo_map_parser-0.1.8.dist-info → valetudo_map_parser-0.1.9.dist-info}/NOTICE.txt +0 -0
@@ -1,35 +1,50 @@
1
1
  """Valetudo map parser.
2
- Version: 0.1.8"""
2
+ Version: 0.1.9"""
3
3
 
4
- from .hypfer_handler import HypferMapImageHandler
5
- from .rand25_handler import ReImageHandler
6
- from .config.rand25_parser import RRMapParser
7
- from .config.shared import CameraShared, CameraSharedManager
8
- from .config.colors import ColorsManagment
4
+ from .config.colors import ColorsManagement
9
5
  from .config.drawable import Drawable
6
+ from .config.drawable_elements import DrawableElement, DrawingConfig
7
+ from .config.enhanced_drawable import EnhancedDrawable
8
+ from .config.rand256_parser import RRMapParser
9
+ from .config.shared import CameraShared, CameraSharedManager
10
10
  from .config.types import (
11
- SnapshotStore,
12
- UserLanguageStore,
13
- RoomStore,
11
+ CameraModes,
14
12
  RoomsProperties,
13
+ RoomStore,
14
+ SnapshotStore,
15
15
  TrimCropData,
16
- CameraModes,
16
+ UserLanguageStore,
17
+ JsonType,
18
+ PilPNG,
19
+ NumpyArray,
20
+ ImageSize,
17
21
  )
22
+ from .hypfer_handler import HypferMapImageHandler
23
+ from .rand256_handler import ReImageHandler
24
+ from .rooms_handler import RoomsHandler, RandRoomsHandler
25
+
18
26
 
19
27
  __all__ = [
28
+ "RoomsHandler",
29
+ "RandRoomsHandler",
20
30
  "HypferMapImageHandler",
21
31
  "ReImageHandler",
22
32
  "RRMapParser",
23
33
  "CameraShared",
24
34
  "CameraSharedManager",
25
- "ColorsManagment",
35
+ "ColorsManagement",
26
36
  "Drawable",
37
+ "DrawableElement",
38
+ "DrawingConfig",
39
+ "EnhancedDrawable",
27
40
  "SnapshotStore",
28
41
  "UserLanguageStore",
29
- "UserLanguageStore",
30
- "SnapshotStore",
31
42
  "RoomStore",
32
43
  "RoomsProperties",
33
44
  "TrimCropData",
34
45
  "CameraModes",
46
+ "JsonType",
47
+ "PilPNG",
48
+ "NumpyArray",
49
+ "ImageSize",
35
50
  ]
@@ -0,0 +1,93 @@
1
+ """Async utility functions for making NumPy and PIL operations truly async."""
2
+
3
+ import asyncio
4
+ import io
5
+ from typing import Any, Callable
6
+
7
+ import numpy as np
8
+ from numpy import rot90
9
+ from PIL import Image
10
+
11
+
12
+ async def make_async(func: Callable, *args, **kwargs) -> Any:
13
+ """Convert a synchronous function to async by yielding control to the event loop."""
14
+ return await asyncio.to_thread(func, *args, **kwargs)
15
+
16
+
17
+ class AsyncNumPy:
18
+ """Async wrappers for NumPy operations that yield control to the event loop."""
19
+
20
+ @staticmethod
21
+ async def async_copy(array: np.ndarray) -> np.ndarray:
22
+ """Async array copying."""
23
+ return await make_async(np.copy, array)
24
+
25
+ @staticmethod
26
+ async def async_full(
27
+ shape: tuple, fill_value: Any, dtype: np.dtype = None
28
+ ) -> np.ndarray:
29
+ """Async array creation with fill value."""
30
+ return await make_async(np.full, shape, fill_value, dtype=dtype)
31
+
32
+ @staticmethod
33
+ async def async_rot90(array: np.ndarray, k: int = 1) -> np.ndarray:
34
+ """Async array rotation."""
35
+ return await make_async(rot90, array, k)
36
+
37
+
38
+ class AsyncPIL:
39
+ """Async wrappers for PIL operations that yield control to the event loop."""
40
+
41
+ @staticmethod
42
+ async def async_fromarray(array: np.ndarray, mode: str = "RGBA") -> Image.Image:
43
+ """Async PIL Image creation from NumPy array."""
44
+ return await make_async(Image.fromarray, array, mode)
45
+
46
+ @staticmethod
47
+ async def async_resize(
48
+ image: Image.Image, size: tuple, resample: int = None
49
+ ) -> Image.Image:
50
+ """Async image resizing."""
51
+ if resample is None:
52
+ resample = Image.LANCZOS
53
+ return await make_async(image.resize, size, resample)
54
+
55
+ @staticmethod
56
+ async def async_save_to_bytes(
57
+ image: Image.Image, format_type: str = "WEBP", **kwargs
58
+ ) -> bytes:
59
+ """Async image saving to bytes."""
60
+
61
+ def save_to_bytes():
62
+ buffer = io.BytesIO()
63
+ image.save(buffer, format=format_type, **kwargs)
64
+ return buffer.getvalue()
65
+
66
+ return await make_async(save_to_bytes)
67
+
68
+
69
+ class AsyncParallel:
70
+ """Helper functions for parallel processing with asyncio.gather()."""
71
+
72
+ @staticmethod
73
+ async def parallel_data_preparation(*tasks):
74
+ """Execute multiple data preparation tasks in parallel."""
75
+ return await asyncio.gather(*tasks, return_exceptions=True)
76
+
77
+ @staticmethod
78
+ async def parallel_array_operations(base_array: np.ndarray, operations: list):
79
+ """Execute multiple array operations in parallel on copies of the base array."""
80
+
81
+ # Create tasks for parallel execution
82
+ tasks = []
83
+ for operation_func, *args in operations:
84
+ # Each operation works on a copy of the base array
85
+ array_copy = await AsyncNumPy.async_copy(base_array)
86
+ tasks.append(operation_func(array_copy, *args))
87
+
88
+ # Execute all operations in parallel
89
+ results = await asyncio.gather(*tasks, return_exceptions=True)
90
+
91
+ # Filter out exceptions and return successful results
92
+ successful_results = [r for r in results if not isinstance(r, Exception)]
93
+ return successful_results