~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/config.py

  • Committer: Aaron Bentley
  • Date: 2006-02-21 02:26:30 UTC
  • mto: (1558.1.1 bzr.ab.integration)
  • mto: This revision was merged to the branch mainline in revision 1559.
  • Revision ID: aaron.bentley@utoronto.ca-20060221022630-c74618c305be4ffd
Switched to ConfigObj 4.2.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
76
76
class ConfigObj(configobj.ConfigObj):
77
77
 
78
78
    def get_bool(self, section, key):
79
 
        val = self[section][key].lower()
80
 
        if val in ('1', 'yes', 'true', 'on'):
81
 
            return True
82
 
        elif val in ('0', 'no', 'false', 'off'):
83
 
            return False
84
 
        else:
85
 
            raise ValueError("Value %r is not boolean" % val)
 
79
        val = self[section].as_bool(key)
86
80
 
87
81
    def get_value(self, section, name):
88
82
        # Try [] for the old DEFAULT section.
548
542
 
549
543
    def _get_config(self):
550
544
        try:
551
 
            obj = ConfigObj(self.branch.control_files.get('branch.conf'
552
 
                        ).readlines())
553
 
            obj.decode('UTF-8')
 
545
            obj = ConfigObj(self.branch.control_files.get('branch.conf'), 
 
546
                            encoding='utf-8')
554
547
        except errors.NoSuchFile:
555
 
            obj = ConfigObj()
 
548
            obj = ConfigObj(encoding='utf=8')
556
549
        return obj
557
550
 
558
551
    def get_option(self, name, section=None, default=None):
583
576
                    cfg_obj[section] = {}
584
577
                    obj = cfg_obj[section]
585
578
            obj[name] = value
586
 
            cfg_obj.encode('UTF-8')
587
 
            out_file = StringIO(''.join([l+'\n' for l in cfg_obj.write()]))
 
579
            out_file = StringIO()
 
580
            cfg_obj.write(out_file)
588
581
            out_file.seek(0)
589
582
            self.branch.control_files.put('branch.conf', out_file)
590
583
        finally: