This repository was archived by the owner on Jul 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtasker.py
More file actions
96 lines (82 loc) · 2.21 KB
/
tasker.py
File metadata and controls
96 lines (82 loc) · 2.21 KB
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#IRYNA KHOMYCH
# test - 456
# 123
# SHELLSHOCK
# 456
import argparse #yuliakordunova for irina
# 45
#balabuda
#Valeriia Balatska
import argparse #yuliakordunova
import json # We use JSON to store date to file
import datetime
import random
def get_current_date(format):
# Python is well know
# for hard work with time
# https://www.programiz.com/python-programming/datetime/current-datetime
now = datetime.datetime.now()
return now.strftime(format)
def get_args():
parser = argparse.ArgumentParser(description='pyTasker - easy tasker sample')
parser.add_argument(
'--create',
help="Interactive task creation"
)
parser.add_argument(
'--modify',
help="Interactive task modification"
)
parser.add_argument(
'--delete',
help="Interactive task deletion"
)
parser.add_argument(
'--show',
help="Show current agenda"
)
parser.add_argument(
'--show-date',
help="Show agenda for some date"
)
args = parser.parse_args()
return args
def get_db():
try:
# If data available and we can read
# we convert is to JSON format
with open(DB_FILE, 'r') as db_read_file:
db = json.load(db_read_file)
return db
except ValueError:
# But!
# If it is empty, will get Error: Cant load empty data!
# If so, we will catch those error, and Handle It by using {}
# empty dict. Empty dict is not empty data, and json.loads
# knows how to read it!
print "[!!] No data in DB."
return {}
def create():
# Input: https://www.geeksforgeeks.org/taking-input-in-python/
name = str(raw_input("Name of task:"))
date = str(raw_input("Date of task:"))
db[date] = name
def main():
args = get_args()
db = get_db()
db["today"] = TODAY
if args.create:
create(db)
print db
with open(DB_FILE, 'w') as db_write_file:
json.dump(db, db_write_file, sort_keys=True, indent=4)
#print(dump_db)
# f.write(dump_db)
# f.close()
# Config
DB_FILE='tasker.db'
FORMAT="%Y/%m/%d"# %H:%M:%S"
TODAY=get_current_date(FORMAT)
if __name__ == '__main__':
print("pyTasker")
main()