cave-utils 2.0.2__tar.gz → 2.0.3__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.
- {cave_utils-2.0.2 → cave_utils-2.0.3}/PKG-INFO +1 -1
- {cave_utils-2.0.2 → cave_utils-2.0.3}/cave_utils/api_utils/general.py +19 -7
- {cave_utils-2.0.2 → cave_utils-2.0.3}/cave_utils/api_utils/validator_utils.py +42 -1
- {cave_utils-2.0.2 → cave_utils-2.0.3}/cave_utils.egg-info/PKG-INFO +1 -1
- {cave_utils-2.0.2 → cave_utils-2.0.3}/pyproject.toml +1 -1
- {cave_utils-2.0.2 → cave_utils-2.0.3}/setup.cfg +1 -1
- {cave_utils-2.0.2 → cave_utils-2.0.3}/test/test_validator.py +1 -1
- {cave_utils-2.0.2 → cave_utils-2.0.3}/LICENSE +0 -0
- {cave_utils-2.0.2 → cave_utils-2.0.3}/NOTICE.md +0 -0
- {cave_utils-2.0.2 → cave_utils-2.0.3}/README.md +0 -0
- {cave_utils-2.0.2 → cave_utils-2.0.3}/cave_utils/__init__.py +0 -0
- {cave_utils-2.0.2 → cave_utils-2.0.3}/cave_utils/api/__init__.py +0 -0
- {cave_utils-2.0.2 → cave_utils-2.0.3}/cave_utils/api/appBar.py +0 -0
- {cave_utils-2.0.2 → cave_utils-2.0.3}/cave_utils/api/extraKwargs.py +0 -0
- {cave_utils-2.0.2 → cave_utils-2.0.3}/cave_utils/api/globalOutputs.py +0 -0
- {cave_utils-2.0.2 → cave_utils-2.0.3}/cave_utils/api/groupedOutputs.py +0 -0
- {cave_utils-2.0.2 → cave_utils-2.0.3}/cave_utils/api/mapFeatures.py +0 -0
- {cave_utils-2.0.2 → cave_utils-2.0.3}/cave_utils/api/maps.py +0 -0
- {cave_utils-2.0.2 → cave_utils-2.0.3}/cave_utils/api/pages.py +0 -0
- {cave_utils-2.0.2 → cave_utils-2.0.3}/cave_utils/api/panes.py +0 -0
- {cave_utils-2.0.2 → cave_utils-2.0.3}/cave_utils/api/settings.py +0 -0
- {cave_utils-2.0.2 → cave_utils-2.0.3}/cave_utils/api_utils/__init__.py +0 -0
- {cave_utils-2.0.2 → cave_utils-2.0.3}/cave_utils/api_utils/validator.py +0 -0
- {cave_utils-2.0.2 → cave_utils-2.0.3}/cave_utils/arguments.py +0 -0
- {cave_utils-2.0.2 → cave_utils-2.0.3}/cave_utils/log.py +0 -0
- {cave_utils-2.0.2 → cave_utils-2.0.3}/cave_utils/socket.py +0 -0
- {cave_utils-2.0.2 → cave_utils-2.0.3}/cave_utils.egg-info/SOURCES.txt +0 -0
- {cave_utils-2.0.2 → cave_utils-2.0.3}/cave_utils.egg-info/dependency_links.txt +0 -0
- {cave_utils-2.0.2 → cave_utils-2.0.3}/cave_utils.egg-info/requires.txt +0 -0
- {cave_utils-2.0.2 → cave_utils-2.0.3}/cave_utils.egg-info/top_level.txt +0 -0
- {cave_utils-2.0.2 → cave_utils-2.0.3}/test/test_arguments.py +0 -0
- {cave_utils-2.0.2 → cave_utils-2.0.3}/test/test_import.py +0 -0
- {cave_utils-2.0.2 → cave_utils-2.0.3}/test/test_log.py +0 -0
|
@@ -82,9 +82,12 @@ class props(ApiValidator):
|
|
|
82
82
|
* `"hstepper"`: Select a unique option along a horizontal slider
|
|
83
83
|
* `"vstepper"`: Select a unique option along a vertical slider
|
|
84
84
|
* When **`type`** == `"date"`:
|
|
85
|
-
* `"date"`: Select a date via a calendar pop-up that appears when the element is clicked
|
|
85
|
+
* `"date"`: Select a date via a calendar pop-up that appears when the element is clicked (default)
|
|
86
|
+
* **Note**: Passed as `YYYY-MM-DD`
|
|
86
87
|
* `"time"`: Select a time via a clock pop-up that appears when the element is clicked
|
|
88
|
+
* **Note**: Passed as `HH:MM:SS`
|
|
87
89
|
* `"datetime"`: Select date and time via a pop-up with calendar and clock tabs that appear when the element is clicked
|
|
90
|
+
* **Note**: Passed as `YYYY-MM-DDTHH:MM:SS`
|
|
88
91
|
* When **`type`** == `"media"`:
|
|
89
92
|
* `"picture"`: Show a PNG or JPG image
|
|
90
93
|
* `"video"`: Display a YouTube, Vimeo, or Dailymotion video clip
|
|
@@ -509,10 +512,13 @@ class values(ApiValidator):
|
|
|
509
512
|
options = list(prop_spec.get("options", {}).keys())
|
|
510
513
|
self.__check_subset_valid__(prop_value, options, prepend_path=[prop_key])
|
|
511
514
|
elif prop_type == "date":
|
|
512
|
-
|
|
513
|
-
|
|
515
|
+
self.__check_date_valid__(
|
|
516
|
+
prop_value,
|
|
517
|
+
date_variant=prop_spec.get("variant", "date"),
|
|
518
|
+
prepend_path=[prop_key],
|
|
519
|
+
)
|
|
514
520
|
elif prop_type == "media":
|
|
515
|
-
self.__check_url_valid__(prop_value)
|
|
521
|
+
self.__check_url_valid__(prop_value, prepend_path=[prop_key])
|
|
516
522
|
|
|
517
523
|
|
|
518
524
|
@type_enforced.Enforcer
|
|
@@ -593,8 +599,14 @@ class valueLists(ApiValidator):
|
|
|
593
599
|
msg=f"`{prop_key}` with the prop type of `{prop_type}` can not have an associated value."
|
|
594
600
|
)
|
|
595
601
|
elif prop_type == "date":
|
|
596
|
-
|
|
597
|
-
|
|
602
|
+
prop_value_list_set = list(set(prop_value_list))
|
|
603
|
+
date_variant = prop_spec.get("variant", "date")
|
|
604
|
+
for prop_value in prop_value_list:
|
|
605
|
+
if not self.__check_date_valid__(
|
|
606
|
+
prop_value, date_variant=date_variant, prepend_path=[prop_key]
|
|
607
|
+
):
|
|
608
|
+
continue
|
|
598
609
|
elif prop_type == "media":
|
|
599
610
|
for prop_value in prop_value_list:
|
|
600
|
-
self.__check_url_valid__(prop_value)
|
|
611
|
+
if not self.__check_url_valid__(prop_value, prepend_path=[prop_key]):
|
|
612
|
+
continue
|
|
@@ -3,7 +3,7 @@ Special utility functions to help in validating your data against the CAVE API.
|
|
|
3
3
|
"""
|
|
4
4
|
from pamda import pamda
|
|
5
5
|
import type_enforced
|
|
6
|
-
import re
|
|
6
|
+
import re, datetime
|
|
7
7
|
from cave_utils.log import LogHelper, LogObject
|
|
8
8
|
|
|
9
9
|
|
|
@@ -143,6 +143,47 @@ class ApiValidator:
|
|
|
143
143
|
)
|
|
144
144
|
if re.match(regex, url) is None:
|
|
145
145
|
self.__error__(path=prepend_path, msg="Invalid url")
|
|
146
|
+
return False
|
|
147
|
+
return True
|
|
148
|
+
|
|
149
|
+
def __check_date_valid__(self, input: str, date_variant: str, prepend_path: list = list()):
|
|
150
|
+
"""
|
|
151
|
+
Validate a date string and if an issue is present, log an error.
|
|
152
|
+
"""
|
|
153
|
+
if date_variant == "date":
|
|
154
|
+
try:
|
|
155
|
+
datetime.datetime.strptime(input, "%Y-%m-%d")
|
|
156
|
+
except ValueError:
|
|
157
|
+
self.__error__(
|
|
158
|
+
path=prepend_path,
|
|
159
|
+
msg=f"Invalid input for type of `date` with variant `date`. Must be in the format `YYYY-MM-DD`",
|
|
160
|
+
)
|
|
161
|
+
return False
|
|
162
|
+
elif date_variant == "datetime":
|
|
163
|
+
try:
|
|
164
|
+
datetime.datetime.strptime(input, "%Y-%m-%dT%H:%M:%S")
|
|
165
|
+
except ValueError:
|
|
166
|
+
self.__error__(
|
|
167
|
+
path=prepend_path,
|
|
168
|
+
msg=f"Invalid input for type of `date` with variant `datetime`. Must be in the format `YYYY-MM-DDTHH:MM:SS`",
|
|
169
|
+
)
|
|
170
|
+
return False
|
|
171
|
+
elif date_variant == "time":
|
|
172
|
+
try:
|
|
173
|
+
datetime.datetime.strptime(input, "%H:%M:%S")
|
|
174
|
+
except ValueError:
|
|
175
|
+
self.__error__(
|
|
176
|
+
path=prepend_path,
|
|
177
|
+
msg=f"Invalid input for type of `date` with variant `time`. Must be in the format `HH:MM:SS`",
|
|
178
|
+
)
|
|
179
|
+
return False
|
|
180
|
+
else:
|
|
181
|
+
self.__error__(
|
|
182
|
+
path=prepend_path,
|
|
183
|
+
msg=f"Invalid variant ({date_variant}) for prop with type `date`. Must be one of `date`, `datetime`, or `time`",
|
|
184
|
+
)
|
|
185
|
+
return False
|
|
186
|
+
return True
|
|
146
187
|
|
|
147
188
|
def __check_subset_valid__(
|
|
148
189
|
self,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|