chronulus-core 0.0.4__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.
File without changes
File without changes
@@ -0,0 +1,45 @@
1
+ from typing import Any
2
+
3
+ from pydantic import BaseModel, Field
4
+ from PIL import Image
5
+
6
+
7
+ def get_pillow_image_type(ext: str):
8
+ ext = "." + ext.lower().replace('.','')
9
+ if ext in Image.registered_extensions():
10
+ return Image.registered_extensions()[ext]
11
+ else:
12
+ return None
13
+
14
+
15
+ class ImageFromUrl(BaseModel):
16
+ url: str
17
+ type: str | None = Field(default=None)
18
+
19
+ def model_post_init(self, __context: Any) -> None:
20
+ if self.type is None:
21
+ parts = self.url.split(".")
22
+ if len(parts) == 1:
23
+ raise ValueError(f"""Image type could not be determined for {self.url}.
24
+ Please add it in the `type` argument.""")
25
+ else:
26
+ ext = parts[-1]
27
+ pillow_format = get_pillow_image_type(ext)
28
+ if pillow_format is None:
29
+ raise ValueError(
30
+ f"""Image type was detected as '.{ext}' but this type is not supported.
31
+ If this is incorrect, please provide the correct type in the `type` argument.
32
+ """)
33
+ else:
34
+ self.type = pillow_format
35
+
36
+ else:
37
+ pillow_format = get_pillow_image_type(self.type)
38
+ if pillow_format is None:
39
+ raise ValueError(
40
+ f"""Image type '{self.type}' was specified but this type is not supported.
41
+ If this is incorrect, please provide the correct type in the `type` argument.
42
+ """)
43
+ else:
44
+ self.type = pillow_format
45
+
@@ -0,0 +1,16 @@
1
+ Metadata-Version: 2.1
2
+ Name: chronulus-core
3
+ Version: 0.0.4
4
+ Summary: Core components for Chronulus
5
+ Author: Chronulus AI
6
+ Author-email: jeremy@chronulus.com
7
+ License: Apache
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: Programming Language :: Python :: 3.10
10
+ Classifier: Programming Language :: Python :: 3.11
11
+ Classifier: Programming Language :: Python :: 3.12
12
+ Description-Content-Type: text/markdown
13
+ Requires-Dist: pydantic==2.9.2
14
+ Requires-Dist: pillow==11.0.0
15
+
16
+ # Chronulus Core
@@ -0,0 +1,7 @@
1
+ chronulus_core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ chronulus_core/types/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
+ chronulus_core/types/attributes.py,sha256=v0i33emX5lj-9itagF_hLu2wmKVBniriCcLzXanzWCg,1605
4
+ chronulus_core-0.0.4.dist-info/METADATA,sha256=0ZNH4_xywFiGmjVOC3ULg3f0kLJDmW0FUKyfGlUaSqY,489
5
+ chronulus_core-0.0.4.dist-info/WHEEL,sha256=OVMc5UfuAQiSplgO0_WdW7vXVGAt9Hdd6qtN4HotdyA,91
6
+ chronulus_core-0.0.4.dist-info/top_level.txt,sha256=yf0QeYAMDvm6uz-kibrE2gXnYgUKHFITnQzpaEAn0Cs,15
7
+ chronulus_core-0.0.4.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (75.2.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1 @@
1
+ chronulus_core