Completed
Pull Request — master (#58)
by Jace
02:38
created

Application   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Test Coverage

Coverage 84.62%

Importance

Changes 3
Bugs 0 Features 0
Metric Value
c 3
b 0
f 0
dl 0
loc 23
ccs 11
cts 13
cp 0.8462
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __init__() 0 7 1
A no_wait() 0 3 1
A auto_queue() 0 3 1
1
"""Data structures for application information."""
2
3 1
import logging
4
5 1
import yorm
0 ignored issues
show
Configuration introduced by
The import yorm could not be resolved.

This can be caused by one of the following:

1. Missing Dependencies

This error could indicate a configuration issue of Pylint. Make sure that your libraries are available by adding the necessary commands.

# .scrutinizer.yml
before_commands:
    - sudo pip install abc # Python2
    - sudo pip3 install abc # Python3
Tip: We are currently not using virtualenv to run pylint, when installing your modules make sure to use the command for the correct version.

2. Missing __init__.py files

This error could also result from missing __init__.py files in your module folders. Make sure that you place one file in each sub-folder.

Loading history...
6
7 1
from .base import NameMixin
8
9
10 1
log = logging.getLogger(__name__)
11
12
13 1
@yorm.attr(mac=yorm.types.NullableString)
0 ignored issues
show
Coding Style introduced by
This class has no __init__ method.
Loading history...
14 1
@yorm.attr(windows=yorm.types.NullableString)
15 1
@yorm.attr(linux=yorm.types.NullableString)
16 1
class Versions(yorm.types.AttributeDictionary):
17
    """Dictionary of OS-specific application filenames."""
18
19
20 1
@yorm.attr(auto_queue=yorm.types.Boolean)
0 ignored issues
show
Coding Style introduced by
This class has no __init__ method.
Loading history...
21 1
@yorm.attr(single_instance=yorm.types.Boolean)
22 1
class Properties(yorm.types.AttributeDictionary):
23
    """Dictionary of application management settings."""
24
25
26 1
@yorm.attr(name=yorm.types.String)
27 1
@yorm.attr(properties=Properties)
28 1
@yorm.attr(versions=Versions)
29 1
class Application(NameMixin, yorm.types.AttributeDictionary):
30
    """Dictionary of application information."""
31
32
    # pylint: disable=E1101
33
34 1
    def __init__(self, name, properties=None, filename=None, versions=None):
35 1
        super().__init__()
36 1
        self.name = name
37 1
        self.properties = properties or Properties()
38 1
        self.versions = versions or Versions(mac=filename,
39
                                             windows=filename,
40
                                             linux=filename)
41
42 1
    @property
43
    def auto_queue(self):
44
        return self.properties.auto_queue
45
46 1
    @property
47
    def no_wait(self):
48
        return not self.properties.single_instance
49
50
51 1
@yorm.attr(all=Application)
0 ignored issues
show
Coding Style introduced by
This class has no __init__ method.
Loading history...
52 1
class Applications(yorm.types.SortedList):
53
    """List of monitored applications."""
54
55 1
    def get(self, name):
56
        """Get the application with the given name."""
57 1
        application = self.find(name)
58 1
        assert application, name
59 1
        return application
60
61 1
    def find(self, name):
62
        """Find the application with the given name, else None."""
63 1
        log.debug("Finding application for '%s'...", name)
64 1
        for application in self:
65 1
            if application == name:
66
                return application
67