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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
# -*- coding: utf-8 -*-
# Copyright John N. Laliberte <allanonjl@gentoo.org>
# LICENSE - GPL2
# the package module
import sys
sys.path = ["modules"]+sys.path
import portage_module
class Package:
# special cases
special_cases = { "GConf":"gconf",
"ORBit2":"orbit",
"libidl":"libIDL",
"libxml++":"libxmlpp",
"gnome2-vfs":"gnome-vfs",
"gtk2":"gtk2-perl",
"gnome2-vfs":"gnome2-vfs-perl",
"pkg-config":"pkgconfig",
"glade3":"dev-util/glade",
}
def __init__(self, raw_data):
self.raw_string = raw_data
self.name = None
self.version = None
self.revision = None
self.major_minor = None
self.raw_name = None
self.category = None
self.parse_raw_string(raw_data)
self.handle_special_cases()
@property
def name_plus_version(self):
return self.name + "-" + self.version
@property
def name_plus_version_plus_revision(self):
return self.name_plus_version + "-" + self.revision
def handle_special_cases(self):
if self.name in self.special_cases:
self.name = self.special_cases[self.name]
def parse_raw_string(self, raw_string):
split_string = portage_module.split_package_into_parts(raw_string)
if None != split_string:
#[cat, pkgname, version, rev ]
self.category,self.name,self.version,self.revision = split_string
self.raw_name = self.name
self.major_minor = self.parse_mm(self.version)
# else:
# print "Error, " + raw_string + " is not a valid package!"
def parse_mm(self, version):
return '.'.join(version.split('.')[0:2])
def print_info(self):
print "Name: " + str(self.name)
print "Version: " + str(self.package_version)
print "Name+Version: " + str(self.name_plus_version)
print "Raw: " + str(self.raw_string)
def __repr__(self):
return self.name_plus_version
class PackageStatus:
def __init__(self, name, stable_version, portage_version, gnome_version, latest_version, status):
self.name = name
self.stable_version = stable_version
self.portage_version = portage_version
self.gnome_version = gnome_version
self.latest_version = latest_version
self.status = status
class Status:
def Compliant(self):
return 0
def NeedUpdate(self):
return 1
def NotFound(self):
return -1
def NewerVersion(self):
return 2
def StableNeedUpdate(self):
return 3
property(Compliant)
property(NeedUpdate)
property(NotFound)
property(NewerVersion)
property(StableNeedUpdate)
|