码迷,mamicode.com
首页 > 其他好文 > 详细

简单小练习_阅读稍后提醒

时间:2018-06-25 14:55:55      阅读:155      评论:0      收藏:0      [点我收藏+]

标签:==   time()   elf   nbsp   div   targe   str   target   dma   

#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(\n)
                    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()

 

简单小练习_阅读稍后提醒

标签:==   time()   elf   nbsp   div   targe   str   target   dma   

原文地址:https://www.cnblogs.com/Erick-L/p/9223936.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!