roc/config.py
cecilkorik ab901dc58f Added platform specific architecture and cleaned up some of the platform
specific hacks in video.py
Added a config file (settings.cfg)
Added functionality for saving last used window position!
Added displaylists to models.py
Broke fonts (temporarily)
2011-10-23 01:42:40 -06:00

45 lines
872 B
Python

import os
import files
class configmanager(object):
def __init__(self):
self.filepath = None
self.data = {}
def load(self):
self.filepath = os.path.join(files.get_basedir(), 'settings.cfg')
if not os.path.exists(self.filepath):
return
fd = open(self.filepath, 'r')
for x in fd:
x = x.strip()
if not '=' in x:
continue
x = x.split('=')
k = x[0].strip()
v = '='.join(x[1:]).strip()
self.data[k] = v
fd.close()
def save(self):
fd = open(self.filepath, 'w')
for k, v in self.data.items():
fd.write("%s = %s\n" % (k, v))
fd.close()
def read_key(self, key):
if key in self.data:
return self.data[key]
else:
return None
def write_key(self, key, value):
self.data[key] = value
def init():
global mgr
mgr = configmanager()
mgr.load()
mgr = None