clear-skies 1.19.6__py3-none-any.whl → 1.19.8__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.

Potentially problematic release.


This version of clear-skies might be problematic. Click here for more details.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: clear-skies
3
- Version: 1.19.6
3
+ Version: 1.19.8
4
4
  Summary: A framework for building backends in the cloud
5
5
  Home-page: https://github.com/cmancone/clearskies
6
6
  License: MIT
@@ -159,7 +159,9 @@ clearskies/input_outputs/exceptions/cli_input_error.py,sha256=kOFU8aLTLmeTL_AKDs
159
159
  clearskies/input_outputs/exceptions/cli_not_found.py,sha256=JBBuZA9ZwdkPhd3a0qaGgEPQrxh1fehy4R3ZaV2gWXU,39
160
160
  clearskies/input_outputs/input_output.py,sha256=vYKn9SE5erS4LuOhhAsXqaOEsGXwZ1NJ4v85KN1Xg6A,4501
161
161
  clearskies/input_outputs/wsgi.py,sha256=9p82eJP5FUAI6jbIojvydG3_9gncX7vcUACQMyRN9x4,3142
162
- clearskies/input_requirements/__init__.py,sha256=7PVLuq60-LjO4wteZMiHTS3z8QWNdspnQQlzh-sohMc,1456
162
+ clearskies/input_requirements/__init__.py,sha256=vIqm8KDiomQSxT7WjogFi1yOOrsVrNMb5GKlfw5USNk,1836
163
+ clearskies/input_requirements/after.py,sha256=TXy8bIVz_77a8oJuohPwoM5E--AOVWsOSjjh5PpA2Ys,1544
164
+ clearskies/input_requirements/before.py,sha256=iLg-Hub9iW2eP19s5fkPrA9TCT_-DTm5KoxgA8ho0-k,1547
163
165
  clearskies/input_requirements/in_the_future_at_least.py,sha256=PLVp_2Yv-1ScKnajlc9hjG7qYZhadKXHNTkRP7WKUdo,739
164
166
  clearskies/input_requirements/in_the_future_at_most.py,sha256=L5Oz47KAHv5WL6Nu2vGkql6q8Ha9IKJMj-uxQkyuIdc,737
165
167
  clearskies/input_requirements/in_the_past_at_least.py,sha256=ES0SgtADHcu7HZDdvIFyD9vpYTnrd4hBi03OShqUZg4,735
@@ -197,7 +199,7 @@ clearskies/tests/simple_api/models/__init__.py,sha256=nUA0W6fgXw_Bxa9CudkaDkC80t
197
199
  clearskies/tests/simple_api/models/status.py,sha256=PEhPbaQh5qdUNHp8O0gz91LOLENAEBtqSaHxUPXchaM,699
198
200
  clearskies/tests/simple_api/models/user.py,sha256=5_P4Tp1tTdX7PkMJ__epPM5MA7JAeVYGas69vcWloLc,819
199
201
  clearskies/tests/simple_api/users_api.py,sha256=KYXCgEofDxHeRdQK67txN5oYUPvxxmB8JTku7L-apk4,2344
200
- clear_skies-1.19.6.dist-info/LICENSE,sha256=3Ehd0g3YOpCj8sqj0Xjq5qbOtjjgk9qzhhD9YjRQgOA,1053
201
- clear_skies-1.19.6.dist-info/METADATA,sha256=-DjicQ4vxHg6QBQ-JmqHq6Jj5ffO09Umuv93ExJ7gr0,1366
202
- clear_skies-1.19.6.dist-info/WHEEL,sha256=d2fvjOD7sXsVzChCqf0Ty0JbHKBaLYwDbGQDwQTnJ50,88
203
- clear_skies-1.19.6.dist-info/RECORD,,
202
+ clear_skies-1.19.8.dist-info/LICENSE,sha256=3Ehd0g3YOpCj8sqj0Xjq5qbOtjjgk9qzhhD9YjRQgOA,1053
203
+ clear_skies-1.19.8.dist-info/METADATA,sha256=ItzA59xKexgK8-N_kyD459-tDdgUy3Yji5lJptXLbik,1366
204
+ clear_skies-1.19.8.dist-info/WHEEL,sha256=d2fvjOD7sXsVzChCqf0Ty0JbHKBaLYwDbGQDwQTnJ50,88
205
+ clear_skies-1.19.8.dist-info/RECORD,,
@@ -1,5 +1,7 @@
1
1
  import datetime
