Completed
Push — develop ( bc7642...53919e )
by Jace
12s
created

gitman.models.group   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 28
dl 0
loc 43
rs 10
c 0
b 0
f 0
wmc 8

6 Methods

Rating   Name   Duplication   Size   Complexity  
A Group.__init__() 0 10 3
A Group.__repr__() 0 2 1
A Group.__lt__() 0 2 1
A Group.__ne__() 0 2 1
A Group.__eq__() 0 2 1
A Group.__str__() 0 3 1
1
import logging
2
3
import yorm
0 ignored issues
show
introduced by
Unable to import 'yorm'
Loading history...
4
from yorm.types import AttributeDictionary, List, String
0 ignored issues
show
introduced by
Unable to import 'yorm.types'
Loading history...
5
6
from .. import exceptions
7
8
9
log = logging.getLogger(__name__)
10
11
12
@yorm.attr(name=String)
13
@yorm.attr(members=List.of_type(String))
14
class Group(AttributeDictionary):
15
    """A group with sources."""
16
17
    def __init__(self, name, members):
18
19
        super().__init__()
20
        self.name = name
21
        self.members = members or []
22
23
        for key in ['name', 'members']:
24
            if not self[key]:
25
                msg = "'{}' required for {}".format(key, repr(self))
26
                raise exceptions.InvalidConfig(msg)
27
28
    def __repr__(self):
29
        return "<group {}>".format(self)
30
31
    def __str__(self):
32
        pattern = "['{n}']"
33
        return pattern.format(n=self.name)
34
35
    def __eq__(self, other):
36
        return self.name == other.name
37
38
    def __ne__(self, other):
39
        return self.name != other.name
40
41
    def __lt__(self, other):
42
        return self.name < other.name
43