File: DistUpgradeConfigParser.py

package info (click to toggle)
update-manager 0.42.2ubuntu22-11
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 4,908 kB
  • ctags: 753
  • sloc: python: 3,738; sh: 2,971; xml: 1,571; makefile: 690; ansic: 38
file content (28 lines) | stat: -rw-r--r-- 904 bytes parent folder | download
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
from ConfigParser import ConfigParser, NoOptionError


class DistUpgradeConfig(ConfigParser):
    def __init__(self):
        ConfigParser.__init__(self)
        self.read(['DistUpgrade.cfg'])
    def getlist(self, section, option):
        try:
            tmp = self.get(section, option)
        except NoOptionError:
            return []
        items = [x.strip() for x in tmp.split(",")]
        return items
    def getListFromFile(self, section, option):
        try:
            filename = self.get(section, option)
        except NoOptionError:
            return []
        items = [x.strip() for x in open(filename)]
        return filter(lambda s: not s.startswith("#") and not s == "", items)


if __name__ == "__main__":
    c = DistUpgradeConfig()
    print c.getlist("Distro","MetaPkgs")
    print c.getlist("Distro","ForcedPurges")
    print c.getListFromFile("Sources","ValidMirrors")