Completed
Push — develop ( 9ba97b...51e53a )
by Jace
14s queued 11s
created

gitman.models.group   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 24
dl 0
loc 36
rs 10
c 0
b 0
f 0
wmc 8

6 Methods

Rating   Name   Duplication   Size   Complexity  
A Group.__repr__() 0 2 1
A Group.__lt__() 0 2 1
A Group.__ne__() 0 2 1
A Group.__post_init__() 0 6 3
A Group.__eq__() 0 2 1
A Group.__str__() 0 3 1
1
from dataclasses import dataclass
2
from typing import List
3
4
from .. import exceptions
5
6
7
@dataclass
8
class Group:
9
    """A group with sources."""
10
11
    name: str
12
    members: List[str]
13
14
    def __post_init__(self):
15
        # TODO: Remove this?
16
        for name in ['name', 'members']:
17
            if not getattr(self, name):
18
                msg = "'{}' required for {}".format(name, repr(self))
19
                raise exceptions.InvalidConfig(msg)
20
21
    def __repr__(self):
22
        return "<group {}>".format(self)
23
24
    def __str__(self):
25
        pattern = "['{n}']"
26
        return pattern.format(n=self.name)
27
28
    def __eq__(self, other):
29
        return self.name == other.name
30
31
    def __ne__(self, other):
32
        return self.name != other.name
33
34
    def __lt__(self, other):
35
        return self.name < other.name
36