mirror of https://github.com/Askill/optar.git
added doc string to watch(); added requirements.txt
This commit is contained in:
parent
07737f8668
commit
9c968fe66c
|
|
@ -0,0 +1,4 @@
|
||||||
|
from src.Watcher import Watcher
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
Watcher("./sites.txt", "./keywords.txt").watch()
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
deepdiff
|
||||||
|
|
@ -19,7 +19,14 @@ class Watcher:
|
||||||
with open(path) as f:
|
with open(path) as f:
|
||||||
return f.read().splitlines()
|
return f.read().splitlines()
|
||||||
|
|
||||||
def watch(self, sleep):
|
def watch(self, sleep=-1):
|
||||||
|
"""start the watcher with the given interval
|
||||||
|
|
||||||
|
:param arg: seconds between runs, -1 for single run
|
||||||
|
:type arg: int
|
||||||
|
:return: None
|
||||||
|
:rtype: None
|
||||||
|
"""
|
||||||
while True:
|
while True:
|
||||||
keywords = self.read_txt_file(self.keywords_source_path)
|
keywords = self.read_txt_file(self.keywords_source_path)
|
||||||
sites = self.read_txt_file(self.sites_source_path)
|
sites = self.read_txt_file(self.sites_source_path)
|
||||||
|
|
@ -38,6 +45,9 @@ class Watcher:
|
||||||
for url, c in content.items():
|
for url, c in content.items():
|
||||||
matches.append(self.search_sites(url, c, keywords))
|
matches.append(self.search_sites(url, c, keywords))
|
||||||
print(matches)
|
print(matches)
|
||||||
|
|
||||||
|
if sleep == -1:
|
||||||
|
return
|
||||||
time.sleep(sleep)
|
time.sleep(sleep)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue