Total Complexity | 8 |
Total Lines | 59 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | # -*- coding: utf-8 -*- |
||
2 | # ----------------------------------------------------------------------------- |
||
3 | # Copyright (c) 2015 Yann Lanthony |
||
4 | # Copyright (c) 2017-2018 Spyder Project Contributors |
||
5 | # |
||
6 | # Licensed under the terms of the MIT License |
||
7 | # (See LICENSE.txt for details) |
||
8 | # ----------------------------------------------------------------------------- |
||
9 | """qtsass.watchers.api - FS Watcher api.""" |
||
10 | |||
11 | # yapf: disable |
||
12 | |||
13 | from __future__ import absolute_import |
||
14 | |||
15 | # yapf: enable |
||
16 | |||
17 | |||
18 | class Watcher(object): |
||
19 | """Watches a file or directory for changes and calls the provided compiler |
||
20 | whenever a change is detected. |
||
21 | """ |
||
22 | |||
23 | def __init__(self, watch_dir, source, destination, compiler): |
||
24 | self._watch_dir = watch_dir |
||
25 | self._source = source |
||
26 | self._destination = destination |
||
27 | self._compiler = compiler |
||
28 | self.setup() |
||
29 | |||
30 | def compile(self): |
||
31 | print('Watcher.compile - %s > %s' % (self._source, self._destination)) |
||
32 | return self._compiler(self._source, self._destination) |
||
33 | |||
34 | def setup(self): |
||
35 | """Perform any setup required by this Watcher.""" |
||
36 | return NotImplemented |
||
37 | |||
38 | def connect(self, fn): |
||
39 | """Connect a handler to be called when this Watcher detects a |
||
40 | file or directory change. Called after setup to connect compile to |
||
41 | as a handler.""" |
||
42 | return NotImplemented |
||
43 | |||
44 | def disconnect(self, fn): |
||
45 | """Disconnect a handler from this Watcher.""" |
||
46 | return NotImplemented |
||
47 | |||
48 | def start(self): |
||
49 | """Start this Watcher.""" |
||
50 | return NotImplemented |
||
51 | |||
52 | def stop(self): |
||
53 | """Stop this Watcher.""" |
||
54 | return NotImplemented |
||
55 | |||
56 | def join(self): |
||
57 | """Wait for this Watcher to finish.""" |
||
58 | return NotImplemented |
||
59 |