request_casting 0.6.0__tar.gz → 1.0.0__tar.gz

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.
@@ -1,18 +1,21 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: request_casting
3
- Version: 0.6.0
3
+ Version: 1.0.0
4
4
  Summary: Provide method to cast django request data for POST and GET methods
5
5
  License: GPL-3.0 license
6
+ License-File: LICENSE
6
7
  Author: turulomio
7
8
  Author-email: turulomio@yahoo.es
8
- Requires-Python: >3.8,<4.0
9
+ Requires-Python: >=3.12,<4
9
10
  Classifier: License :: Other/Proprietary License
10
11
  Classifier: Programming Language :: Python :: 3
11
- Classifier: Programming Language :: Python :: 3.9
12
- Classifier: Programming Language :: Python :: 3.10
13
- Classifier: Programming Language :: Python :: 3.11
14
12
  Classifier: Programming Language :: Python :: 3.12
15
- Requires-Dist: pydicts (>=0.11.0)
13
+ Classifier: Programming Language :: Python :: 3.13
14
+ Classifier: Programming Language :: Python :: 3.14
15
+ Requires-Dist: pydicts (>=1.3.0)
16
+ Project-URL: Homepage, https://github.com/turulomio/request_casting/
17
+ Project-URL: Repository, https://github.com/turulomio/request_casting/
18
+ Project-URL: changelog, https://github.com/turulomio/request_casting#changelog
16
19
  Description-Content-Type: text/markdown
17
20
 
18
21
  # request_casting
@@ -109,6 +112,19 @@ curl http://localhost:8000/myview/?a=2011-10-05T14:48:00.000Z => a will be a d
109
112
  curl http://localhost:8000/myview/?a=2021-1-1 => a will be None
110
113
  ```
111
114
 
115
+ ### RequestEmail
116
+ Use this method inside a view to get a validated email
117
+
118
+ ```python
119
+ # ... The same as RequestBool example
120
+ a=request_casting.RequestEmail(request, "a")
121
+ ```
122
+ You'll get this answers
123
+ ```
124
+ curl http://localhost:8000/myview/?a=hi@hi.com => a will be an email
125
+ curl http://localhost:8000/myview/?a=hi.hi.com => a will be None
126
+ ```
127
+
112
128
  ### RequestInteger
113
129
 
114
130
  Use this method inside a view to get a casted Integer
@@ -211,6 +227,16 @@ curl "http://localhost:8000/myview/?a[]=http://localhost:8000/api/records/1/&a[]
211
227
 
212
228
  ## Other usefull functions
213
229
 
230
+ ### all_args_are_none
231
+
232
+ Returns True if all function arguments are None. It's very usefull to compare view parameters faster.
233
+
234
+ ```python
235
+ request_casting.all_args_are_none(None, None, None) #Returns True
236
+ request_casting.all_args_are_none(1, None, None)# Returns False
237
+ request_casting.all_args_are_none(1, 1, 1) #Return False
238
+ ```
239
+
214
240
  ### all_args_are_not_empty
215
241
 
216
242
  Returns True if all function arguments are different to None and ""
@@ -240,24 +266,3 @@ It's very usefull to compare view parameters fast.
240
266
 
241
267
  Run `poe coverage` to test module.
242
268
 
243
- ## Changelog
244
-
245
- ### 0.5.0 (2023-12-05)
246
- - Added support to request_casting with json formats (APICLIENT)
247
-
248
- ### 0.4.0 (2023-12-05)
249
- - Migrated to pydicts-0.9.0
250
-
251
- ### 0.3.0 (2023-12-04)
252
- - Improved parse_from_url and object_from_url validations
253
- - Added validate_object to RequestUrl and RequestListOfUrls to validate returned objects
254
- - Added gettext support
255
-
256
- ### 0.2.0 (2023-11-18)
257
- - Improving documentation
258
- - All default values are set to None, including RequestList methods
259
- - string2dtaware now uses ZoneInfo instead of pytz
260
-
261
- ### 0.1.0 (2023-11-15)
262
- - Converted reusingcode module to an independent module
263
-
@@ -92,6 +92,19 @@ curl http://localhost:8000/myview/?a=2011-10-05T14:48:00.000Z => a will be a d
92
92
  curl http://localhost:8000/myview/?a=2021-1-1 => a will be None
93
93
  ```
