-
Notifications
You must be signed in to change notification settings - Fork 1
/
server.py
44 lines (34 loc) · 1.51 KB
/
server.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
from time import strptime
import sys
from eve import Eve
from eve.io.mongo import Validator
from eve.utils import api_prefix
from auth.authentication import EVETokenAuth
from base_hooks import set_hooks, set_docs, set_methods
class EmpoweringValidator(Validator):
# def _validate_type_string(self, field, value):
# # \s == the special re sequence '\s' matches Unicode whitespace characters including [ \t\n\r\f\v]
# if re.sub('[\r\n\t]', '', value) != value:
# self._error(field, "Field %s contains special characters: %s" % (field, re.sub('[\r\n\t]', '', value)))
# def _validate_type_companyid(self, field, value):
# if not companies_cache.get(value):
# companies_cache.rebuild()
# if not companies_cache.get(value):
# self._error(field, "companyId field does not exist: %s" % value)
def _validate_type_hour(self, field, value):
try:
strptime(value, "%H:%M:%S")
except ValueError:
self._error(field, "Field %s is not valid: %s. Expected format: hh:mm:ss" % (field, value))
def _validate_type_month(self, field, value):
try:
strptime(value, "%m-%d")
except ValueError:
self._error(field, "Field %s is not valid: %s. Expected format: MM-DD" % (field, value))
app = Eve(validator=EmpoweringValidator, auth=EVETokenAuth)
set_hooks(app)
set_methods(app)
set_docs(app)
prefix = api_prefix(api_version=app.config['API_VERSION'])
if __name__ == '__main__':
app.run()