ramifice 0.8.1__py3-none-any.whl → 0.8.3__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.
@@ -12,6 +12,7 @@ from aioshutil import copyfile
12
12
  from ramifice.fields.general.field import Field
13
13
  from ramifice.fields.general.file_group import FileGroup
14
14
  from ramifice.utils import constants
15
+ from ramifice.utils.constants import MEDIA_ROOT, MEDIA_URL
15
16
  from ramifice.utils.errors import FileHasNoExtensionError
16
17
  from ramifice.utils.mixins.json_converter import JsonMixin
17
18
 
@@ -124,7 +125,7 @@ class FileField(Field, FileGroup, JsonMixin):
124
125
  # Create the current date for the directory name.
125
126
  date_str: str = str(date.today())
126
127
  # Create path to target directory.
127
- dir_target_path = f"{self.media_root}/{self.target_dir}/{date_str}"
128
+ dir_target_path = f"{MEDIA_ROOT}/uploads/{self.target_dir}/{date_str}"
128
129
  # Create target directory if it does not exist.
129
130
  if not await aiofiles.os.path.exists(dir_target_path):
130
131
  await aiofiles.os.makedirs(dir_target_path)
@@ -136,7 +137,7 @@ class FileField(Field, FileGroup, JsonMixin):
136
137
  await open_f.write(f_content)
137
138
  # Add paths to target file.
138
139
  file_info["path"] = f_target_path
139
- file_info["url"] = f"{self.media_url}/{self.target_dir}/{date_str}/{f_uuid_name}"
140
+ file_info["url"] = f"{MEDIA_URL}/uploads/{self.target_dir}/{date_str}/{f_uuid_name}"
140
141
  # Add original file name.
141
142
  file_info["name"] = filename
142
143
  # Add file extension.
@@ -169,7 +170,7 @@ class FileField(Field, FileGroup, JsonMixin):
169
170
  # Create the current date for the directory name.
170
171
  date_str: str = str(date.today())
171
172
  # Create path to target directory.
172
- dir_target_path = f"{self.media_root}/{self.target_dir}/{date_str}"
173
+ dir_target_path = f"{MEDIA_ROOT}/uploads/{self.target_dir}/{date_str}"
173
174
  # Create target directory if it does not exist.
174
175
  if not await aiofiles.os.path.exists(dir_target_path):
175
176
  await aiofiles.os.makedirs(dir_target_path)
@@ -179,7 +180,7 @@ class FileField(Field, FileGroup, JsonMixin):
179
180
  await copyfile(src_path, f_target_path)
180
181
  # Add paths to target file.
181
182
  file_info["path"] = f_target_path
182
- file_info["url"] = f"{self.media_url}/{self.target_dir}/{date_str}/{f_uuid_name}"
183
+ file_info["url"] = f"{MEDIA_URL}/uploads/{self.target_dir}/{date_str}/{f_uuid_name}"
183
184
  # Add original file name.
184
185
  file_info["name"] = os.path.basename(src_path)
185
186
  # Add file extension.
@@ -31,5 +31,3 @@ class FileGroup(metaclass=ABCMeta):
31
31
  self.default = default
32
32
  self.target_dir = target_dir
33
33
  self.accept = accept
34
- self.media_root: str = "public/media/uploads"
35
- self.media_url: str = "/media/uploads"
@@ -12,6 +12,7 @@ from aioshutil import copyfile
12
12
  from ramifice.fields.general.field import Field
13
13
  from ramifice.fields.general.file_group import FileGroup
14
14
  from ramifice.utils import constants
15
+ from ramifice.utils.constants import MEDIA_ROOT, MEDIA_URL
15
16
  from ramifice.utils.errors import FileHasNoExtensionError
16
17
  from ramifice.utils.mixins.json_converter import JsonMixin
17
18
 
@@ -155,9 +156,9 @@ class ImageField(Field, FileGroup, JsonMixin):
155
156
  # Directory name for the original image and its thumbnails.
156
157
  general_dir = uuid.uuid4()
157
158
  # Create path to target directory with images.
158
- imgs_dir_path = f"{self.media_root}/{self.target_dir}/{date_str}/{general_dir}"
159
+ imgs_dir_path = f"{MEDIA_ROOT}/uploads/{self.target_dir}/{date_str}/{general_dir}"
159
160
  # Create url path to target directory with images.
