-
Notifications
You must be signed in to change notification settings - Fork 5
/
package_version.py
37 lines (27 loc) · 1.06 KB
/
package_version.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
from app.data_object import *
class PackageVersion(DataObject):
def __init__(self, name, number, licenses,
runtime_dependencies, development_dependencies):
self.name = name
self.number = number
self.runtime_dependencies = runtime_dependencies
self.development_dependencies = development_dependencies
self.licenses = licenses
@property
def id(self):
return f'{str(self.name)}:{self.formatted_number}'
@property
def formatted_number(self):
return str(self.number) if self.number else 'latest'
@property
def formatted_licenses(self):
return '|'.join(self.licenses) if self.licenses else '<no licenses found>'
def __str__(self):
return self.id
def __repr__(self):
return f'{str(self)} → {self.formatted_licenses}'
class PackageVersionNotFound(PackageVersion):
def __init__(self, name, number=None):
super().__init__(name, number, [], [], [])
def __repr__(self):
return f'{str(self)} → <version not found on registry>'