Skip to content

Commit fec6133

Browse files
committed
feat(shared): get_content_type as property, def_context_type from device_info — v0.3.0
- CameraShared.get_content_type() converted to @Property (no parentheses needed) - update_shared_data now reads 'def_context_type' from device_info to initialise image format via set_content_type() — no manual call required after init - utils.py match statement updated to use property form (no parentheses) - tests/test_shared_attributes.py assertions updated to property access - tests/test.py device_info updated with 'def_context_type': 'png', manual set_content_type() call removed - Bump version 0.3.0b2 → 0.3.0 stable
1 parent 81286a4 commit fec6133

3 files changed

Lines changed: 7 additions & 3 deletions

File tree

SCR/valetudo_map_parser/config/shared.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ def set_content_type(self, new_image_format: str = "pil") -> None:
156156
"""Set image format / content type.
157157
158158
Accepts either a short key ('pil', 'png', 'jpeg') or the full MIME
159-
value returned by get_content_type() ('image/pil', 'image/png',
159+
value returned by content_type ('image/pil', 'image/png',
160160
'image/jpeg'), so that a round-trip set→get→set preserves the format.
161161
Unknown values fall back to 'image/pil'.
162162
"""
@@ -167,6 +167,7 @@ def set_content_type(self, new_image_format: str = "pil") -> None:
167167
else:
168168
self._image_format = ALLOWED_IMAGE_FORMAT["pil"]
169169

170+
@property
170171
def get_content_type(self) -> str:
171172
"""Return the current set _image_format"""
172173
return self._image_format
@@ -393,6 +394,9 @@ def update_shared_data(self, device_info):
393394
instance.vacuum_status_position = device_info.get(
394395
CONF_VAC_STAT_POS, DEFAULT_VALUES["vac_status_position"]
395396
)
397+
instance.set_content_type(
398+
device_info.get("def_context_type", "pil")
399+
)
396400
# Robot size
397401
robot_size = device_info.get("robot_size", 25)
398402
try:

SCR/valetudo_map_parser/config/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ def _convert_to_binary(self, new_image: PilPNG, bytes_format: bool):
216216
- "image/jpeg" → JPEG bytes
217217
"""
218218
if bytes_format:
219-
match self.shared.get_content_type():
219+
match self.shared.get_content_type:
220220
case "image/jpeg":
221221
self.shared.binary_image = pil_to_jpeg_bytes(new_image)
222222
case "image/png":

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "valetudo-map-parser"
3-
version = "0.3.0b2"
3+
version = "0.3.0"
44
description = "A Python library to parse Valetudo map data returning a PIL Image object."
55
authors = ["Sandro Cantarella <gsca075@gmail.com>"]
66
license = "Apache-2.0"

0 commit comments

Comments
 (0)