valetudo-map-parser 0.1.9b22__py3-none-any.whl → 0.1.9b23__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.
@@ -16,6 +16,7 @@ from .config.types import (
16
16
  from .hypfer_handler import HypferMapImageHandler
17
17
  from .rand25_handler import ReImageHandler
18
18
 
19
+
19
20
  __all__ = [
20
21
  "HypferMapImageHandler",
21
22
  "ReImageHandler",
@@ -10,6 +10,7 @@ from numpy import rot90
10
10
 
11
11
  from .types import Color, NumpyArray, TrimCropData
12
12
 
13
+
13
14
  _LOGGER = logging.getLogger(__name__)
14
15
 
15
16
 
@@ -6,6 +6,7 @@ import logging
6
6
  from enum import StrEnum
7
7
  from typing import Dict, List, Tuple
8
8
 
9
+
9
10
  _LOGGER = logging.getLogger(__name__)
10
11
 
11
12
  Color = Tuple[int, int, int, int] # RGBA color definition
@@ -10,6 +10,7 @@ import struct
10
10
  from enum import Enum
11
11
  from typing import Any, Callable, Dict, List, Optional, TypeVar
12
12
 
13
+
13
14
  _CallableT = TypeVar("_CallableT", bound=Callable[..., Any])
14
15
 
15
16
 
@@ -6,6 +6,7 @@ Version: v2024.12.0
6
6
 
7
7
  import asyncio
8
8
  import logging
9
+ from typing import Dict, List
9
10
 
10
11
  from .types import (
11
12
  ATTR_CALIBRATION_POINTS,
@@ -36,8 +37,10 @@ from .types import (
36
37
  DEFAULT_VALUES,
37
38
  CameraModes,
38
39
  Colors,
40
+ TrimsData,
39
41
  )
40
42
 
43
+
41
44
  _LOGGER = logging.getLogger(__name__)
42
45
 
43
46
 
@@ -99,8 +102,15 @@ class CameraShared:
99
102
  self.map_pred_points = None # Predefined points data
100
103
  self.map_new_path = None # New path data
101
104
  self.map_old_path = None # Old path data
102
- self.trim_crop_data = None
103
105
  self.user_language = None # User language
106
+ self.trim_crop_data = None
107
+ self.trims: Dict[TrimsData, int] = {
108
+ TrimsData.TRIM_LEFT: 0,
109
+ TrimsData.TRIM_UP: 0,
110
+ TrimsData.TRIM_RIGHT: 0,
111
+ TrimsData.TRIM_DOWN: 0,
112
+ }
113
+ self.skip_room_ids: List[str] = []
104
114
 
105
115
  def update_user_colors(self, user_colors):
106
116
  """Update the user colors."""
@@ -7,11 +7,13 @@ import asyncio
7
7
  import json
8
8
  import logging
9
9
  from dataclasses import dataclass
10
+ from enum import Enum
10
11
  from typing import Any, Dict, Tuple, Union
11
12
 
12
13
  import numpy as np
13
14
  from PIL import Image
14
15
 
16
+
15
17
  DEFAULT_ROOMS = 1
16
18
 
17
19
  MY_LOGGER = logging.getLogger(__name__)
@@ -587,3 +589,12 @@ class CameraModes:
587
589
  CAMERA_STANDBY = "camera_standby"
588
590
  CAMERA_OFF = False
589
591
  CAMERA_ON = True
592
+
593
+
594
+ class TrimsData(Enum):
595
+ """Constants for the trims data."""
596
+
597
+ TRIM_LEFT = "trim_left"
598
+ TRIM_UP = "trim_up"
599
+ TRIM_RIGHT = "trim_right"
600
+ TRIM_DOWN = "trim_down"
@@ -4,10 +4,12 @@ import hashlib
4
4
  import json
5
5
  from dataclasses import dataclass
6
6
  from logging import getLogger
7
+ from typing import Callable, List, Optional
7
8
 
8
- from PIL import Image, ImageOps
9
+ from PIL import ImageOps
10
+
11
+ from .types import ChargerPosition, ImageSize, NumpyArray, PilPNG, RobotPosition
9
12
 
10
- from .types import ChargerPosition, ImageSize, NumpyArray, RobotPosition
11
13
 
12
14
  _LOGGER = getLogger(__name__)
13
15
 
@@ -16,13 +18,13 @@ _LOGGER = getLogger(__name__)
16
18
  class ResizeParams:
17
19
  """Resize the image to the given dimensions and aspect ratio."""
18
20
 
19
- pil_img: Image # PIL image object
21
+ pil_img: PilPNG
20
22
  width: int
21
23
  height: int
22
- aspect_ratio: str = None
23
- crop_size: list = None
24
- is_rand: bool = False
25
- offset_func: callable = None # Function reference for offset calculation
24
+ aspect_ratio: str
25
+ crop_size: List[int]
26
+ is_rand: Optional[bool] = False
27
+ offset_func: Optional[Callable] = None
26
28
 
27
29
 
28
30
  @dataclass
@@ -33,7 +35,7 @@ class OffsetParams:
33
35
  hsf: int
34
36
  width: int
35
37
  height: int
36
- rand256: bool = False
38
+ rand256: Optional[bool] = False
37
39
 
38
40
 
39
41
  class BaseHandler:
@@ -91,7 +93,7 @@ class BaseHandler:
91
93
  )
92
94
 
93
95
  def _set_image_offset_ratio_1_1(
94
- self, width: int, height: int, rand256: bool = False
96
+ self, width: int, height: int, rand256: Optional[bool] = False
95
97
  ) -> None:
96
98
  """Set the image offset ratio to 1:1."""
97
99
 
@@ -118,7 +120,7 @@ class BaseHandler:
118
120
  )
119
121
 
120
122
  def _set_image_offset_ratio_2_1(
121
- self, width: int, height: int, rand256: bool = False
123
+ self, width: int, height: int, rand256: Optional[bool] = False
122
124
  ) -> None:
123
125
  """Set the image offset ratio to 2:1."""
124
126
 
@@ -146,7 +148,7 @@ class BaseHandler:
146
148
  )
