-
Notifications
You must be signed in to change notification settings - Fork 30
/
papers.py
56 lines (43 loc) · 1.73 KB
/
papers.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
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/env python3
""" Computer-based immigration office for Kanadia """
__author__ = 'Susan Sim'
__email__ = "ses@drsusansim.org"
__copyright__ = "2014 Susan Sim"
__license__ = "MIT License"
__status__ = "Prototype"
# imports one per line
import re
import datetime
import json
def decide(input_file, watchlist_file, countries_file):
"""
Decides whether a traveller's entry into Kanadia should be accepted
:param input_file: The name of a JSON formatted file that contains cases to decide
:param watchlist_file: The name of a JSON formatted file that contains names and passport numbers on a watchlist
:param countries_file: The name of a JSON formatted file that contains country data, such as whether
an entry or transit visa is required, and whether there is currently a medical advisory
:return: List of strings. Possible values of strings are: "Accept", "Reject", "Secondary", and "Quarantine"
"""
return ["Reject"]
def valid_passport_format(passport_number):
"""
Checks whether a pasport number is five sets of five alpha-number characters separated by dashes
:param passport_number: alpha-numeric string
:return: Boolean; True if the format is valid, False otherwise
"""
passport_format = re.compile('^.{5}-.{5}-.{5}-.{5}-.{5}$')
if passport_format.match(passport_number):
return True
else:
return False
def valid_date_format(date_string):
"""
Checks whether a date has the format YYYY-mm-dd in numbers
:param date_string: date to be checked
:return: Boolean True if the format is valid, False otherwise
"""
try:
datetime.datetime.strptime(date_string, '%Y-%m-%d')
return True
except ValueError:
return False