~bdfhjk/clicompanion/fix-738264

« back to all changes in this revision

Viewing changes to clicompanionlib/config.py

merge from clicompanion.preferences

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env python
 
2
# -*- coding: utf-8 -*-
 
3
#
 
4
# clicompanion.py - commandline tool.
 
5
#
 
6
# Copyright 2010 Duane Hinnen
 
7
#
 
8
# This program is free software: you can redistribute it and/or modify it
 
9
# under the terms of the GNU General Public License version 3, as published
 
10
# by the Free Software Foundation.
 
11
#
 
12
# This program is distributed in the hope that it will be useful, but
 
13
# WITHOUT ANY WARRANTY; without even the implied warranties of
 
14
# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
 
15
# PURPOSE.  See the GNU General Public License for more details.
 
16
#
 
17
# You should have received a copy of the GNU General Public License along
 
18
# with this program.  If not, see <http://www.gnu.org/licenses/>.
 
19
#
 
20
#
 
21
import os
 
22
import ConfigParser
 
23
 
 
24
CONFIGFILE = os.path.expanduser("~/.config/clicompanion/config")
 
25
 
 
26
class Config(object):
 
27
 
 
28
    ''' 
 
29
    create configuration file
 
30
    '''
 
31
 
 
32
    def create_config(self):
 
33
    
 
34
        if not os.path.exists(CONFIGFILE):
 
35
            config = ConfigParser.ConfigParser()
 
36
            # set a number of parameters
 
37
            config.add_section("terminal")
 
38
            config.set("terminal", "scrollb", 500)
 
39
            config.set("terminal", "colorf", '#FFFFFF')
 
40
            config.set("terminal", "colorb", '#000000')
 
41
            config.set("terminal", "encoding", 'utf-8')
 
42
            # Writing our configuration file
 
43
            with open(CONFIGFILE, 'wb') as f:
 
44
                config.write(f)
 
45
            
 
46
        else:
 
47
            pass
 
48
 
 
49
 
 
50