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
98
99
100
101
102
|
# 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",
"gnome-control-center":"control-center"
}
def __init__(self, raw_data):
self.raw_string = raw_data
self.name = None
self.version = None
self.revision = None
self.name_plus_version = None
self.name_plus_version_plus_revision = None
self.major_minor = None
self.raw_name = None
self.category = None
self.parse_raw_string(raw_data)
self.handle_special_cases()
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.name_plus_version = self.name + "-" + self.version
self.name_plus_version_plus_revision = self.name + "-" + self.version + "-" + \
self.revision
self.major_minor = self.parse_mm(self.version)
else:
print "Error, " + raw_string + " is not a valid package!"
def parse_mm(self, version):
majorminor = ""
firstdot = version.find(".")
if 0 < firstdot:
major = version[:firstdot]
majorminor += major
version = version[firstdot+1:]
seconddot = version.find(".")
if 0 < seconddot:
minor = version[:seconddot]
majorminor = majorminor + "." + minor
elif 0 > seconddot:
# This means there is no second dot, something like, gtk-doc-1.4
majorminor = majorminor + "." + version
return majorminor
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)
class PackageStatus:
def __init__(self, name, portage_version, gnome_version, latest_version, status):
self.name = name
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
property(Compliant)
property(NeedUpdate)
property(NotFound)
property(NewerVersion)
|