File: interfaces.py

package info (click to toggle)
python-hupper 1.5-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 536 kB
  • sloc: python: 2,200; makefile: 149
file content (46 lines) | stat: -rw-r--r-- 1,201 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import abc

from .compat import with_metaclass


class IReloaderProxy(with_metaclass(abc.ABCMeta)):
    @abc.abstractmethod
    def watch_files(self, files):
        """ Signal to the monitor to track some custom paths."""

    @abc.abstractmethod
    def trigger_reload(self):
        """ Signal the monitor to execute a reload."""


class IFileMonitorFactory(with_metaclass(abc.ABCMeta)):
    def __call__(self, callback):
        """ Return an :class:`.IFileMonitor` instance.

        ``callback`` is a callable to be invoked by the ``IFileMonitor``
        when file changes are detected. It should accept the path of
        the changed file as its only parameter.

        """


class IFileMonitor(with_metaclass(abc.ABCMeta)):
    @abc.abstractmethod
    def add_path(self, path):
        """ Start monitoring a new path."""

    @abc.abstractmethod
    def start(self):
        """ Start the monitor. This method should not block."""

    @abc.abstractmethod
    def stop(self):
        """ Trigger the monitor to stop.

        This should be called before invoking :meth:`.join`.

        """

    @abc.abstractmethod
    def join(self):
        """ Block until the monitor has stopped."""