94
94
 
95
+ ### RequestEmail
96
+ Use this method inside a view to get a validated email
97
+
98
+ ```python
99
+ # ... The same as RequestBool example
100
+ a=request_casting.RequestEmail(request, "a")
101
+ ```
102
+ You'll get this answers
103
+ ```
104
+ curl http://localhost:8000/myview/?a=hi@hi.com => a will be an email
105
+ curl http://localhost:8000/myview/?a=hi.hi.com => a will be None
106
+ ```
107
+
95
108
  ### RequestInteger
96
109
 
97
110
  Use this method inside a view to get a casted Integer
@@ -194,6 +207,16 @@ curl "http://localhost:8000/myview/?a[]=http://localhost:8000/api/records/1/&a[]
194
207
 
195
208
  ## Other usefull functions
196
209
 
210
+ ### all_args_are_none
211
+
212
+ Returns True if all function arguments are None. It's very usefull to compare view parameters faster.
213
+
214
+ ```python
215
+ request_casting.all_args_are_none(None, None, None) #Returns True
216
+ request_casting.all_args_are_none(1, None, None)# Returns False
217
+ request_casting.all_args_are_none(1, 1, 1) #Return False
218
+ ```
219
+
197
220
  ### all_args_are_not_empty
198
221
 
199
222
  Returns True if all function arguments are different to None and ""
@@ -222,24 +245,3 @@ It's very usefull to compare view parameters fast.
222
245
  ## Test module
223
246
 
224
247
  Run `poe coverage` to test module.
225
-
226
- ## Changelog
227
-
228
- ### 0.5.0 (2023-12-05)
229
- - Added support to request_casting with json formats (APICLIENT)
230
-
231
- ### 0.4.0 (2023-12-05)
232
- - Migrated to pydicts-0.9.0
233
-
234
- ### 0.3.0 (2023-12-04)
235
- - Improved parse_from_url and object_from_url validations
236
- - Added validate_object to RequestUrl and RequestListOfUrls to validate returned objects
237
- - Added gettext support
238
-
239
- ### 0.2.0 (2023-11-18)
240
- - Improving documentation
241
- - All default values are set to None, including RequestList methods
242
- - string2dtaware now uses ZoneInfo instead of pytz
243
-
244
- ### 0.1.0 (2023-11-15)
245
- - Converted reusingcode module to an independent module
@@ -1,34 +1,40 @@
1
- [tool.poetry]
1
+
2
+ [project]
2
3
  name = "request_casting"
3
- version = "0.6.0"
4
+ version = "1.0.0"
4
5
  description = "Provide method to cast django request data for POST and GET methods"
5
- authors = ["turulomio <turulomio@yahoo.es>"]
6
- license = "GPL-3.0 license"
6
+ authors = [{name = "turulomio", email = "turulomio@yahoo.es"}]
7
+ license = {text = "GPL-3.0 license"}
7
8
  readme = "README.md"
9
+ requires-python = ">=3.12,<4"
10
+ dependencies = [
11
+ "pydicts >=1.3.0",
12
+ ]
13
+
14
+
15
+ [project.urls]
16
+ homepage = "https://github.com/turulomio/request_casting/"
17
+ repository = "https://github.com/turulomio/request_casting/"
18
+ changelog = "https://github.com/turulomio/request_casting#changelog"
8
19
 
9
- [tool.poetry.dependencies]
10
- python = ">3.8,<4.0"
11
- pydicts = ">=0.11.0"
12
20
 
13
21
  [tool.poetry.group.dev.dependencies]
14
- poetry = ">=1.5.1"
15
- poethepoet = ">=0.22.0"
16
- django = ">=4.2.7"
17
- djangorestframework = ">=3.14.0"
18
- coverage = ">=7.3.2"
22
+ poetry = ">=2.4.1"
23
+ poethepoet = ">=0.45.0"
24
+ django = ">=6.0.5"
25
+ djangorestframework = ">=3.17.1"
26
+ coverage = ">=7.13.5"
27
+
19
28
 
20
29
  [build-system]
21
- requires = ["poetry-core"]
30
+ requires = ["poetry-core>=2.0.0,<3.0.0"]
22
31
  build-backend = "poetry.core.masonry.api"
