forked from ossillate-inc/packj
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpackage.py
80 lines (60 loc) · 1.57 KB
/
package.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
from __future__ import generators
from abc import ABC, abstractmethod
class Package(ABC):
_data = None
_name = None
_latest_version_str = None
_created = None
_descr = None
_title = None
_releases = None
def __init__(self, metadata):
self._data = metadata
self._versions = {}
self._pkg_url = None
self._homepage = None
def name(self):
return self._name
def descr(self):
return self._descr
def homepage(self):
return self._homepage
def pkg_url(self):
return self._pkg_url
def keywords(self):
return self._keywords
def releases(self):
return self._releases
def title(self):
return self._title
def latest_ver_str(self):
return self._latest_version_str
def dump(self):
return {
'name' : self._name,
'title' : self._title,
'created' : self._created,
'num_vers' : self.num_versions(),
'homepage' : self._homepage,
'pkg_url' : self._pkg_url,
'latest_ver_str': self._latest_version_str,
}
#################################################################
# versions
#################################################################
def version_tags(self):
return list(self._versions.keys())
def num_versions(self):
return len(self._versions)
def versions(self):
return self._versions.values()
def version(self, ver_str):
if version_id in self._versions:
return self._versions[version_id]
raise ValueError('Failed to find version %s' % (version_id))
def latest_version_id(self):
return self._latest_version_str
def created(self):
return self._created