Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!usr/bin/python
- ##Timer Tool - Input
- import datetime, io, pickle
- class Database:
- def __init__(self):
- self.tickets = {}
- self.ticket_id = 0
- def add_ticket(self):
- print()
- print()
- print("Allright, adding a ticket.")
- link = input("Paste the URL here: ")
- delay = input("How many days to delay this? ")
- delay = int(delay)
- notes = input("Type any notes here: ")
- arf = datetime.date.today()
- thirty = [8, 4, 6, 11]
- disp_month = arf.month
- if arf.month in thirty:
- if arf.day + delay > 30:
- disp_day = (arf.day-30) + delay
- if arf.month == 12:
- disp_month = 1
- else:
- disp_month = arf.month + 1
- else:
- disp_day = arf.day + delay
- elif arf.month == 2:
- if arf.day + delay > 28:
- disp_day = (arf.day-28) + delay
- if arf.month == 12:
- disp_month = 1
- else:
- disp_month = arf.month + 1
- else:
- disp_day = arf.day + delay
- else:
- if arf.day + delay > 31:
- disp_day = (arf.day-31) + delay
- if arf.month == 12:
- disp_month = 1
- else:
- disp_month = arf.month + 1
- else:
- disp_day = arf.day + delay
- self.ticket_id += 1
- mew = self.ticket_id + 1
- mew = str(mew)
- self.tickets[mew] = {}
- arf = self.tickets[mew]
- arf['link'] = link
- arf['disp_mont'] = disp_month
- arf['disp_day'] = disp_day
- arf['notes'] = notes
- print(arf)
- data = open('database.otter', 'wb')
- pickle.dump(self, data)
- data.close()
- def display_ticket(self):
- arf = datetime.date.today()
- disp_day = arf.day
- dips_month = arf.month
- ticket_del = []
- for i in self.tickets:
- ter = self.tickets[i]
- if ter['disp_day'] == disp_day:
- p1_save = open('tickets.txt', 'a')
- ticket = ""
- ticket+=str("\n")
- ticket+=str(self.tickets[i]['link'])
- ticket+=" "
- ticket+=str(self.tickets[i]['notes'])
- ticket_del.append(i)
- p1_save.write(ticket)
- p1_save.close()
- for i in ticket_del:
- del self.tickets[i]
- def dump_all(self):
- for i in self.tickets:
- print(i)
- ticket = ""
- ticket+=str("\n")
- ticket+=str(self.tickets[i]['link'])
- ticket+=" "
- ticket+=str(self.tickets[i]['notes'])
- print(ticket)
- p1_save = open('dump.txt', 'a')
- p1_save.write(ticket)
- p1_save.close()
- db = Database()
- def menu():
- print("Arr, this be Summercat's timer tool")
- print("Arr, and this be the menu.")
- running = 1
- while running:
- print("[A]dd a ticket, or [D]isplay tickets into tickets.txt.\n Or [C]ancel.")
- choice = input("A, B, or C? ")
- if choice.isnumeric():
- print("Avast, type in a proper answer!")
- else:
- choice = choice.lower()
- if choice == 'a':
- db.add_ticket()
- elif choice == 'b':
- db.display_ticket()
- elif choice == 'c':
- running = 0
- elif choice == 'd':
- db.dump_all()
- elif choice == 'p':
- for i in db.tickets:
- print(db.tickets[i])
- try:
- data = open('database.otter', 'r+b')
- db = pickle.load(data)
- data.close()
- except:
- print("Database not found.")
- menu()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement