mirror of
https://github.com/home-assistant/core.git
synced 2025-07-25 14:17:45 +00:00
Move folder_watcher imports at top-level (#29095)
This commit is contained in:
parent
7a04f0c0df
commit
4107fd9a25
@ -3,6 +3,8 @@ import logging
|
|||||||
import os
|
import os
|
||||||
|
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
from watchdog.events import PatternMatchingEventHandler
|
||||||
|
from watchdog.observers import Observer
|
||||||
|
|
||||||
from homeassistant.const import EVENT_HOMEASSISTANT_START, EVENT_HOMEASSISTANT_STOP
|
from homeassistant.const import EVENT_HOMEASSISTANT_START, EVENT_HOMEASSISTANT_STOP
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
@ -50,7 +52,6 @@ def setup(hass, config):
|
|||||||
|
|
||||||
def create_event_handler(patterns, hass):
|
def create_event_handler(patterns, hass):
|
||||||
"""Return the Watchdog EventHandler object."""
|
"""Return the Watchdog EventHandler object."""
|
||||||
from watchdog.events import PatternMatchingEventHandler
|
|
||||||
|
|
||||||
class EventHandler(PatternMatchingEventHandler):
|
class EventHandler(PatternMatchingEventHandler):
|
||||||
"""Class for handling Watcher events."""
|
"""Class for handling Watcher events."""
|
||||||
@ -99,8 +100,6 @@ class Watcher:
|
|||||||
|
|
||||||
def __init__(self, path, patterns, hass):
|
def __init__(self, path, patterns, hass):
|
||||||
"""Initialise the watchdog observer."""
|
"""Initialise the watchdog observer."""
|
||||||
from watchdog.observers import Observer
|
|
||||||
|
|
||||||
self._observer = Observer()
|
self._observer = Observer()
|
||||||
self._observer.schedule(
|
self._observer.schedule(
|
||||||
create_event_handler(patterns, hass), path, recursive=True
|
create_event_handler(patterns, hass), path, recursive=True
|
||||||
|
Loading…
x
Reference in New Issue
Block a user