160
- imgs_dir_url = f"{self.media_url}/{self.target_dir}/{date_str}/{general_dir}"
161
+ imgs_dir_url = f"{MEDIA_URL}/uploads/{self.target_dir}/{date_str}/{general_dir}"
161
162
  # Create a new name for the original image.
162
163
  new_original_name = f"original{extension}"
163
164
  # Create path to main image.
@@ -213,9 +214,9 @@ class ImageField(Field, FileGroup, JsonMixin):
213
214
  # Directory name for the original image and its thumbnails.
214
215
  general_dir = uuid.uuid4()
215
216
  # Create path to target directory with images.
216
- imgs_dir_path = f"{self.media_root}/{self.target_dir}/{date_str}/{general_dir}"
217
+ imgs_dir_path = f"{MEDIA_ROOT}/uploads/{self.target_dir}/{date_str}/{general_dir}"
217
218
  # Create url path to target directory with images.
218
- imgs_dir_url = f"{self.media_url}/{self.target_dir}/{date_str}/{general_dir}"
219
+ imgs_dir_url = f"{MEDIA_URL}/uploads/{self.target_dir}/{date_str}/{general_dir}"
219
220
  # Create a new name for the original image.
220
221
  new_original_name = f"original{extension}"
221
222
  # Create path to main image.
@@ -7,9 +7,11 @@ List of variables:
7
7
  - `MONGO_DATABASE` - Caching a Mongo database.
8
8
  - `DATABASE_NAME` - Caching a database name.
9
9
  - `SUPER_COLLECTION_NAME` - Caching a super collection name.
10
+ - `MEDIA_ROOT` - Absolute filesystem path to the directory that will hold user-uploaded files.
11
+ - `MEDIA_URL` - URL that handles the media served from MEDIA_ROOT, used for managing stored files.
12
+ - `STATIC_ROOT` - The absolute path to the directory where static files are located.
13
+ - `STATIC_URL` - URL to use when referring to static files located in STATIC_ROOT.
10
14
  - `REGEX` - Caching a patterns of regular expression.