2
2
 
3
+ from .after import After
4
+ from .before import Before
3
5
  from ..binding_config import BindingConfig
4
6
  from .minimum_length import MinimumLength
5
7
  from .maximum_length import MaximumLength
@@ -13,11 +15,19 @@ from .in_the_past_at_most import InThePastAtMost
13
15
  from .time_delta import TimeDelta
14
16
 
15
17
 
16
- def minimum_length(minimum_length):
18
+ def after(other_column_name: str, allow_equal: bool = False):
19
+ return BindingConfig(After, other_column_name=other_column_name, allow_equal=allow_equal)
20
+
21
+
22
+ def before(other_column_name: str, allow_equal: bool = False):
23
+ return BindingConfig(Before, other_column_name=other_column_name, allow_equal=allow_equal)
24
+
25
+
26
+ def minimum_length(minimum_length: int):
17
27
  return BindingConfig(MinimumLength, minimum_length)
18
28
 
19
29
 
20
- def maximum_length(maximum_length):
30
+ def maximum_length(maximum_length: int):
21
31
  return BindingConfig(MaximumLength, maximum_length)
22
32
 
23
33
 
@@ -0,0 +1,36 @@
1
+ from .requirement import Requirement
2
+ import datetime
3
+ import dateparser
4
+
5
+
6
+ class After(Requirement):
7
+ def configure(self, other_column_name: str, allow_equal: bool = False):
8
+ self.other_column_name = other_column_name
9
+ self.allow_equal = allow_equal
10
+
11
+ def check(self, model, data):
12
+ # we won't check anything for missing values (columns should be required if that is an issue)
13
+ if not data.get(self.column_name):
14
+ return ""
15
+ my_value = data[self.column_name]
16
+ other_value = data.get(self.other_column_name, model.__getitem__(self.other_column_name))
17
+ # again, no checks for non-values
18
+ if not other_value:
19
+ return ""
20
+
21
+ my_value_as_date = dateparser.parse(data[self.column_name])
22
+ if not my_value_as_date:
23
+ return f"'{self.column_name}' was not a valid date."
24
+
25
+ if type(other_value) != str and type(other_value) != datetime.datetime:
26
+ return f"'{other_column_name}' was not a valid date."
27
+ other_value_as_date = dateparser.parse(other_value) if type(other_value) == str else other_value
28
+ if not other_value_as_date:
29
+ return f"'{self.other_column_name}' was not a valid date."
30
+
31
+ if my_value_as_date == other_value_as_date:
32
+ return "" if self.allow_equal else f"'{self.column_name}' must be after '{self.other_column_name}'"
33
+
34
+ if my_value_as_date < other_value_as_date:
35
+ return f"'{self.column_name}' must be after '{self.other_column_name}'"
36
+ return ""
@@ -0,0 +1,36 @@
1
+ from .requirement import Requirement
2
+ import datetime
3
+ import dateparser
4
+
5
+
6
+ class Before(Requirement):
7
+ def configure(self, other_column_name: str, allow_equal: bool = False):
8
+ self.other_column_name = other_column_name
9
+ self.allow_equal = allow_equal
10
+
11
+ def check(self, model, data):
12
+ # we won't check anything for missing values (columns should be required if that is an issue)
13
+ if not data.get(self.column_name):
14
+ return ""
15
+ my_value = data[self.column_name]
16
+ other_value = data.get(self.other_column_name, model.__getitem__(self.other_column_name))
17
+ # again, no checks for non-values
18
+ if not other_value:
19
+ return ""
20
+
21
+ my_value_as_date = dateparser.parse(data[self.column_name])
22
+ if not my_value_as_date:
23
+ return f"'{self.column_name}' was not a valid date."
24
+
25
+ if type(other_value) != str and type(other_value) != datetime.datetime:
26
+ return f"'{other_column_name}' was not a valid date."
27
+ other_value_as_date = dateparser.parse(other_value) if type(other_value) == str else other_value
28
+ if not other_value_as_date:
29
+ return f"'{self.other_column_name}' was not a valid date."
30
+
31
+ if my_value_as_date == other_value_as_date:
32
+ return "" if self.allow_equal else f"'{self.column_name}' must be before '{self.other_column_name}'"
33
+
34
+ if my_value_as_date > other_value_as_date:
35
+ return f"'{self.column_name}' must be before '{self.other_column_name}'"
36
+ return ""