[go: up one dir, main page]

Menu

[r81]: / appconfig.py  Maximize  Restore  History

Download this file

62 lines (55 with data), 2.0 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#! /usr/bin/env python
# -*- coding: utf-8 -*-
import ConfigParser
import os
import sys
try:
import pygtk
pygtk.require("2.0")
import gobject
except:
print("pygtk Not Availible")
sys.exit(1)
try:
import gtk
except:
print("GTK Not Availible")
sys.exit(1)
class Config(ConfigParser.RawConfigParser):
def __init__(self):
ConfigParser.RawConfigParser.__init__(self)
cf_dir = os.path.join(os.path.expanduser('~'), '.minimpy')
bu_dir = os.path.join(cf_dir, 'minimpy_data')
self.first_run = False
self.config_file = os.path.join(cf_dir, 'config.cfg')
if not os.path.exists(cf_dir):
os.mkdir(cf_dir)
self.add_section('interface')
self.add_section('project')
self.add_section('operations')
self.set('interface', 'locale', 'en_US')
self.set('interface', 'layout_dir', 'ltr')
self.set('interface', 'batch_allocation', False)
self.set('interface', 'tab_pos', 2)
self.set('project', 'recent_trial', '')
self.set('project', 'load_recent', True)
self.set('operations', 'backup_network_path', bu_dir)
self.set('operations', 'alt_random', False)
self.set('operations', 'cach_cred', True)
self.set('operations', 'backup_network', True)
self.first_run = True
self.write_config()
self.read_config()
# setting the interface direction
if self.get('interface', 'layout_dir') == 'rtl':
gtk.widget_set_default_direction(gtk.TEXT_DIR_RTL)
elif self.get('interface', 'layout_dir') == 'ltr':
gtk.widget_set_default_direction(gtk.TEXT_DIR_LTR)
def read_config(self):
self.read(self.config_file)
def write_config(self):
with open(self.config_file, 'wb') as config_file:
self.write(config_file)
config_file.flush()
config_file.close()
self.read(self.config_file)