11
- - `FILE_INFO_DICT` - Caching a dictionary to transmit information about the file.
12
- - `IMG_INFO_DICT` - Caching a dictionary to transmit information about the image.
13
15
  """
14
16
 
15
17
  import re
@@ -30,6 +32,18 @@ DATABASE_NAME: str | None = None
30
32
  # Store technical data for Models migration into a database.
31
33
  # Store dynamic field data for simulate relationship Many-to-One and Many-to-Manyю.
32
34
  SUPER_COLLECTION_NAME: str = "SUPER_COLLECTION"
35
+ # Absolute filesystem path to the
36
+ # directory that will hold user-uploaded files.
37
+ MEDIA_ROOT: str = "public/media"
38
+ # URL that handles the media served from MEDIA_ROOT,
39
+ # used for managing stored files.
40
+ MEDIA_URL: str = "/media"
41
+ # The absolute path to the
42
+ # directory where static files are located.
43
+ STATIC_ROOT: str = "public/static"
44
+ # URL to use when referring to
45
+ # static files located in STATIC_ROOT.
46
+ STATIC_URL: str = "/static"
33
47
  # Caching a patterns of regular expression.
34
48
  REGEX: dict[str, re.Pattern] = {
35
49
  "database_name": re.compile(r"^[a-zA-Z][-_a-zA-Z0-9]{0,59}$"),
@@ -52,7 +52,7 @@ async def apply_fixture(
52
52
  value = None
53
53
  if value is not None:
54
54
  if group == "file" or group == "img":
55
- field_data.from_path(value)
55
+ await field_data.from_path(value)
56
56
  elif group == "date":
57
57
  field_data.value = parse(value)
58
58
  else:
@@ -30,11 +30,11 @@ from typing import Any
30
30
 
31
31
  from ramifice.utils.errors import PanicError
32
32
 
33
- # Language code by default.
33
+ # Language by default.
34
34
  DEFAULT_LOCALE: str = "en"
35
35
  # Code of current language.
36
36
  CURRENT_LOCALE: str = copy.deepcopy(DEFAULT_LOCALE)
37
- # List of codes supported by languages.
37
+ # List of supported languages.
38
38
  LANGUAGES: frozenset[str] = frozenset(("en", "ru"))
39
39
 
40
40
  if not DEFAULT_LOCALE in LANGUAGES:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ramifice
3
- Version: 0.8.1
3
+ Version: 0.8.3
4
4
  Summary: ORM-like API MongoDB for Python language.
5
5
  Project-URL: Homepage, https://github.com/kebasyaty/ramifice
6
6
  Project-URL: Documentation, https://kebasyaty.github.io/ramifice/
@@ -25,10 +25,10 @@ ramifice/fields/color_field.py,sha256=K-lYp8f08HTZt6WU0kY3CQWaAmx6I3-uyKHBq7xAeS
25
25
  ramifice/fields/date_field.py,sha256=-M_dD8tVUXcDCQD5Hy5Ns9Z2QGlRya0qbvoWgA4qpmg,5277
26
26
  ramifice/fields/date_time_field.py,sha256=ahjX-cD5Qj-V7JUi5QAZ8qgv9UePhYYYzJghiasKdqE,5312
27
27
  ramifice/fields/email_field.py,sha256=4Kxy1K6CXJUJ8Db0CQuopjodiY4ybe7V0GT756t7Nks,3481
28
- ramifice/fields/file_field.py,sha256=icckL_LGfPlotHO7j32lMre9J0O0k-WVjMQg5QdQav4,8130
28
+ ramifice/fields/file_field.py,sha256=jYAiP0KmhsrjJwVgEHUCA0zqJzKZmjFw9OeXv583ln0,8202
29
29
  ramifice/fields/float_field.py,sha256=JeVwoIi6j-dovXarZ3NgmSQI7f3qZzydlRs_yqp3Faw,4637
30
30
  ramifice/fields/id_field.py,sha256=YO5oIwXtqgURjjd2oYe2ouXxdpaiJp5ZhUgUA2pkNeo,4183
31
- ramifice/fields/image_field.py,sha256=qoUAkZW2b-EkU5IDvlbxEOFwWpLYFXs9ZFnxL55an6M,11549
31
+ ramifice/fields/image_field.py,sha256=g3z_Ug5Ob514OZdacm6qpHTRpPBauuL3WqBTfQgEO1I,11621
32
32
  ramifice/fields/integer_field.py,sha256=xPwpdhYNz4MyHgOypqa29oGNdKZic05yyUYHg5CDD3E,4609
33
33
  ramifice/fields/ip_field.py,sha256=tBFGFMC_zwAyLGtVRNNfiu4vQoxXPcgVHhX_aoHrvns,3390
34
34
  ramifice/fields/password_field.py,sha256=USD4Y8MTI89QZVT6zqLGBmb5kqOKrXqh73-z99cOvtk,3266
@@ -40,7 +40,7 @@ ramifice/fields/general/__init__.py,sha256=JzgIDseNQLB_IDwY9-JSiT_bONxvhJmbKl5Ph
40
40
  ramifice/fields/general/choice_group.py,sha256=aNO8LnsafGOOQ7d2lAppI9YtzVHbWUZ6t1znEEIbAv8,962
41
41
  ramifice/fields/general/date_group.py,sha256=C5VgR0CBEGgG7nIYEeI82hVXttngSJAGFvEdXC_OpGY,1213
42
42
  ramifice/fields/general/field.py,sha256=qm7N-U5H1V6BK_6quJeGGpTmb9IqA-vxZlNHwoABye0,1384
43
- ramifice/fields/general/file_group.py,sha256=T-IwFnlJAWaRcQKVn09IJCdFNGgnUfMkjLzWFFqn7gY,1117
43
+ ramifice/fields/general/file_group.py,sha256=pC9bGUpDeu7FLJVD6NMCzq18aPETotipknSly2GH7Q0,1014
44
44
  ramifice/fields/general/number_group.py,sha256=LOPHbKAnIuqW4DEh2fH78w6qOQjp0OhkuP7MoikhlkA,761
45
45
  ramifice/fields/general/text_group.py,sha256=m9EnlYGwqlck-JIYOCUd0hUYAVr8jH4YCnTmm9QlCkQ,1103
46
46
  ramifice/models/__init__.py,sha256=h_QQ5rSJNZ-7kmx7wIFd8E8RmUS94b_x4jdwMbq8zm4,15
@@ -66,19 +66,19 @@ ramifice/paladins/groups/pass_group.py,sha256=uuIIqMBXsYG7vTHc_AhdgWuNCivxTgQMjk
66
66
  ramifice/paladins/groups/slug_group.py,sha256=ztiA2v7e5lQYRZtlLw8WGOhSWaYQfOdZ6wkKbx3ZbTM,2329
67
67
  ramifice/paladins/groups/text_group.py,sha256=cdwUZoomw61A7CmDIbds_oOaia2tD-J5LLuj5b8E8O4,4472
68
68
  ramifice/utils/__init__.py,sha256=xixHoOX4ja5jIUZemem1qn4k4aonv3G3Q76azQK_pkU,43
69
- ramifice/utils/constants.py,sha256=uR20um3Qg_1SG1t7WyWbpq8kQD-9Mslyr_c1yh5Hw9w,1751
69
+ ramifice/utils/constants.py,sha256=dTSk07FVc6hgXwG1IF0_klPnbfxlFHiaRmym5zWgzIM,2395
70
70
  ramifice/utils/errors.py,sha256=iuhq7fzpUmsOyeXeg2fJjta8yAuqlXLKsZVMpfUhtHE,1901
71
- ramifice/utils/fixtures.py,sha256=IG55gdFUbrWRQ2cL3Df9mYBgjVlFrlRuWB7UeK1Nzd8,3173
71
+ ramifice/utils/fixtures.py,sha256=PMRl1Ud0Ek0eX5F7BPiL7az_H7YKtIVKB8MJ17CeBdw,3179
72
72
  ramifice/utils/migration.py,sha256=5VYYB7DFMzLCRYWdlwtqGRSUPFdXp5SMxuMWraofVCw,11106
73
73
  ramifice/utils/tools.py,sha256=dJjG92nevSq_US30pUdbBy37pvqBdxXHBeHZxpOInKM,2843
74
- ramifice/utils/translations.py,sha256=aEkNKilD7RlJjBixqhh0cfIMw9lg13woaIwd3dyR8G4,4247
74
+ ramifice/utils/translations.py,sha256=Ibx6HqPcnsNxuBfXDs9mCLEA7xu4mkl3q39vqFaK-GI,4233
75
75
  ramifice/utils/unit.py,sha256=PPNKWYFJ8cz0nwbBPaTdL58_Nr7N0fIHFJBpKG2ZLKI,2482
76
76
  ramifice/utils/mixins/__init__.py,sha256=GrxJDsw73bEkitIh0-0BCxNnUK-N5uRXMCRlaPoaz1o,265
77
77
  ramifice/utils/mixins/add_valid.py,sha256=TLOObedzXNA9eCylfAVbVCqIKE5sV-P5AdIN7avj-GA,407
78
78
  ramifice/utils/mixins/hooks.py,sha256=33jvJRhfnJeL2Hd_YFXk3M_7wjqHaByU2wRjKyboL6s,914
79
79
  ramifice/utils/mixins/indexing.py,sha256=Z0427HoaVRyNmSNN8Fx0mSICgAKV-gDdu3iR5qYUEbs,329
80
80
  ramifice/utils/mixins/json_converter.py,sha256=2K_PZ34AzpesusgyyQFOLXFPcjXez3TWn-m9CHIKwRo,1131
81
- ramifice-0.8.1.dist-info/METADATA,sha256=-7ipjUF7Fx9rMP5ISYyeO_oAUBC3nmku8wkMtu1SG1s,21016
82
- ramifice-0.8.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
83
- ramifice-0.8.1.dist-info/licenses/LICENSE,sha256=LrEL0aTZx90HDwFUQCJutORiDjJL9AnuVvCtspXIqt4,1095
84
- ramifice-0.8.1.dist-info/RECORD,,
81
+ ramifice-0.8.3.dist-info/METADATA,sha256=oPmjSfAlrM-Uf-jeztkvHapDj1HkLptyEvwiPZkLrO4,21016
82
+ ramifice-0.8.3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
83
+ ramifice-0.8.3.dist-info/licenses/LICENSE,sha256=LrEL0aTZx90HDwFUQCJutORiDjJL9AnuVvCtspXIqt4,1095
84
+ ramifice-0.8.3.dist-info/RECORD,,