/b-gtk/fix-viz

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/b-gtk/fix-viz

« back to all changes in this revision

Viewing changes to olive/__init__.py

  • Committer: Jelmer Vernooij
  • Date: 2007-03-13 11:38:34 UTC
  • Revision ID: jelmer@samba.org-20070313113834-vxkz3l62u6ubkvcc
Add test argument to Preferences().

Show diffs side-by-side

added added

removed removed

Lines of Context:
931
931
 
932
932
class Preferences:
933
933
    """ A class which handles Olive's preferences. """
934
 
    def __init__(self):
 
934
    def __init__(self, path=None):
935
935
        """ Initialize the Preferences class. """
936
936
        # Some default options
937
937
        self.defaults = { 'strict_commit' : False,
944
944
 
945
945
        # Create a config parser object
946
946
        self.config = ConfigParser.RawConfigParser()
 
947
 
 
948
        # Set filename
 
949
        if path is None:
 
950
            if sys.platform == 'win32':
 
951
                # Windows - no dotted files
 
952
                self._filename = os.path.expanduser('~/olive.conf')
 
953
            else:
 
954
                self._filename = os.path.expanduser('~/.olive.conf')
 
955
        else:
 
956
            self._filename = path
947
957
        
948
958
        # Load the configuration
949
959
        self.read()
968
978
        """ Just read the configuration. """
969
979
        # Re-initialize the config parser object to avoid some bugs
970
980
        self.config = ConfigParser.RawConfigParser()
971
 
        if sys.platform == 'win32':
972
 
            # Windows - no dotted files
973
 
            self.config.read([os.path.expanduser('~/olive.conf')])
974
 
        else:
975
 
            self.config.read([os.path.expanduser('~/.olive.conf')])
 
981
        self.config.read([self._filename])
976
982
    
977
983
    def write(self):
978
984
        """ Write the configuration to the appropriate files. """
979
 
        if sys.platform == 'win32':
980
 
            # Windows - no dotted files
981
 
            fp = open(os.path.expanduser('~/olive.conf'), 'w')
982
 
            self.config.write(fp)
983
 
            fp.close()
984
 
        else:
985
 
            fp = open(os.path.expanduser('~/.olive.conf'), 'w')
986
 
            self.config.write(fp)
987
 
            fp.close()
 
985
        fp = open(self._filename, 'w')
 
986
        self.config.write(fp)
 
987
        fp.close()
988
988
 
989
989
    def get_bookmarks(self):
990
990
        """ Return the list of bookmarks. """