Automatically read the profile (lazily)
This commit is contained in:
@@ -3,6 +3,8 @@ import os
|
||||
from ConfigParser import ConfigParser
|
||||
from ConfigParser import NoOptionError
|
||||
|
||||
from sugar import env
|
||||
|
||||
class ActivityModule:
|
||||
"""Info about an activity module. Wraps a .activity file."""
|
||||
|
||||
@@ -54,6 +56,7 @@ class ActivityRegistry:
|
||||
|
||||
def __init__(self):
|
||||
self._activities = []
|
||||
self.scan_directory(env.get_activities_dir())
|
||||
|
||||
def get_activity_from_id(self, activity_id):
|
||||
"""Returns an activity given his identifier"""
|
||||
|
||||
+17
-19
@@ -1,11 +1,27 @@
|
||||
import os
|
||||
from ConfigParser import ConfigParser
|
||||
|
||||
from sugar.canvas.IconColor import IconColor
|
||||
from sugar import env
|
||||
|
||||
class Profile:
|
||||
def __init__(self,):
|
||||
self._path = None
|
||||
self._path = env.get_profile_path()
|
||||
self._nick_name = None
|
||||
self._color = None
|
||||
|
||||
self._ensure_dirs()
|
||||
|
||||
cp = ConfigParser()
|
||||
parsed = cp.read([self._get_config_path()])
|
||||
|
||||
if cp.has_option('Buddy', 'NickName'):
|
||||
self._nick_name = cp.get('Buddy', 'NickName')
|
||||
if cp.has_option('Buddy', 'Color'):
|
||||
self._color = IconColor(cp.get('Buddy', 'Color'))
|
||||
|
||||
if self._color == None:
|
||||
self.set_color(IconColor())
|
||||
|
||||
def _ensure_dirs(self):
|
||||
try:
|
||||
@@ -29,24 +45,6 @@ class Profile:
|
||||
def get_path(self):
|
||||
return self._path
|
||||
|
||||
def set_path(self, path):
|
||||
self._path = path
|
||||
|
||||
def read(self):
|
||||
self._color = None
|
||||
self._ensure_dirs()
|
||||
|
||||
cp = ConfigParser()
|
||||
parsed = cp.read([self._get_config_path()])
|
||||
|
||||
if cp.has_option('Buddy', 'NickName'):
|
||||
self._nick_name = cp.get('Buddy', 'NickName')
|
||||
if cp.has_option('Buddy', 'Color'):
|
||||
self._color = IconColor(cp.get('Buddy', 'Color'))
|
||||
|
||||
if self._color == None:
|
||||
self.set_color(IconColor())
|
||||
|
||||
def save(self):
|
||||
cp = ConfigParser()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user