From 637a08154ed1ebe6c6dd5ee326288fba061842f6 Mon Sep 17 00:00:00 2001 From: Marco Pesenti Gritti Date: Tue, 17 Oct 2006 12:31:04 +0000 Subject: Fix some path bugs. Reload the profile when first time dialog wrote it. --- (limited to 'sugar') diff --git a/sugar/profile.py b/sugar/profile.py index 12eb08b..2ba1fd7 100644 --- a/sugar/profile.py +++ b/sugar/profile.py @@ -20,24 +20,36 @@ from ConfigParser import ConfigParser from sugar import env from sugar.graphics.iconcolor import IconColor -def get_nick_name(): - return _nick_name +class _Profile(object): + def __init__(self): + self.name = None + self.color = None + self._load() -def get_color(): - return _color + 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') -cp = ConfigParser() -config_path = os.path.join(env.get_profile_path(), 'config') -parsed = cp.read([config_path]) + if cp.has_option('Buddy', 'Color'): + self.color = IconColor(cp.get('Buddy', 'Color')) -if cp.has_option('Buddy', 'NickName'): - _nick_name = cp.get('Buddy', 'NickName') -else: - _nick_name = None + del cp + +def get_nick_name(): + return _profile.name + +def get_color(): + return _profile.color -if cp.has_option('Buddy', 'Color'): - _color = IconColor(cp.get('Buddy', 'Color')) -else: - _color = None +def update(): + print 'Update' + _profile.update() -del cp +_profile = _Profile() -- cgit v0.9.1