2
# DistInfo.py - simple parser for a xml-based metainfo file
4
# Copyright (c) 2005 Gustavo Noronha Silva
6
# Author: Gustavo Noronha Silva <kov@debian.org>
8
# This program is free software; you can redistribute it and/or
9
# modify it under the terms of the GNU General Public License as
10
# published by the Free Software Foundation; either version 2 of the
11
# License, or (at your option) any later version.
13
# This program is distributed in the hope that it will be useful,
14
# but WITHOUT ANY WARRANTY; without even the implied warranty of
15
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
# GNU General Public License for more details.
18
# You should have received a copy of the GNU General Public License
19
# along with this program; if not, write to the Free Software
20
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
33
repository_type = None
42
def __init__(self, dist = None,
43
base_dir = "/usr/share/update-manager/dists"):
44
self.metarelease_uri = ''
48
pipe = os.popen("lsb_release -i | cut -d : -f 2-")
49
dist = pipe.read().strip()
53
dist_fname = "%s/%s.info" % (base_dir, dist)
54
dist_file = open (dist_fname)
59
for line in dist_file:
60
tokens = line.split (':', 1)
63
field = tokens[0].strip ()
64
value = tokens[1].strip ()
65
if field == 'ChangelogURI':
66
self.changelogs_uri = _(value)
67
elif field == 'MetaReleaseURI':
68
self.metarelease_uri = value
69
elif field == 'Suite':
72
suite.components.append (component)
74
self.suites.append (suite)
78
elif field == 'RepositoryType':
79
suite.repository_type = value
80
elif field == 'BaseURI':
81
suite.base_uri = value
82
elif field == 'Description':
83
suite.description = _(value)
84
elif field == 'Component':
86
suite.components.append (component)
87
component = Component ()
88
component.name = value
89
elif field == 'Enabled':
90
component.enabled = bool(int(value))
91
elif field == 'CompDescription':
92
component.description = _(value)
95
suite.components.append (component)
97
self.suites.append (suite)
101
if __name__ == "__main__":
102
d = DistInfo ("Debian", "../distribution-data")
103
print d.changelogs_uri
104
for suite in d.suites:
106
print suite.description
108
for component in suite.components:
110
print component.description
111
print component.enabled