~roadmr/ubuntu/precise/checkbox/0.13.1

« back to all changes in this revision

Viewing changes to checkbox/lib/config.py

  • Committer: Bazaar Package Importer
  • Author(s): Marc Tardif, Gabor Keleman
  • Date: 2009-08-19 15:36:05 UTC
  • Revision ID: james.westby@ubuntu.com-20090819153605-weo6htup3yi6zn0t
Tags: 0.8~alpha4
* New upstream version:
  * Changed icon.
  * Added timeout property to lock_prompt plugin.
  * Added concept of attachments to tests.
  * Added support for backslahes in templates to wrap lines.
  * Added support blacklisting and whitelisting both tests and suites.
  * Introduced the concept of jobs for suites, tests and attachments.
  * Removed upstart event which is no longer needed.
  * Replaced architecture and category with requires in test definitions.
* Fixed pygst dependency (LP: #334442)
* Fixed configuration file updates during install (LP: #330596)
* Fixed and expanded translations (LP: #347038)
* Fixed ignored system proxy settings (LP: #345548)
* Fixed parsing blank lines in templates (LP: #393907)
* Fixed escaping of lists (LP: #394001)
* Fixed timeout in manual tests (LP: #377986)
* Fixed CLI interface dialog.
* Fixed support for FreeDesktop XDG base directory specification (LP: #363549)
* Added general and package specific apport hooks

[ Gabor Keleman ]
* Fixed untranslated strings in tests (LP: #374666)
* Fixed untranslated last screen (LP: #374646)

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
 
24
24
from ConfigParser import ConfigParser
25
25
 
 
26
from checkbox.lib.text import split
 
27
 
26
28
 
27
29
class IncludeDict(dict):
28
30
 
35
37
 
36
38
    def __setitem__(self, key, value):
37
39
        if key == "includes":
38
 
            for path in re.split(r"\s*,?\s+", value):
 
40
            for path in split(value):
39
41
                path = self._parser._interpolate("DEFAULT", None, path, self)
40
42
                path = posixpath.expanduser(path)
41
43
                if not posixpath.exists(path):
99
101
 
100
102
class Config(object):
101
103
 
102
 
    def __init__(self, path, configs=[]):
103
 
        self.path = path
104
 
 
 
104
    def __init__(self):
105
105
        self._parser = ConfigParser()
106
106
        self._parser._defaults = IncludeDict(self._parser)
107
107
 
108
 
        if not posixpath.exists(path):
109
 
            raise Exception, "No such configuration file: %s" % path
110
 
        self._parser.read(path)
 
108
        # Copy attributes from the parser to avoid one additional
 
109
        # function call on each access.
 
110
        for attr in ["has_section", "remove_section"]:
 
111
            setattr(self, attr, getattr(self._parser, attr))
111
112
 
 
113
    def read_configs(self, configs):
112
114
        for config in configs:
113
115
            match = re.match("(.*)/([^/]+)=(.*)", config)
114
116
            if not match:
120
122
 
121
123
            self._parser.set(name, option, value)
122
124
 
123
 
        # Copy attributes from the parser to avoid one additional
124
 
        # function call on each access.
125
 
        for attr in ["has_section", "remove_section"]:
126
 
            setattr(self, attr, getattr(self._parser, attr))
 
125
    def read_file(self, file, filename="<stream>"):
 
126
        logging.info("Reading configurations from: %s", filename)
 
127
 
 
128
        self._parser.readfp(file, filename)
 
129
 
 
130
    def read_filename(self, filename):
 
131
        if not posixpath.exists(filename):
 
132
            raise Exception, "No such configuration file: %s" % filename
 
133
 
 
134
        file = open(filename, "r")
 
135
        return self.read_file(file, filename)
127
136
 
128
137
    def get_defaults(self):
129
138
        attributes = self._parser.defaults()