Skip to content

Commit

Permalink
black reformat
Browse files Browse the repository at this point in the history
  • Loading branch information
dat-adi committed Oct 22, 2020
1 parent efe99f0 commit ea14bae
Show file tree
Hide file tree
Showing 9 changed files with 79 additions and 40 deletions.
20 changes: 12 additions & 8 deletions src/converting_timestamps.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,26 @@
import os
import json


def parse_timestamps(time_stamp_test):
time_stamps = [i for i in time_stamp_test]
return time_stamps


def time_stamp_return(day):
schedule = []
if os.path.isfile('schedule.txt'):
with open('schedule.txt', 'r') as f:
tempApps = f.read()
converted = json.loads(tempApps)
parse_timestamps(converted[day].keys())
return parse_timestamps(converted[day].keys())
if os.path.isfile("schedule.txt"):
with open("schedule.txt", "r") as f:
tempApps = f.read()
converted = json.loads(tempApps)
parse_timestamps(converted[day].keys())
return parse_timestamps(converted[day].keys())


def main():
day = input("Which day do you want to know about? : ")
print(time_stamp_return(day))

if __name__ == '__main__':
main()

if __name__ == "__main__":
main()
1 change: 1 addition & 0 deletions src/deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from pynput.keyboard import Key, Controller
import pickle


def deploy_links(team_links):
keyboard = Controller()
for team_link in team_links:
Expand Down
2 changes: 1 addition & 1 deletion src/schedule.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
]
}
}
}
}
16 changes: 13 additions & 3 deletions src/schedule_module_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,30 @@
import converting_timestamps as ct
import deploy


def find_day():
week_days = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday']
week_days = [
"monday",
"tuesday",
"wednesday",
"thursday",
"friday",
"saturday",
"sunday",
]
day = week_days[datetime.date.today().weekday()]
return day


def scheduling(timestamp, links):
day = find_day()
schedule.every().day.at(timestamp).do(deploy.deploy_links, links)

while True:
schedule.run_pending()
time.sleep(1)


if __name__ == "__main__":
temp_stamps = ct.time_stamp_return(find_day())
scheduling(temp_stamps, ["https://www.google.com", "https://www.youtube.com"])
scheduling(temp_stamps, ["https://www.google.com", "https://www.youtube.com"])
22 changes: 13 additions & 9 deletions src/test/new_timetablemaker.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
# -*- coding: utf-8 -*-

import json

Expand All @@ -18,39 +18,43 @@ def get_info(self):
print("Add links now. Type 'quit' to stop.")
while True:
temp_link = input("> ")
if temp_link == 'quit':
if temp_link == "quit":
break
else:
self.links.append(temp_link)
self.time_table[self.in_time] = self.links
print(str(self.time_table)) # just prints to console for debugging. Can remove later.
print(
str(self.time_table)
) # just prints to console for debugging. Can remove later.

def day_return(self):
return self.day

def put_info(self):
return self.time_table

def timestamp_return(self):
return self.timestamps


def make():
week_timetable = {}

while True:
input_day_name = input("Enter the day : ").lower()
current_day = day_timetable(input_day_name)
while True:
if input('Enter the upcoming class?(y/n) : ')[0] == 'y':
if input("Enter the upcoming class?(y/n) : ")[0] == "y":
current_day.get_info()
week_timetable[current_day.day_return()] = current_day.put_info()
else:
break
if input("Do you wish to enter entries for another day?(y/n) : ")[0] == 'n':
if input("Do you wish to enter entries for another day?(y/n) : ")[0] == "n":
break

with open('./schedule.txt', 'w') as f:
with open("./schedule.txt", "w") as f:
f.write(json.dumps(week_timetable, indent=4, sort_keys=True))

if __name__ == '__main__':
make()

if __name__ == "__main__":
make()
14 changes: 8 additions & 6 deletions src/test/timer_difference.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,27 @@
import datetime


