Move folder_watcher imports at top-level (#29095)
parent
7a04f0c0df
commit
4107fd9a25
|
@ -3,6 +3,8 @@ import logging
|
|||
import os
|
||||
|
||||
import voluptuous as vol
|
||||
from watchdog.events import PatternMatchingEventHandler
|
||||
from watchdog.observers import Observer
|
||||
|
||||
from homeassistant.const import EVENT_HOMEASSISTANT_START, EVENT_HOMEASSISTANT_STOP
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
|
@ -50,7 +52,6 @@ def setup(hass, config):
|
|||
|
||||
def create_event_handler(patterns, hass):
|
||||
"""Return the Watchdog EventHandler object."""
|
||||
from watchdog.events import PatternMatchingEventHandler
|
||||
|
||||
class EventHandler(PatternMatchingEventHandler):
|
||||
"""Class for handling Watcher events."""
|
||||
|
@ -99,8 +100,6 @@ class Watcher:
|
|||
|
||||
def __init__(self, path, patterns, hass):
|
||||
"""Initialise the watchdog observer."""
|
||||
from watchdog.observers import Observer
|
||||
|
||||
self._observer = Observer()
|
||||
self._observer.schedule(
|
||||
create_event_handler(patterns, hass), path, recursive=True
|
||||
|
|
Loading…
Reference in New Issue