def __init__(self, main_path, callback):
super(LibraryFileWatcher, self).__init__()
self.main_path = os.path.normpath(main_path)
self.callback = callback
# Perform a preliminary loading to find all of the connected files...
# TODO: modularity
with open(os.path.abspath(self.main_path), 'r') as FID:
loader = config.Loader(FID)
try:
tmpLib = loader.get_single_data()
self.filenames = [os.path.normpath(lf) for lf in loader.filenames]
finally:
loader.dispose()
self.eventHandler = MyEventHandler(self.filenames, self.callback)
self.observer = Observer()
self.observer.schedule(self.eventHandler, path=os.path.dirname(os.path.abspath(main_path)))
self.observer.start()
self.resume()
评论列表
文章目录