/[partial-mirror]/branches/rewrite/src/Config.py
ViewVC logotype

Contents of /branches/rewrite/src/Config.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2 - (hide annotations) (download) (as text)
Sat Mar 27 18:11:13 2004 UTC (9 years, 1 month ago) by otavio
Original Path: debian/debpartial-mirror/trunk/src/Config.py
File MIME type: text/x-python
File size: 2986 byte(s)
First debian package in svn.
1 otavio 2 import ConfigParser
2    
3     # Process the configuration options
4     class Config:
5     # Initialize these vars
6     __mirror = {}
7     __dists = {}
8     __suggests = ""
9     __recomends = ""
10    
11     def __init__(self, filename):
12     cnf = ConfigParser.ConfigParser()
13     cnf.read(filename)
14     for section in cnf.sections():
15     for option in cnf.options(section):
16     if section == "mirror":
17     if option == "archs" or option == "files":
18     self.__mirror[option] = cnf.get(section, option).split(" ")
19     else:
20     self.__mirror[option] = cnf.get(section, option)
21     else:
22     if not self.__dists.has_key(section):
23     self.__dists[section] = {}
24    
25     if option == "filter" or option == "packages":
26     filters = cnf.get(section, option).split(" ")
27    
28     for rule in filters:
29     rule = rule.split(":")
30    
31     if not self.__dists[section].has_key(rule[0]):
32     self.__dists[section][rule[0]] = []
33    
34     if option == "filter":
35     self.__dists[section][rule[0]].append({"section": rule[1], "priority": rule[2], "package": "*"})
36     else:
37     self.__dists[section][rule[0]].append({"section": "*", "priority": "*", "package": rule[1]})
38    
39     def getValue(self, section, option):
40     if self.__options.has_key(section):
41     if self.__option[section].has_key(option):
42     return self.__option[section][option]
43     return ""
44    
45     def getMirror(self):
46     return self.__mirror
47    
48     def __getMirrorOption(self, option):
49     if self.__mirror.has_key(option):
50     return self.__mirror[option]
51     return ""
52    
53     def getServer(self):
54     return self.__getMirrorOption("server");
55    
56     def getArchs(self):
57     return self.__getMirrorOption("archs");
58    
59     def getFiles(self):
60     return self.__getMirrorOption("files");
61    
62     def getLocalDirectory(self):
63     return self.__getMirrorOption("local_directory");
64    
65     def getDists(self):
66     return self.__dists
67    
68     def getSuggests(self):
69     if self.__getMirrorOption('get_suggests') == 'true':
70     return True
71     else:
72     return False
73    
74     def getRecomends(self):
75     if self.__getMirrorOption('get_recomends') == 'true':
76     return True
77     else:
78     return False
79    
80     def getSections(self, dist_name):
81     if self.__dists.has_key(dist_name):
82     return self.__dists[dist_name]
83     return ""
84    
85     def getFilters(self, dist_name, section_name):
86     if self.__dists.has_key(dist_name):
87     if self.__dists[dist_name].has_key(section_name):
88     return self.__dists[dist_name][section_name]
89     return ""

  ViewVC Help
Powered by ViewVC 1.1.5