~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/config.py

  • Committer: Aaron Bentley
  • Date: 2006-02-01 18:08:46 UTC
  • mto: (1534.7.121 bzr.ttransform)
  • mto: This revision was merged to the branch mainline in revision 1558.
  • Revision ID: abentley@panoramicfeedback.com-20060201180846-c8f1200d1440c465
Implemented default command options

Show diffs side-by-side

added added

removed removed

Lines of Context:
57
57
import sys
58
58
from fnmatch import fnmatch
59
59
import re
 
60
import shlex
60
61
 
61
62
import bzrlib
62
63
import bzrlib.errors as errors
183
184
            return True
184
185
        return False
185
186
 
 
187
    def get_command_defaults(self, command_name):
 
188
        """Return the default options"""
 
189
        # All these template methods look like overengineering to me.  Is it
 
190
        # clear that we want to support a variety of configuration formats?
 
191
        return self._get_command_defaults(command_name)
 
192
 
 
193
    def _get_command_defaults(self, command_name):
 
194
        return []
 
195
 
186
196
 
187
197
class IniBasedConfig(Config):
188
198
    """A configuration policy that draws from ini files."""
246
256
        raise errors.BzrError("Invalid signatures policy '%s'"
247
257
                              % signature_string)
248
258
 
 
259
    def _get_command_defaults(self, command_name):
 
260
        try:
 
261
            defaults = self._get_parser().get_value("COMMAND_DEFAULTS", 
 
262
                                                    command_name)
 
263
        except KeyError:
 
264
            return []
 
265
        try:
 
266
            return shlex.split(defaults)
 
267
        except ValueError, e:
 
268
            raise errors.CommandDefaultSyntax(command_name=command_name, 
 
269
                                              error=e)
249
270
 
250
271
class GlobalConfig(IniBasedConfig):
251
272
    """The configuration that should be used for a specific location."""