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

gitman.models.group.Group.__repr__()   A

Complexity

Conditions 1

Size

Total Lines 2
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nop 1
dl 0
loc 2
rs 10
c 0
b 0
f 0
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