-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils.py
37 lines (31 loc) · 931 Bytes
/
utils.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
from dateutil.relativedelta import relativedelta
from datetime import datetime
from os import path
import csv
class Utils(object):
def __init__(self):
pass
@staticmethod
def check_license(code, dt):
if datetime.now() <= datetime.strptime(dt, '%Y/%m/%d'):
return True
else:
return False
@staticmethod
def check_code(code):
filename = path.join('.', 'configs', 'keys.csv')
reader = csv.reader(open(filename, 'r'))
codes = []
for index, row in enumerate(reader):
codes.append(row[0])
if code in codes:
return True
else:
return False
@staticmethod
def three_days_warning(dt):
three_days_date = datetime.now() + relativedelta(days=3)
if three_days_date >= datetime.strptime(dt, '%Y/%m/%d'):
return True
else:
return False