sugar.bundle package

Submodules

sugar.bundle.activitybundle module

Sugar activity bundles

UNSTABLE.

class sugar.bundle.activitybundle.ActivityBundle(path, translated=True)[source]

Bases: Bundle

A Sugar activity bundle

See http://wiki.sugarlabs.org/go/Development_Team/Almanac/Activity_Bundles for details

MIME_TYPE = 'application/vnd.olpc-sugar'
__init__(path, translated=True)[source]
get_locale_path()[source]

Get the locale path inside the (installed) activity bundle.

get_icons_path()[source]

Get the icons path inside the (installed) activity bundle.

get_name()[source]

Get the activity user-visible name.

get_bundle_id()[source]

Get the activity bundle id

get_icon()[source]

Get the activity icon name

get_icon_filename()[source]

Get the icon file name

get_activity_version()[source]

Get the activity version

get_command()[source]

Get the command to execute to launch the activity factory

get_mime_types()[source]

Get the MIME types supported by the activity

get_tags()[source]

Get the tags that describe the activity

get_summary()[source]

Get the summary that describe the activity

get_description()[source]

Get the description for the activity. The description is a pace of multi paragraph text about the activity. It is written in a HTML subset using only the p, ul, li and ol tags.

get_single_instance()[source]

Get whether there should be a single instance for the activity

get_max_participants()[source]

Get maximum number of participants in share

get_show_launcher()[source]

Get whether there should be a visible launcher for the activity

install()[source]
install_mime_type(install_path)[source]

Update the mime type database and install the mime type icon

uninstall(force=False, delete_profile=False)[source]
is_user_activity()[source]
sugar.bundle.activitybundle.get_bundle_instance(path, translated=True)[source]

sugar.bundle.bundle module

Sugar bundle file handler

UNSTABLE.

exception sugar.bundle.bundle.AlreadyInstalledException[source]

Bases: Exception

exception sugar.bundle.bundle.NotInstalledException[source]

Bases: Exception

exception sugar.bundle.bundle.InvalidPathException[source]

Bases: Exception

exception sugar.bundle.bundle.ZipExtractException[source]

Bases: Exception

exception sugar.bundle.bundle.RegistrationException[source]

Bases: Exception

exception sugar.bundle.bundle.MalformedBundleException[source]

Bases: Exception

class sugar.bundle.bundle.Bundle(path)[source]

Bases: object

A Sugar activity, content module, etc.

The bundle itself may be either a zip file or a directory hierarchy, with metadata about the bundle stored various files inside it.

This is an abstract base class. See ActivityBundle and ContentBundle for more details on those bundle types.

__init__(path)[source]
get_file(filename)[source]
is_file(filename)[source]
is_dir(filename)[source]
get_path()[source]

Get the bundle path.

get_installation_time()[source]

Get a timestamp representing the time at which this activity was installed.

get_show_launcher()[source]

sugar.bundle.bundleversion module

Validation and normalization of bundle versions.

Instances of NormalizedVersion can be directly compared;

>>> from sugar.bundle.bundleversion import NormalizedVersion
>>> a = NormalizedVersion('157.3')
>>> b = NormalizedVersion('201.2')
>>> a > b
False
>>> b > a
True

Invalid versions will raise InvalidVersionError.

Valid versions are 1, 1.2, 1.2.3, 1.2.3-peru, and 1.2.3~dfsg.

Invalid versions are:
  • 1.2peru (because the suffix must be preceded with a dash or tilde),

  • 1.2. (because a version can’t end with a period), or

  • 1.02.5 (because a version can’t have a leading zero).

Based on the implementation of PEP 386, but adapted to our numeration schema.

sugar.bundle.bundleversion.VERSION_RE

regular expression for versions, deprecated, as it is insufficient by itself.

Type:

RegexObject

exception sugar.bundle.bundleversion.InvalidVersionError[source]

Bases: Exception

A version cannot be normalized, because:
  • the object is not a string,

  • the string does not match the regular expression, or

  • the string has a leading zero in a version part.

class sugar.bundle.bundleversion.NormalizedVersion(activity_version)[source]

Bases: object

Normalize a version string.

Parameters:

activity_version (str) – the version string

Raises:

InvalidVersionError

parts

the numeric parts of the version after normalization.

Type:

list

__init__(activity_version)[source]

sugar.bundle.contentbundle module

Sugar content bundles

UNSTABLE.

class sugar.bundle.contentbundle.ContentBundle(path)[source]

Bases: Bundle

A Sugar content bundle

See http://wiki.laptop.org/go/Content_bundles for details

MIME_TYPE = 'application/vnd.olpc-content'
__init__(path)[source]
get_name()[source]
get_library_version()[source]
get_locale()[source]
get_activity_start()[source]
get_icon()[source]
get_start_uri()[source]
get_bundle_id()[source]
get_activity_version()[source]
get_tags()[source]
install()[source]
uninstall(force=False, delete_profile=False)[source]
is_user_activity()[source]

sugar.bundle.helpers module

sugar.bundle.helpers.bundle_from_archive(path, mime_type=None)[source]

Return an appropriate Bundle object for a given file path. The bundle type is identified by mime_type, which is guessed if not provided.

sugar.bundle.helpers.bundle_from_dir(path)[source]

Return an appropriate Bundle object for a given directory containing an unzipped bundle.

Module contents