23
32
 
33
+
34
+
24
35
  [tool.poe.tasks]
25
36
  release = { script = "request_casting.poethepoet:release" }
26
37
  reusing = { script = "request_casting.poethepoet:reusing" }
27
38
  test = { script = "request_casting.poethepoet:test" }
28
39
  coverage = { script = "request_casting.poethepoet:coverage" }
29
40
  translate = { script = "request_casting.poethepoet:translate" }
30
-
31
- [project.urls]
32
- homepage = "https://github.com/turulomio/request_casting/"
33
- repository = "https://github.com/turulomio/request_casting/"
34
- changelog = "https://github.com/turulomio/request_casting#changelog"
@@ -1,4 +1,4 @@
1
1
  from datetime import datetime
2
- __version__="0.6.0"
3
- __version_datetime__=datetime(2023, 12, 14, 20, 39)
2
+ __version__="1.0.0"
3
+ __version_datetime__=datetime(2026, 5, 10, 17, 37)
4
4
  __version_date__=__version_datetime__.date()
@@ -0,0 +1,28 @@
1
+ # Spanish translations for PACKAGE package
2
+ # Traducciones al español para el paquete PACKAGE.
3
+ # Copyright (C) 2024 turulomio <turulomio@yahoo.es>
4
+ # This file is distributed under the same license as the request_casting package.
5
+ #
6
+ # turulomio <turulomio@yahoo.es>, 2024.
7
+ msgid ""
8
+ msgstr ""
9
+ "Project-Id-Version: request_casting\n"
10
+ "Report-Msgid-Bugs-To: \n"
11
+ "POT-Creation-Date: 2024-05-15 10:00+0000\n"
12
+ "PO-Revision-Date: 2024-05-15 10:00+0000\n"
13
+ "Last-Translator: turulomio <turulomio@yahoo.es>\n"
14
+ "Language-Team: Spanish\n"
15
+ "Language: es\n"
16
+ "MIME-Version: 1.0\n"
17
+ "Content-Type: text/plain; charset=UTF-8\n"
18
+ "Content-Transfer-Encoding: 8bit\n"
19
+ "Plural-Forms: nplurals=2; plural=(n != 1);\n"
20
+ "X-Generator: Lokalize 19.12.3\n"
21
+
22
+ #, python-brace-format
23
+ msgid "I couldn't get id from this url: {0}"
24
+ msgstr "No pude conseguir el id de esta url: {0}"
25
+
26
+ #, python-brace-format
27
+ msgid "Url ({0}) couldn't be parsed. Model: {1}. Real string before id: {2}"
28
+ msgstr "La URL ({0}) no pudo ser parseada. Modelo: {1}. Cadena real antes del ID: {2}"
@@ -8,7 +8,7 @@ msgid ""
8
8
  msgstr ""
9
9
  "Project-Id-Version: PACKAGE VERSION\n"
10
10
  "Report-Msgid-Bugs-To: \n"
11
- "POT-Creation-Date: 2023-12-14 20:40+0100\n"
11
+ "POT-Creation-Date: 2026-05-10 17:38+0200\n"
12
12
  "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
13
13
  "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
14
14
  "Language-Team: LANGUAGE <LL@li.org>\n"
@@ -21,7 +21,6 @@ def translate():
21
21
  system("xgettext -L Python --no-wrap --no-location --from-code='UTF-8' -o request_casting/locale/request_casting.pot request_casting/*.py")
22
22
  system("msgmerge -N --no-wrap -U request_casting/locale/es.po request_casting/locale/request_casting.pot")
23
23
  system("msgfmt -cv -o request_casting/locale/es/LC_MESSAGES/request_casting.mo request_casting/locale/es.po")
24
- system("msgfmt -cv -o request_casting/locale/en/LC_MESSAGES/request_casting.mo request_casting/locale/en.po")
25
24
 
26
25
  def release():
27
26
  print("""Nueva versión:
@@ -204,6 +204,20 @@ def RequestDtaware(request, field, timezone_string, default=None):
204
204
 
205
205
 
206
206
  return casts.str2dtaware(dictionary.get(field), "JsUtcIso", timezone_string, ignore_exception=True, ignore_exception_value=default)
207
+
208
+ def RequestEmail(request, field, default=None):
209
+ if request.method=="GET":
210
+ dictionary=request.GET
211
+ else:
212
+ dictionary=request.data
213
+
214
+ if not field in dictionary:
215
+ return default
216
+
217
+ if casts.is_email(dictionary.get(field)):
218
+ return dictionary.get(field)
219
+ else:
220
+ return default
207
221
 
208
222
  def RequestString(request, field, default=None):
209
223
  if request.method=="GET":
@@ -298,3 +312,10 @@ def all_args_are_not_empty(*args):
298
312
  if arg is None or arg=="":
299
313
  return False
300
314
  return True
315
+
316
+ ## Returns false if some arg is None
317
+ def all_args_are_none(*args):
318
+ for arg in args:
319
+ if arg is not None:
320
+ return False
321
+ return True
@@ -1,20 +0,0 @@
1
- # Spanish translations for PACKAGE package
2
- # Traducciones al español para el paquete PACKAGE.
3
- # Copyright (C) 2015 THE PACKAGE'S COPYRIGHT HOLDER
4
- # This file is distributed under the same license as the PACKAGE package.
5
- #
6
- # root <turulomio@yahoo.es>, 2015, 2020.
7
- msgid ""
8
- msgstr ""
9
- "Project-Id-Version: UnoGenerator\n"
10
- "Report-Msgid-Bugs-To: \n"
11
- "POT-Creation-Date: 2021-10-04 05:20+0200\n"
12
- "PO-Revision-Date: 2020-04-03 08:54+0200\n"
13
- "Last-Translator: Turulomio <turulomio@yahoo.es>\n"
14
- "Language-Team: Turulomio <turulomio@yahoo.es>\n"
15
- "Language: en\n"
16
- "MIME-Version: 1.0\n"
17
- "Content-Type: text/plain; charset=UTF-8\n"
18
- "Content-Transfer-Encoding: 8bit\n"
19
- "Plural-Forms: nplurals=2; plural=(n != 1);\n"
20
- "X-Generator: Lokalize 19.12.3\n"
@@ -1,40 +0,0 @@
1
- # Spanish translations for PACKAGE package
2
- # Traducciones al español para el paquete PACKAGE.
3
- # Copyright (C) 2015 THE PACKAGE'S COPYRIGHT HOLDER
4
- # This file is distributed under the same license as the PACKAGE package.
5
- #
6
- # root <turulomio@yahoo.es>, 2015, 2020.
7
- msgid ""
8
- msgstr ""
9
- "Project-Id-Version: TooManyFiles\n"
10
- "Report-Msgid-Bugs-To: \n"
11
- "POT-Creation-Date: 2023-12-14 20:40+0100\n"
12
- "PO-Revision-Date: 2020-04-03 08:54+0200\n"
13
- "Last-Translator: trabajo <turulomio@yahoo.es>\n"
14
- "Language-Team: Spanish <kde-i18n-doc@kde.org>\n"
15
- "Language: es\n"
16
- "MIME-Version: 1.0\n"
17
- "Content-Type: text/plain; charset=UTF-8\n"
18
- "Content-Transfer-Encoding: 8bit\n"
19
- "Plural-Forms: nplurals=2; plural=(n != 1);\n"
20
- "X-Generator: Lokalize 19.12.3\n"
21
-
22
- #, python-brace-format
23
- msgid "I couldn't get id from this url: {0}"
24
- msgstr "No pude conseguir el id de esta url: {0}"
25
-
26
- #, python-brace-format
27
- msgid "Url ({0}) couldn't be parsed. Model: {1}. Real string before id: {2}"
28
- msgstr ""
29
-
30
- #, python-brace-format
31
- #~ msgid "Error in RequestDate with method {0}"
32
- #~ msgstr "Error en RequestDate con método {0}"
33
-
34
- #, python-brace-format
35
- #~ msgid "Error in RequestBool with method {0}"
36
- #~ msgstr "Error en RequestBool con método {0}"
37
-
38
- #, python-brace-format
39
- #~ msgid "Error in RequestDecimal with method {0}"
40
- #~ msgstr "Error en RequestDecimal con método {0}"
File without changes