Make Historymonitor.history a list instead of a deque (for slicing)

This commit is contained in:
Kristóf Tóth 2018-03-03 22:44:05 +01:00
parent eea6a418a8
commit 5133806d33

View File

@ -1,6 +1,5 @@
from watchdog.observers import Observer from watchdog.observers import Observer
from watchdog.events import FileSystemEventHandler from watchdog.events import FileSystemEventHandler
from collections import deque
from os.path import dirname from os.path import dirname
@ -17,7 +16,7 @@ class CallbackEventHandler(FileSystemEventHandler):
class HistoryMonitor: class HistoryMonitor:
def __init__(self, histfile): def __init__(self, histfile):
self.histfile = histfile self.histfile = histfile
self._history = deque() self._history = []
self.observer = Observer() self.observer = Observer()
self.observer.schedule(CallbackEventHandler(self._fetch_history), dirname(self.histfile)) self.observer.schedule(CallbackEventHandler(self._fetch_history), dirname(self.histfile))
@ -27,7 +26,7 @@ class HistoryMonitor:
def _fetch_history(self): def _fetch_history(self):
with open(self.histfile, 'r') as ifile: with open(self.histfile, 'r') as ifile:
self._history = deque(ifile.readlines()) self._history = ifile.readlines()
def watch(self): def watch(self):
self.observer.start() self.observer.start()