Improve bundle API for bundleregistry changes

The bundle API is a bit confusing and inconsistent. Fix up the
ActivityBundle and ContentBundle classes to be more consistent and to
work with the ongoing improvements being made in bundleregistry.
master
Daniel Drake 11 years ago committed by Daniel Narvaez
parent f4c1bd152a
commit 12476caa12

@ -226,10 +226,6 @@ class ActivityBundle(Bundle):
raise NotInstalledException
return os.path.join(self._path, 'icons')
def get_path(self):
"""Get the activity bundle path."""
return self._path
def get_name(self):
"""Get the activity user-visible name."""
return self._name
@ -287,9 +283,8 @@ class ActivityBundle(Bundle):
"""Get whether there should be a visible launcher for the activity"""
return self._show_launcher
def install(self, install_dir=None):
if install_dir is None:
install_dir = env.get_user_activities_path()
def install(self):
install_dir = env.get_user_activities_path()
self._unzip(install_dir)
@ -348,7 +343,9 @@ class ActivityBundle(Bundle):
os.unlink(dst)
os.symlink(src, dst)
def uninstall(self, install_path, force=False, delete_profile=False):
def uninstall(self, force=False, delete_profile=False):
install_path = self.get_path()
if os.path.islink(install_path):
# Don't remove the actual activity dir if it's a symbolic link
# because we may be removing user data.

@ -26,8 +26,7 @@ import os
import urllib
from sugar3 import env
from sugar3.bundle.bundle import Bundle, NotInstalledException, \
MalformedBundleException
from sugar3.bundle.bundle import Bundle, MalformedBundleException
from sugar3.bundle.bundleversion import NormalizedVersion
from sugar3.bundle.bundleversion import InvalidVersionError
@ -185,6 +184,10 @@ class ContentBundle(Bundle):
def get_activity_start(self):
return self._activity_start
def get_icon(self):
# To be implemented later
return None
def _run_indexer(self):
xdg_data_dirs = os.getenv('XDG_DATA_DIRS',
'/usr/local/share/:/usr/share/')
@ -215,29 +218,17 @@ class ContentBundle(Bundle):
# needs rethinking while fixing ContentBundle support
return self._library_version
def is_installed(self):
if self._zip_file is None:
return True
elif os.path.isdir(self.get_root_dir()):
return ContentBundle(self.get_root_dir()).get_library_version() \
== self.get_library_version()
else:
return False
def install(self):
# TODO ignore passed install_path argument
# needs rethinking while fixing ContentBundle support
install_path = env.get_user_library_path()
self._unzip(install_path)
self._run_indexer()
return self.get_root_dir()
def uninstall(self):
if self._zip_file is None:
if not self.is_installed():
raise NotInstalledException
install_dir = self._path
else:
install_dir = os.path.join(self.get_root_dir())
def uninstall(self, force=False, delete_profile=False):
install_dir = self._path
self._uninstall(install_dir)
self._run_indexer()
def is_user_activity(self):
# All content bundles are installed in user storage
return True

Loading…
Cancel
Save