-
Notifications
You must be signed in to change notification settings - Fork 5
/
dependency.py
45 lines (32 loc) · 1.06 KB
/
dependency.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
from enum import Enum
from app.data_object import *
class DependencyKind(Enum):
RUNTIME = 1
DEVELOPMENT = 2
def __str__(self):
if self == DependencyKind.RUNTIME:
return 'runtime'
elif self == DependencyKind.DEVELOPMENT:
return 'development'
class Dependency(DataObject):
def __init__(self, name, kind, number=None):
self.name = name
self.kind = kind
self.number = number
@staticmethod
def runtime(name, number=None):
return Dependency(name, DependencyKind.RUNTIME, number)
@staticmethod
def development(name, number=None):
return Dependency(name, DependencyKind.DEVELOPMENT, number)
@property
def is_runtime(self):
return self.kind == DependencyKind.RUNTIME
@property
def is_development(self):
return self.kind == DependencyKind.DEVELOPMENT
def __str__(self):
number = 'latest' if self.number is None else self.number
return f'[{self.kind}] {self.name}:{number}'
def __repr__(self):
return str(self)