''' This program is a testing program for the processing
of the time difference between each of the stamps.'''
""" This program is a testing program for the processing
of the time difference between each of the stamps."""


def single_day_timestamp_difference(tesps):
# TimE StamPS for tesps
print(tesps)
# datetime usage to check whether or not timestamp has passed.
# Start from timestamp which is valid and not passed.

with open('schedule.txt', 'r') as f:

with open("schedule.txt", "r") as f:
content = f.read()
content = json.loads(content)
print(content)

''' The two following lines can be removed from this code as it
exists in converting_timestamps.py, but for now, testing '''
""" The two following lines can be removed from this code as it
exists in converting_timestamps.py, but for now, testing """
days = [i for i in content]
print(days)

for day in days:
time_stamps = [i for i in content[day]]
print(time_stamps)
single_day_timestamp_difference(time_stamps)
23 changes: 18 additions & 5 deletions src/timed_link.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,32 +10,45 @@

# function to provide the current day the user is in.
def find_day():
week_days = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday']
week_days = [
"monday",
"tuesday",
"wednesday",
"thursday",
"friday",
"saturday",
"sunday",
]
day = week_days[datetime.date.today().weekday()]
return day


# funtion to parse the file and provide the url for the particular timestamp.
def parse_file_link(course_urls):
temp = course_urls.values()
links = [j for i in temp for j in i]
return links


# supposed to be the main part which reads the file and sends it to different functions.
def execute():
schedule = []

if os.path.isfile('schedule.txt'):
with open('schedule.txt', 'r') as f:
if os.path.isfile("schedule.txt"):
with open("schedule.txt", "r") as f:
tempApps = f.read()
converted = json.loads(tempApps)
days = converted.keys()
schedule.append(converted.values())

timestamps = ct.time_stamp_return(find_day()) # unformatted_timestamps -> 1900, timestamps -> 19:00
timestamps = ct.time_stamp_return(
find_day()
) # unformatted_timestamps -> 1900, timestamps -> 19:00
for timestamp in timestamps:
print(timestamp)
temp_links = parse_file_link(converted[find_day()][timestamp])
smc.scheduling(timestamp, temp_links)


if __name__ == "__main__":
execute()
execute()
2 changes: 1 addition & 1 deletion src/timetable_GUI.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
root = Tk()
root.title("It's the Time Tabler.")

root.mainloop()
root.mainloop()
19 changes: 12 additions & 7 deletions src/timetablemaker.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import json


class day_timetable:
def __init__(self, day):
self.day = day
Expand All @@ -12,19 +13,22 @@ def get_info(self):
print("Add links now. Type 'quit' to stop.")
while True:
temp_link = input("> ")
if temp_link == 'quit':
if temp_link == "quit":
break
else:
self.links.append(temp_link)
self.time_table[self.in_time] = {self.course_code: self.links}
print(str(self.time_table)) # just prints to console for debugging. Can remove later.

print(
str(self.time_table)
) # just prints to console for debugging. Can remove later.

def day_return(self):
return self.day

def put_info(self):
return self.time_table


# available_days = r'^[sun,mon,tues,wednes,thurs,fri]day$' need to verify days later
def make():
week_timetable = {}
Expand All @@ -33,16 +37,17 @@ def make():
input_day_name = input("Enter the day : ").lower()
current_day = day_timetable(input_day_name)
while True:
if input('Enter the upcoming class?(y/n) : ')[0] == 'y':
if input("Enter the upcoming class?(y/n) : ")[0] == "y":
current_day.get_info()
week_timetable[current_day.day_return()] = current_day.put_info()
else:
break
if input("Do you wish to continue?(y/n) : ")[0] == 'n':
if input("Do you wish to continue?(y/n) : ")[0] == "n":
break

with open('../src/schedule.txt', 'w') as f:
with open("../src/schedule.txt", "w") as f:
f.write(json.dumps(week_timetable, indent=4, sort_keys=True))


if __name__ == "__main__":
make()
make()

0 comments on commit ea14bae

Please sign in to comment.