~mars/tarmac/move-pre-merge-hook

« back to all changes in this revision

Viewing changes to tarmac/config.py

  • Committer: Tarmac
  • Author(s): Rodney Dawes
  • Date: 2010-10-13 04:54:58 UTC
  • mfrom: (370.2.1 fix-votes)
  • Revision ID: paul@eventuallyanyway.com-20101013045458-nfynkzkk2ka9n8u3
Expose [Tarmac] options as attributes on the TarmacConfig object
Wrap set and remove_option so that we can manage TarmacConfig attributes
Fix the global config Votes tests to not set the attributes directly

Show diffs side-by-side

added added

removed removed

Lines of Context:
45
45
        if not self.has_option('Tarmac', 'log_file'):
46
46
            self.set('Tarmac', 'log_file', DEFAULTS['log_file'])
47
47
 
 
48
        for key, val in self.items('Tarmac'):
 
49
            setattr(self, key, val)
 
50
 
 
51
    def set(self, section, option, value):
 
52
        """Wrap the set method, so we can tweak our attrs."""
 
53
        ConfigParser.set(self, section, option, value)
 
54
        if section == 'Tarmac':
 
55
            setattr(self, option, value)
 
56
 
 
57
    def remove_option(self, section, option):
 
58
        """Wrap the remove_option method so we can tweak our attrs."""
 
59
        ConfigParser.remove_option(self, section, option)
 
60
        if section == 'Tarmac':
 
61
            delattr(self, option)
 
62
 
48
63
    @property
49
64
    def CONFIG_HOME(self):
50
65
        '''Return the base dir for the config.'''