GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Passed
Pull Request — master (#44)
by
unknown
01:14
created

qtsass.watchers.watchdog   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 69
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 9
eloc 32
dl 0
loc 69
rs 10
c 0
b 0
f 0

8 Methods

Rating   Name   Duplication   Size   Complexity  
A SourceChangedEventHandler.on_modified() 0 5 2
A WatchdogWatcher.join() 0 2 1
A WatchdogWatcher.connect() 0 2 1
A WatchdogWatcher.disconnect() 0 2 1
A WatchdogWatcher.start() 0 2 1
A SourceChangedEventHandler.__init__() 0 5 1
A WatchdogWatcher.stop() 0 2 1
A WatchdogWatcher.setup() 0 8 1
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
"""Contains the Qt implementation of the Watcher api."""
10
11
# yapf: disable
12
13
from __future__ import absolute_import
14
15
# Third party imports
16
from watchdog.events import FileSystemEventHandler
17
from watchdog.observers import Observer
18
19
# Local imports
20
from qtsass.watchers.api import Watcher
21
22
# yapf: enable
23
24
25
class SourceChangedEventHandler(FileSystemEventHandler):
26
    """Source event hanlder."""
27
28
    def __init__(self, compile, callbacks):
29
        """Source event hanlder."""
30
        super(SourceChangedEventHandler, self).__init__()
31
        self._compile = compile
32
        self._callbacks = callbacks
33
34
    def on_modified(self, event):
35
        """Override watchdog method to handle on file modification events."""
36
        css = self._compile()
37
        for callback in self._callbacks:
38
            callback(css)
39
40
41
class WatchdogWatcher(Watcher):
42
    """Watches a file or directory for changes and calls the provided compiler
43
    whenever a change is detected.
44
    """
45
46
    def setup(self):
47
        self._callbacks = set()
48
        self._handler = SourceChangedEventHandler(
49
            self.compile,
50
            self._callbacks
51
        )
52
        self._observer = Observer()
53
        self._observer.schedule(self._handler, self._watch_dir, recursive=True)
54
55
    def connect(self, fn):
56
        self._callbacks.add(fn)
57
58
    def disconnect(self, fn):
59
        self._callbacks.discard(fn)
60
61
    def start(self):
62
        self._observer.start()
63
64
    def stop(self):
65
        self._observer.stop()
66
67
    def join(self):
68
        self._observer.join()
69