~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/config.py

  • Committer: John Arbash Meinel
  • Date: 2009-07-29 21:35:05 UTC
  • mfrom: (4576 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4577.
  • Revision ID: john@arbash-meinel.com-20090729213505-tkqsvy1zfpocu75w
Merge bzr.dev 4576 in prep for NEWS

Show diffs side-by-side

added added

removed removed

Lines of Context:
146
146
class Config(object):
147
147
    """A configuration policy - what username, editor, gpg needs etc."""
148
148
 
 
149
    def __init__(self):
 
150
        super(Config, self).__init__()
 
151
 
149
152
    def get_editor(self):
150
153
        """Get the users pop up editor."""
151
154
        raise NotImplementedError
174
177
        """Get a generic option - no special process, no default."""
175
178
        return self._get_user_option(option_name)
176
179
 
 
180
    def get_user_option_as_bool(self, option_name):
 
181
        """Get a generic option as a boolean - no special process, no default.
 
182
 
 
183
        :return None if the option doesn't exist or its value can't be
 
184
            interpreted as a boolean. Returns True or False ortherwise.
 
185
        """
 
186
        s = self._get_user_option(option_name)
 
187
        return ui.bool_from_string(s)
 
188
 
177
189
    def gpg_signing_command(self):
178
190
        """What program should be used to sign signatures?"""
179
191
        result = self._gpg_signing_command()
196
208
        """See log_format()."""
197
209
        return None
198
210
 
199
 
    def __init__(self):
200
 
        super(Config, self).__init__()
201
 
 
202
211
    def post_commit(self):
203
212
        """An ordered list of python functions to call.
204
213
 
299
308
class IniBasedConfig(Config):
300
309
    """A configuration policy that draws from ini files."""
301
310
 
 
311
    def __init__(self, get_filename):
 
312
        super(IniBasedConfig, self).__init__()
 
313
        self._get_filename = get_filename
 
314
        self._parser = None
 
315
 
302
316
    def _get_parser(self, file=None):
303
317
        if self._parser is not None:
304
318
            return self._parser
381
395
        """See Config.log_format."""
382
396
        return self._get_user_option('log_format')
383
397
 
384
 
    def __init__(self, get_filename):
385
 
        super(IniBasedConfig, self).__init__()
386
 
        self._get_filename = get_filename
387
 
        self._parser = None
388
 
 
389
398
    def _post_commit(self):
390
399
        """See Config.post_commit."""
391
400
        return self._get_user_option('post_commit')
930
939
            return self._config.get_option(name, section, default)
931
940
        finally:
932
941
            self.branch.unlock()
933
 
        return result
934
942
 
935
943
    def set_option(self, value, name, section=None):
936
944
        """Set a per-branch configuration option"""