ramifice 0.3.19__py3-none-any.whl → 0.3.20__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.
- ramifice/decorators.py +7 -4
- ramifice/fields/file_field.py +3 -3
- ramifice/fields/image_field.py +5 -7
- ramifice/model.py +5 -0
- {ramifice-0.3.19.dist-info → ramifice-0.3.20.dist-info}/METADATA +1 -1
- {ramifice-0.3.19.dist-info → ramifice-0.3.20.dist-info}/RECORD +8 -8
- {ramifice-0.3.19.dist-info → ramifice-0.3.20.dist-info}/WHEEL +0 -0
- {ramifice-0.3.19.dist-info → ramifice-0.3.20.dist-info}/licenses/LICENSE +0 -0
ramifice/decorators.py
CHANGED
@@ -65,7 +65,10 @@ def model(
|
|
65
65
|
"is_update_doc": is_update_doc if is_migrate_model else False,
|
66
66
|
"is_delete_doc": is_delete_doc if is_migrate_model else False,
|
67
67
|
}
|
68
|
-
attrs["META"] = {
|
68
|
+
attrs["META"] = {
|
69
|
+
**metadata,
|
70
|
+
**caching(cls, service_name),
|
71
|
+
}
|
69
72
|
|
70
73
|
if is_migrate_model:
|
71
74
|
return type(
|
@@ -117,14 +120,14 @@ def caching(cls: Any, service_name: str) -> dict[str, Any]:
|
|
117
120
|
# Count fields for migrating.
|
118
121
|
count_fields_for_migrating = 0
|
119
122
|
|
120
|
-
|
121
|
-
|
123
|
+
raw_model = cls()
|
124
|
+
raw_model.fields()
|
122
125
|
default_fields: dict[str, Any] = {
|
123
126
|
"_id": IDField(),
|
124
127
|
"created_at": DateTimeField(),
|
125
128
|
"updated_at": DateTimeField(),
|
126
129
|
}
|
127
|
-
fields = {**
|
130
|
+
fields = {**raw_model.__dict__, **default_fields}
|
128
131
|
for f_name, f_type in fields.items():
|
129
132
|
if not callable(f_type):
|
130
133
|
f_type_str = f_type.__class__.__name__
|
ramifice/fields/file_field.py
CHANGED
@@ -4,7 +4,7 @@ import os
|
|
4
4
|
import shutil
|
5
5
|
import uuid
|
6
6
|
from base64 import b64decode
|
7
|
-
from datetime import
|
7
|
+
from datetime import date
|
8
8
|
from pathlib import Path
|
9
9
|
from typing import Any
|
10
10
|
|
@@ -121,7 +121,7 @@ class FileField(Field, FileGroup, JsonMixin):
|
|
121
121
|
# Create new (uuid) file name.
|
122
122
|
f_uuid_name = f"{uuid.uuid4()}{extension}"
|
123
123
|
# Create the current date for the directory name.
|
124
|
-
date_str =
|
124
|
+
date_str: str = str(date.today())
|
125
125
|
# Create path to target directory.
|
126
126
|
dir_target_path = f"{self.media_root}/{self.target_dir}/{date_str}"
|
127
127
|
# Create target directory if it does not exist.
|
@@ -166,7 +166,7 @@ class FileField(Field, FileGroup, JsonMixin):
|
|
166
166
|
# Create new (uuid) file name.
|
167
167
|
f_uuid_name = f"{uuid.uuid4()}{extension}"
|
168
168
|
# Create the current date for the directory name.
|
169
|
-
date_str =
|
169
|
+
date_str: str = str(date.today())
|
170
170
|
# Create path to target directory.
|
171
171
|
dir_target_path = f"{self.media_root}/{self.target_dir}/{date_str}"
|
172
172
|
# Create target directory if it does not exist.
|
ramifice/fields/image_field.py
CHANGED
@@ -4,7 +4,7 @@ import os
|
|
4
4
|
import shutil
|
5
5
|
import uuid
|
6
6
|
from base64 import b64decode
|
7
|
-
from datetime import
|
7
|
+
from datetime import date
|
8
8
|
from pathlib import Path
|
9
9
|
from typing import Any
|
10
10
|
|
@@ -135,7 +135,6 @@ class ImageField(Field, FileGroup, JsonMixin):
|
|
135
135
|
base64_str: str | None = None,
|
136
136
|
filename: str | None = None,
|
137
137
|
is_delete: bool = False,
|
138
|
-
add_wh: bool = False,
|
139
138
|
) -> None:
|
140
139
|
"""Convert base64 to a image,
|
141
140
|
get image information and save in the target directory.
|
@@ -159,7 +158,7 @@ class ImageField(Field, FileGroup, JsonMixin):
|
|
159
158
|
if item[0] == 40:
|
160
159
|
break
|
161
160
|
# Create the current date for the directory name.
|
162
|
-
date_str =
|
161
|
+
date_str: str = str(date.today())
|
163
162
|
# Directory name for the original image and its thumbnails.
|
164
163
|
general_dir = uuid.uuid4()
|
165
164
|
# Create path to target directory with images.
|
@@ -181,7 +180,7 @@ class ImageField(Field, FileGroup, JsonMixin):
|
|
181
180
|
img_info["path"] = main_img_path
|
182
181
|
img_info["url"] = f"{imgs_dir_url}/{new_original_name}"
|
183
182
|
# Add width and height.
|
184
|
-
if
|
183
|
+
if self.__dict__.get("add_width_height", False):
|
185
184
|
with Image.open(main_img_path) as img:
|
186
185
|
width, height = img.size
|
187
186
|
img_info["width"] = width
|
@@ -209,7 +208,6 @@ class ImageField(Field, FileGroup, JsonMixin):
|
|
209
208
|
self,
|
210
209
|
src_path: str | None = None,
|
211
210
|
is_delete: bool = False,
|
212
|
-
add_wh: bool = False,
|
213
211
|
) -> None:
|
214
212
|
"""Get image information and copy the image to the target directory."""
|
215
213
|
src_path = src_path or None
|
@@ -224,7 +222,7 @@ class ImageField(Field, FileGroup, JsonMixin):
|
|
224
222
|
msg = f"The image `{src_path}` has no extension."
|
225
223
|
raise FileHasNoExtensionError(msg)
|
226
224
|
# Create the current date for the directory name.
|
227
|
-
date_str =
|
225
|
+
date_str: str = str(date.today())
|
228
226
|
# Directory name for the original image and its thumbnails.
|
229
227
|
general_dir = uuid.uuid4()
|
230
228
|
# Create path to target directory with images.
|
@@ -244,7 +242,7 @@ class ImageField(Field, FileGroup, JsonMixin):
|
|
244
242
|
img_info["path"] = main_img_path
|
245
243
|
img_info["url"] = f"{imgs_dir_url}/{new_original_name}"
|
246
244
|
# Add width and height.
|
247
|
-
if
|
245
|
+
if self.__dict__.get("add_width_height", False):
|
248
246
|
with Image.open(main_img_path) as img:
|
249
247
|
width, height = img.size
|
250
248
|
img_info["width"] = width
|
ramifice/model.py
CHANGED
@@ -46,6 +46,11 @@ class Model(metaclass=ABCMeta):
|
|
46
46
|
)
|
47
47
|
self.fields()
|
48
48
|
self.inject()
|
49
|
+
if not self.__class__.META["is_migrate_model"]:
|
50
|
+
for _, f_type in self.__dict__.items():
|
51
|
+
if not callable(f_type):
|
52
|
+
if f_type.group == "img":
|
53
|
+
f_type.__dict__["add_width_height"] = True
|
49
54
|
|
50
55
|
def __del__(self) -> None: # noqa: D105
|
51
56
|
# If the model is not migrated,
|
@@ -1,13 +1,13 @@
|
|
1
1
|
ramifice/__init__.py,sha256=ISlaL2BprlJLE_N1fvtAqGrB3Dhniy9IZGoyWEYZhRU,678
|
2
2
|
ramifice/add_valid.py,sha256=kvpMg7snL9tor0A23XRdgwiXazRwHfb8baoJUNjM_4Y,327
|
3
|
-
ramifice/decorators.py,sha256=
|
3
|
+
ramifice/decorators.py,sha256=txbTYnKw5AtRZb7IshOzEHuoy8MAPB8wBcCTbk-6CcE,6181
|
4
4
|
ramifice/errors.py,sha256=iuhq7fzpUmsOyeXeg2fJjta8yAuqlXLKsZVMpfUhtHE,1901
|
5
5
|
ramifice/fixtures.py,sha256=NtxOnZslYJb4yvRpZbs3ckugmTwHQFS_9iCt2zddOC0,3102
|
6
6
|
ramifice/hooks.py,sha256=Ri-ISfMT-IHaLO2eAqg8CODCTs3HRTxSylqspUKnVf4,873
|
7
7
|
ramifice/indexing.py,sha256=wQpX2qei5Zc7iIq5yIV93Skp8Aa8ZD0vybnEk7cRuXs,271
|
8
8
|
ramifice/migration.py,sha256=t_Rm1OUQYrlaPQQd1uS5S7EYMvSuKUcWzi7P4JMkrOw,11114
|
9
9
|
ramifice/mixins.py,sha256=gKLmWQ-QrGO3K5_k-h1tDa08lkCql_dte2Jy05q1wsM,1125
|
10
|
-
ramifice/model.py,sha256=
|
10
|
+
ramifice/model.py,sha256=hKA_BrGBWcn-mYB9dHIJoSJYEteO6SdJdgwgjdaV7mc,7632
|
11
11
|
ramifice/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
12
12
|
ramifice/store.py,sha256=MpDEPvUvbs11FXjakNtHPm9MekIv5p1U3as2Y80lTyc,1860
|
13
13
|
ramifice/translations.py,sha256=GNGE0ULAA0aOY5pTxUd3MQW-nVaKvp6BeXWEcsR0s0o,4048
|
@@ -38,10 +38,10 @@ ramifice/fields/color_field.py,sha256=sjVSoJU6TIZ66wzPx0WRl5zQsx-kINMMuxa_pSUpW6
|
|
38
38
|
ramifice/fields/date_field.py,sha256=Vlaxgp3WeDNMwbnQcTGu8kyQ7gc7M-7sFBPfzu-4MVw,5205
|
39
39
|
ramifice/fields/date_time_field.py,sha256=VpLeYJHs0df45fz4gnprtn7aipVFKGY4n02eRep7in0,5240
|
40
40
|
ramifice/fields/email_field.py,sha256=wOM07nQ5fOSOTydQhg3b4dV_95F1bd97peQ_XAnV0MY,3720
|
41
|
-
ramifice/fields/file_field.py,sha256=
|
41
|
+
ramifice/fields/file_field.py,sha256=NMM9k-kVes7VarxvTQmsl2f2nvRKp-upjPHMDjNIrwY,7892
|
42
42
|
ramifice/fields/float_field.py,sha256=4l7gzg46qQ7ZbXS6Z8GUhiUBR26rXChvO_uFx-lbUds,4555
|
43
43
|
ramifice/fields/id_field.py,sha256=5wlY2j051TB2GPsw0iQkFiQBV_Y_o1W_QnCtBlaDuYQ,4126
|
44
|
-
ramifice/fields/image_field.py,sha256=
|
44
|
+
ramifice/fields/image_field.py,sha256=u4YJ3vFtGj5uhVLjgrvV9gNLwLXT4jfVPUN2mlPKHfg,12269
|
45
45
|
ramifice/fields/integer_field.py,sha256=Gnm5IBSvWtCLGbg5pOSAdKa5xLzqXgiigVbzw8zcjas,4531
|
46
46
|
ramifice/fields/ip_field.py,sha256=D7xR3A-O049TQ_pEEKVTLsKF5cdr5O7ULyz4Pj3-cwQ,3601
|
47
47
|
ramifice/fields/password_field.py,sha256=5BlZZ4mXM0CAYDHguwsK8KFnvkOOmr8R0yowHByNVD4,3451
|
@@ -75,7 +75,7 @@ ramifice/paladins/groups/num_group.py,sha256=Jvb-lwHxapQybbLerC4t-_yO8N7Coo1fIlZ
|
|
75
75
|
ramifice/paladins/groups/pass_group.py,sha256=SEKpR2voNQtmywugDXJKY4XqPTL91CrJ87h0QNMqQqs,1952
|
76
76
|
ramifice/paladins/groups/slug_group.py,sha256=_IRil2PwpY7cH7WaExNksKz61kQjvc27blrEufgUB30,2323
|
77
77
|
ramifice/paladins/groups/text_group.py,sha256=nYZGwAIsJD-tX8RBtFlWvngO9RU4V0CnREUhxvV2UDo,3493
|
78
|
-
ramifice-0.3.
|
79
|
-
ramifice-0.3.
|
80
|
-
ramifice-0.3.
|
81
|
-
ramifice-0.3.
|
78
|
+
ramifice-0.3.20.dist-info/METADATA,sha256=ZpWGFOazkmaGbW9rMKja65dApz_DHCrA2_PBCynIqzw,18904
|
79
|
+
ramifice-0.3.20.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
80
|
+
ramifice-0.3.20.dist-info/licenses/LICENSE,sha256=LrEL0aTZx90HDwFUQCJutORiDjJL9AnuVvCtspXIqt4,1095
|
81
|
+
ramifice-0.3.20.dist-info/RECORD,,
|
File without changes
|
File without changes
|