#ReadManger(c) -> (tool & context) from time import ctime import os import threading import webbrowser class ReadManager(object): def __init__(self, config): self.read_time= config['time'] self.folder_path = config['folder_path'] self.urls = self.urls_parse(self.folder_path) def urls_parse(self,path): urls = [] for f in os.listdir(path): if not f.startswith('.'): full_path = path + f with open(full_path,'r') as raw_url: url = raw_url.read().split('URL=')[-1].strip(' ') urls.append(url) return urls def time_to_read(self): return self.read_time == ctime().split()[-2] def sent_to_browser(self): for url in self.urls: webbrowser.open_new_tab(url) def run(self): def _run(): while True: if self.time_to_read: self.sent_to_browser() t = threading.Thread(target=_run) t.daemon =True t.start() managers = [ReadManager(c) for c in CONFIGS] # for m in managers: # m.run()