147
149
 
148
150
  def _set_image_offset_ratio_3_2(
149
- self, width: int, height: int, rand256: bool = False
151
+ self, width: int, height: int, rand256: Optional[bool] = False
150
152
  ) -> None:
151
153
  """Set the image offset ratio to 3:2."""
152
154
 
@@ -177,7 +179,7 @@ class BaseHandler:
177
179
  )
178
180
 
179
181
  def _set_image_offset_ratio_5_4(
180
- self, width: int, height: int, rand256: bool = False
182
+ self, width: int, height: int, rand256: Optional[bool] = False
181
183
  ) -> None:
182
184
  """Set the image offset ratio to 5:4."""
183
185
 
@@ -209,7 +211,7 @@ class BaseHandler:
209
211
  )
210
212
 
211
213
  def _set_image_offset_ratio_9_16(
212
- self, width: int, height: int, rand256: bool = False
214
+ self, width: int, height: int, rand256: Optional[bool] = False
213
215
  ) -> None:
214
216
  """Set the image offset ratio to 9:16."""
215
217
 
@@ -237,7 +239,7 @@ class BaseHandler:
237
239
  )
238
240
 
239
241
  def _set_image_offset_ratio_16_9(
240
- self, width: int, height: int, rand256: bool = False
242
+ self, width: int, height: int, rand256: Optional[bool] = False
241
243
  ) -> None:
242
244
  """Set the image offset ratio to 16:9."""
243
245
 
@@ -298,8 +300,8 @@ class BaseHandler:
298
300
 
299
301
  @staticmethod
300
302
  async def calculate_array_hash(
301
- layers: dict, active: list[int] = None
302
- ) -> str or None:
303
+ layers: dict, active: Optional[List[int]]
304
+ ) -> str | None:
303
305
  """Calculate the hash of the image based on layers and active zones."""
304
306
  if layers and active:
305
307
  data_to_hash = {
@@ -499,7 +501,7 @@ async def async_resize_image(params: ResizeParams):
499
501
  str(hsf),
500
502
  )
501
503
 
502
- if params.crop_size is not None:
504
+ if (params.crop_size is not None) and (params.offset_func is not None):
503
505
  offset = OffsetParams(wsf, hsf, new_width, new_height, params.is_rand)
504
506
  params.crop_size[0], params.crop_size[1] = await params.offset_func(offset)
505
507
 
@@ -507,6 +509,7 @@ async def async_resize_image(params: ResizeParams):
507
509
 
508
510
  return ImageOps.pad(params.pil_img, (params.width, params.height))
509
511
 
