Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/sugar/profile.py
diff options
context:
space:
mode:
authorMarco Pesenti Gritti <marco@localhost.localdomain>2006-10-17 12:31:04 (GMT)
committer Marco Pesenti Gritti <marco@localhost.localdomain>2006-10-17 12:31:04 (GMT)
commit637a08154ed1ebe6c6dd5ee326288fba061842f6 (patch)
tree678afeb7276568928c2a245398f6dd3cd5695775 /sugar/profile.py
parentb481373db0addfa38c52d183610e030c821dc05e (diff)
Fix some path bugs. Reload the profile when first time dialog wrote it.
Diffstat (limited to 'sugar/profile.py')
-rw-r--r--sugar/profile.py44
1 files changed, 28 insertions, 16 deletions
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()