Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move folder_watcher imports at top-level #29095

Merged
merged 1 commit into from
Nov 26, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 2 additions & 3 deletions homeassistant/components/folder_watcher/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
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
Expand Down Expand Up @@ -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."""
Expand Down Expand Up @@ -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
Expand Down