Fix file observer

This commit is contained in:
R. Richard
2019-06-27 16:15:22 +02:00
committed by Kristóf Tóth
parent 6cc3d32097
commit da19769362
2 changed files with 6 additions and 15 deletions

View File

@ -2,7 +2,7 @@
from typing import Iterable
from time import time
from os.path import abspath, dirname, isfile
from os.path import abspath, dirname, isdir
from watchdog.observers import Observer
from watchdog.events import FileSystemMovedEvent, PatternMatchingEventHandler
@ -66,10 +66,10 @@ class InotifyDirDeletedEvent(InotifyEvent):
class InotifyObserver:
def __init__(self, path, patterns=[], exclude=None, recursive=False):
def __init__(self, path, patterns=None, exclude=None, recursive=False):
self._files = []
self._paths = path
self._patterns = patterns
self._patterns = patterns or []
self._exclude = exclude
self._recursive = recursive
self._observer = Observer()
@ -97,12 +97,12 @@ class InotifyObserver:
def _extract_files_from_paths(self):
files, paths = [], []
for path in self._paths:
if isfile(path):
if isdir(path):
paths.append(path)
else:
new_file = abspath(path)
files.append(new_file)
paths.append(dirname(new_file))
else:
paths.append(path)
self._files, self._paths = files, paths
@property