512
+
510
513
  def prepare_resize_params(handler, pil_img, rand):
511
514
  """Prepare resize parameters for image resizing."""
512
515
  return ResizeParams(
@@ -516,5 +519,5 @@ def prepare_resize_params(handler, pil_img, rand):
516
519
  aspect_ratio=handler.shared.image_aspect_ratio,
517
520
  crop_size=handler.crop_img_size,
518
521
  offset_func=handler.async_map_coordinates_offset,
519
- is_rand=rand
522
+ is_rand=rand,
520
523
  )
@@ -10,6 +10,7 @@ import logging
10
10
 
11
11
  from .config.types import Color, JsonType, NumpyArray, RobotPosition
12
12
 
13
+
13
14
  _LOGGER = logging.getLogger(__name__)
14
15
 
15
16
 
@@ -20,6 +20,7 @@ from .config.utils import BaseHandler, prepare_resize_params
20
20
  from .hypfer_draw import ImageDraw as ImDraw
21
21
  from .map_data import ImageData
22
22
 
23
+
23
24
  _LOGGER = logging.getLogger(__name__)
24
25
 
25
26
 
@@ -28,6 +28,7 @@ from .config.utils import BaseHandler, prepare_resize_params
28
28
  from .map_data import RandImageData
29
29
  from .reimg_draw import ImageDraw
30
30
 
31
+
31
32
  _LOGGER = logging.getLogger(__name__)
32
33
 
33
34
 
@@ -12,6 +12,7 @@ from .config.drawable import Drawable
12
12
  from .config.types import Color, JsonType, NumpyArray
13
13
  from .map_data import ImageData, RandImageData
14
14
 
15
+
15
16
  _LOGGER = logging.getLogger(__name__)
16
17
 
17
18
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: valetudo-map-parser
3
- Version: 0.1.9b22
3
+ Version: 0.1.9b23
4
4
  Summary: A Python library to parse Valetudo map data returning a PIL Image object.
5
5
  License: Apache-2.0
6
6
  Author: Sandro Cantarella
@@ -0,0 +1,20 @@
1
+ valetudo_map_parser/__init__.py,sha256=Wmd20bdI1btzMq-0x8NxGYWskTjdUmD-Fem9MTfziwU,810
2
+ valetudo_map_parser/config/__init__.py,sha256=DQ9plV3ZF_K25Dp5ZQHPDoG-40dQoJNdNi-dfNeR3Zc,48
3
+ valetudo_map_parser/config/auto_crop.py,sha256=OCEUxmqaCy4jbuIkXFuutJ2W3usarfowEJBXKak-1nw,11019
4
+ valetudo_map_parser/config/colors.py,sha256=IzTT9JvF12YGGJxaTiEJRuwUdCCsFCLzsR9seCDfYWs,6515
5
+ valetudo_map_parser/config/drawable.py,sha256=hsrEJCMVOrjs5sJfr26SeqJD0VNlYWwxcVkkHeaxx7U,20356
6
+ valetudo_map_parser/config/rand25_parser.py,sha256=kIayyqVZBfQfAMkiArzqrrj9vqZB3pkgT0Y5ufrQmGA,16448
7
+ valetudo_map_parser/config/shared.py,sha256=BPfkcsfZnWqiwCfTECyXw-8LX9NFc6SuwiYU99cbWtE,9735
8
+ valetudo_map_parser/config/types.py,sha256=VWzrR0xzlcTBdL9Eu6hJLpVjO0YusQomR1vOIj1g2a0,16306
9
+ valetudo_map_parser/config/utils.py,sha256=8TBqH5jKr7wMM5dtWqnk5pPwZa_D0ApOpmdZUaqiRl8,18679
10
+ valetudo_map_parser/hypfer_draw.py,sha256=1trtil-CQcDSiAMBWPBmuP5L9MWHGTp5OlY7MX8FgDg,14932
11
+ valetudo_map_parser/hypfer_handler.py,sha256=dW3EKF-Hc8OT74IcUXk8faPx4CvhkL3WH79tq_bLCfw,13516
12
+ valetudo_map_parser/map_data.py,sha256=6FbQfgxFB6E4kcOWokReJOVSekVaE1kStyhTQhAhiOg,19469
13
+ valetudo_map_parser/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
14
+ valetudo_map_parser/rand25_handler.py,sha256=N0i4JBnX5UY-TMpRa11oXE6DrjIU3fqSM89aaKVP0Eo,15318
15
+ valetudo_map_parser/reimg_draw.py,sha256=V0JUASavKVnEtAhv7nOV4pjsRxZrNsjIUtctbKO8wvk,12507
16
+ valetudo_map_parser-0.1.9b23.dist-info/LICENSE,sha256=Lh-qBbuRV0-jiCIBhfV7NgdwFxQFOXH3BKOzK865hRs,10480
17
+ valetudo_map_parser-0.1.9b23.dist-info/METADATA,sha256=xTp6WcfWrNFVtRMW58-WAZZqAd2_VSbH-sJfG4Rjyhc,1029
18
+ valetudo_map_parser-0.1.9b23.dist-info/NOTICE.txt,sha256=5lTOuWiU9aiEnJ2go8sc7lTJ7ntMBx0g0GFnNrswCY4,2533
19
+ valetudo_map_parser-0.1.9b23.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
20
+ valetudo_map_parser-0.1.9b23.dist-info/RECORD,,
@@ -1,20 +0,0 @@
1
- valetudo_map_parser/__init__.py,sha256=pWRSVGM2OtPKTzdpPTEgLrNYjZ9P2duwaDLI_KN-iLY,809
2
- valetudo_map_parser/config/__init__.py,sha256=DQ9plV3ZF_K25Dp5ZQHPDoG-40dQoJNdNi-dfNeR3Zc,48
3
- valetudo_map_parser/config/auto_crop.py,sha256=z97Yqoe96ZiWmgaKTFv7sODb9UD6doRduTeQXMYWXVA,11018
4
- valetudo_map_parser/config/colors.py,sha256=0sTI_x0ZMchSDPTsEivdTXDn58nEbyE4REXIp0IpWdg,6514
5
- valetudo_map_parser/config/drawable.py,sha256=hsrEJCMVOrjs5sJfr26SeqJD0VNlYWwxcVkkHeaxx7U,20356
6
- valetudo_map_parser/config/rand25_parser.py,sha256=fehyF18hRWRWbXbojocQCIaIch21Lbh1wtl2XdKRSl0,16447
7
- valetudo_map_parser/config/shared.py,sha256=LQV5K8tbVhEKUkby9ssjEmh_T4Ai-Euzsbag_HWYVRc,9448
8
- valetudo_map_parser/config/types.py,sha256=sdjqhcxpRSxNFLVHIyCg-RDL9JIjtQHoR2C2WpocWBc,16107
9
- valetudo_map_parser/config/utils.py,sha256=QHF0rx72TS0Kpt2iTqqFwr6MlV0TJXK6-_008wDg8nU,18573
10
- valetudo_map_parser/hypfer_draw.py,sha256=s58ak9IBYLjJyoddfDC99PfQ12HTjkSfJYXqCi4vZKs,14931
11
- valetudo_map_parser/hypfer_handler.py,sha256=8uAPum9JK_JDDSEoD_gLGxMRvdOg4oAABqc3PvW-GTs,13515
12
- valetudo_map_parser/map_data.py,sha256=6FbQfgxFB6E4kcOWokReJOVSekVaE1kStyhTQhAhiOg,19469
13
- valetudo_map_parser/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
14
- valetudo_map_parser/rand25_handler.py,sha256=iGWxNgLzl-4btakBGKEbLqKOp7j2gDD6bmSAp4YGjkY,15317
15
- valetudo_map_parser/reimg_draw.py,sha256=dtdbYKKxmQnbOaHBHayWEF07OdSnTKo2CPSOW0qpgH0,12506
16
- valetudo_map_parser-0.1.9b22.dist-info/LICENSE,sha256=Lh-qBbuRV0-jiCIBhfV7NgdwFxQFOXH3BKOzK865hRs,10480
17
- valetudo_map_parser-0.1.9b22.dist-info/METADATA,sha256=B6EqNlL0I8Pmt-hy_nvT8HA9EdUTOb-_-X6dDAmowpo,1029
18
- valetudo_map_parser-0.1.9b22.dist-info/NOTICE.txt,sha256=5lTOuWiU9aiEnJ2go8sc7lTJ7ntMBx0g0GFnNrswCY4,2533
19
- valetudo_map_parser-0.1.9b22.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
20
- valetudo_map_parser-0.1.9b22.dist-info/RECORD,,