~canonical-platform-qa/uci-config/py3-items

« back to all changes in this revision

Viewing changes to uciconfig/stacks.py

  • Committer: Vincent Ladeuil
  • Date: 2014-04-01 07:42:21 UTC
  • mfrom: (52.1.10 command)
  • Revision ID: vila+ci@canonical.com-20140401074221-3jzzacnotx7j2yoe
Add support for cmdline UIs.

Show diffs side-by-side

added added

removed removed

Lines of Context:
146
146
 
147
147
 
148
148
def iter_option_refs(string):
149
 
    # Split isolate refs so every other chunk is a ref
 
149
    # Split isolated refs so every other chunk is a ref
150
150
    is_ref = False
151
151
    for chunk in _option_ref_re.split(string):
152
152
        yield is_ref, chunk
188
188
            for store, section in sections():
189
189
                yield store, section
190
190
 
 
191
    def iter_options(self):
 
192
        for store, section in self.iter_sections():
 
193
            for oname in section.iter_option_names():
 
194
                # Only defined options are seen here so they all have a value
 
195
                value = section.get(oname, expand=False)
 
196
                # The value does not require quoting (for now)
 
197
                yield store, section, oname, value
 
198
 
191
199
    def get(self, name, expand=True, convert=True):
192
200
        """Return the *first* option value found in the sections.
193
201
 
332
340
    def remove(self, name):
333
341
        """Remove an existing option."""
334
342
        _, section = self._get_mutable_section()
335
 
        section.remove(name)
 
343
        try:
 
344
            section.remove(name)
 
345
        except KeyError:
 
346
            raise errors.NoSuchConfigOption(name)
336
347
 
337
348
    def __repr__(self):
338
349
        # Mostly for debugging use