Fix some path bugs. Reload the profile when first time dialog wrote it.

This commit is contained in:
Marco Pesenti Gritti
2006-10-17 14:31:04 +02:00
parent b481373db0
commit 637a08154e
3 changed files with 37 additions and 18 deletions
+28 -16
View File
@@ -20,24 +20,36 @@ from ConfigParser import ConfigParser
from sugar import env
from sugar.graphics.iconcolor import IconColor
class _Profile(object):
def __init__(self):
self.name = None
self.color = None
self._load()
def update(self):
self._load()
def _load(self):
cp = ConfigParser()
config_path = os.path.join(env.get_profile_path(), 'config')
parsed = cp.read([config_path])
if cp.has_option('Buddy', 'NickName'):
self.name = cp.get('Buddy', 'NickName')
if cp.has_option('Buddy', 'Color'):
self.color = IconColor(cp.get('Buddy', 'Color'))
del cp
def get_nick_name():
return _nick_name
return _profile.name
def get_color():
return _color
return _profile.color
cp = ConfigParser()
config_path = os.path.join(env.get_profile_path(), 'config')
parsed = cp.read([config_path])
def update():
print 'Update'
_profile.update()
if cp.has_option('Buddy', 'NickName'):
_nick_name = cp.get('Buddy', 'NickName')
else:
_nick_name = None
if cp.has_option('Buddy', 'Color'):
_color = IconColor(cp.get('Buddy', 'Color'))
else:
_color = None
del cp
_profile = _Profile()