/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/config.py

  • Committer: John Arbash Meinel
  • Date: 2009-12-02 23:09:40 UTC
  • mfrom: (4853.1.1 whitespace)
  • mto: This revision was merged to the branch mainline in revision 4856.
  • Revision ID: john@arbash-meinel.com-20091202230940-7n2aydoxngdqxzld
Strip trailing whitespace from doc files by Patrick Regan.

Resolve one small conflict with another doc edit.
Also, revert the changes to all the .pdf and .png files. We shouldn't
be touching them as they are pure-binary files.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005-2010 Canonical Ltd
 
1
# Copyright (C) 2005, 2007, 2008 Canonical Ltd
2
2
#   Authors: Robert Collins <robert.collins@canonical.com>
3
3
#            and others
4
4
#
190
190
        """Get a generic option as a boolean - no special process, no default.
191
191
 
192
192
        :return None if the option doesn't exist or its value can't be
193
 
            interpreted as a boolean. Returns True or False otherwise.
 
193
            interpreted as a boolean. Returns True or False ortherwise.
194
194
        """
195
195
        s = self._get_user_option(option_name)
196
 
        if s is None:
197
 
            # The option doesn't exist
198
 
            return None
199
 
        val = ui.bool_from_string(s)
200
 
        if val is None:
201
 
            # The value can't be interpreted as a boolean
202
 
            trace.warning('Value "%s" is not a boolean for "%s"',
203
 
                          s, option_name)
204
 
        return val
205
 
 
206
 
    def get_user_option_as_list(self, option_name):
207
 
        """Get a generic option as a list - no special process, no default.
208
 
 
209
 
        :return None if the option doesn't exist. Returns the value as a list
210
 
            otherwise.
211
 
        """
212
 
        l = self._get_user_option(option_name)
213
 
        if isinstance(l, (str, unicode)):
214
 
            # A single value, most probably the user forgot the final ','
215
 
            l = [l]
216
 
        return l
 
196
        return ui.bool_from_string(s)
217
197
 
218
198
    def gpg_signing_command(self):
219
199
        """What program should be used to sign signatures?"""
333
313
                path = 'bzr'
334
314
            return path
335
315
 
336
 
    def suppress_warning(self, warning):
337
 
        """Should the warning be suppressed or emitted.
338
 
 
339
 
        :param warning: The name of the warning being tested.
340
 
 
341
 
        :returns: True if the warning should be suppressed, False otherwise.
342
 
        """
343
 
        warnings = self.get_user_option_as_list('suppress_warnings')
344
 
        if warnings is None or warning not in warnings:
345
 
            return False
346
 
        else:
347
 
            return True
348
 
 
349
316
 
350
317
class IniBasedConfig(Config):
351
318
    """A configuration policy that draws from ini files."""
518
485
        self._write_config_file()
519
486
 
520
487
    def _write_config_file(self):
521
 
        path = self._get_filename()
522
 
        f = open(path, 'wb')
523
 
        osutils.copy_ownership_from_path(path)
 
488
        f = open(self._get_filename(), 'wb')
524
489
        self._get_parser().write(f)
525
490
        f.close()
526
491
 
820
785
            os.mkdir(parent_dir)
821
786
        trace.mutter('creating config directory: %r', path)
822
787
        os.mkdir(path)
823
 
        osutils.copy_ownership_from_path(path)
824
788
 
825
789
 
826
790
def config_dir():
877
841
 
878
842
    This doesn't implicitly create it.
879
843
 
880
 
    On Windows it's in the config directory; elsewhere it's /var/crash
881
 
    which may be monitored by apport.  It can be overridden by
882
 
    $APPORT_CRASH_DIR.
 
844
    On Windows it's in the config directory; elsewhere in the XDG cache directory.
883
845
    """
884
846
    if sys.platform == 'win32':
885
847
        return osutils.pathjoin(config_dir(), 'Crash')
886
848
    else:
887
 
        # XXX: hardcoded in apport_python_hook.py; therefore here too -- mbp
888
 
        # 2010-01-31
889
 
        return os.environ.get('APPORT_CRASH_DIR', '/var/crash')
 
849
        return osutils.pathjoin(xdg_cache_dir(), 'crash')
890
850
 
891
851
 
892
852
def xdg_cache_dir():
1417
1377
 
1418
1378
 
1419
1379
class PlainTextCredentialStore(CredentialStore):
1420
 
    __doc__ = """Plain text credential store for the authentication.conf file"""
 
1380
    """Plain text credential store for the authentication.conf file."""
1421
1381
 
1422
1382
    def decode_password(self, credentials):
1423
1383
        """See CredentialStore.decode_password."""
1512
1472
 
1513
1473
    def _get_config_file(self):
1514
1474
        try:
1515
 
            return StringIO(self._transport.get_bytes(self._filename))
 
1475
            return self._transport.get(self._filename)
1516
1476
        except errors.NoSuchFile:
1517
1477
            return StringIO()
1518
1478