sugar.datastore package

Submodules

sugar.datastore.datastore module

STABLE

class sugar.datastore.datastore.DSMetadata(*args: Any, **kwargs: Any)[source]

Bases: GObject

A representation of the metadata associated with a DS entry.

__init__(properties=None)[source]
has_key(key)[source]
keys()[source]
get_dictionary()[source]
copy()[source]
get(key, default=None)[source]
update(properties)[source]

Update all of the metadata

class sugar.datastore.datastore.DSObject(object_id, metadata=None, file_path=None)[source]

Bases: object

A representation of a DS entry.

__init__(object_id, metadata=None, file_path=None)[source]
get_object_id()[source]
set_object_id(object_id)[source]
property object_id
get_metadata()[source]
set_metadata(metadata)[source]
property metadata
get_file_path(fetch=True)[source]
set_file_path(file_path)[source]
property file_path
destroy()[source]
copy()[source]
class sugar.datastore.datastore.RawObject(file_path)[source]

Bases: object

A representation for objects not in the DS but in the file system.

__init__(file_path)[source]
get_metadata()[source]
property metadata
get_file_path(fetch=True)[source]
property file_path
destroy()[source]
sugar.datastore.datastore.get(object_id)[source]

Get the properties of the object with the ID given.

Keyword arguments: object_id – unique identifier of the object

Return: a DSObject

sugar.datastore.datastore.create()[source]

Create a new DSObject.

Return: a DSObject

sugar.datastore.datastore.write(ds_object, update_mtime=True, transfer_ownership=False, reply_handler=None, error_handler=None, timeout=-1)[source]

Write the DSObject given to the datastore. Creates a new entry if the entry does not exist yet.

Keyword arguments: update_mtime – boolean if the mtime of the entry should be regenerated

(default True)

transfer_ownership – set it to true if the ownership of the entry should

be passed - who is responsible to delete the file when done with it (default False)

reply_handler – will be called with the method’s return values as

arguments (default None)

error_handler – will be called with an instance of a DBusException

representing a remote exception (default None)

timeout – dbus timeout for the caller to wait (default -1)

sugar.datastore.datastore.delete(object_id)[source]

Delete the datastore entry with the given uid.

Keyword arguments: object_id – uid of the datastore entry

sugar.datastore.datastore.find(query, sorting=None, limit=None, offset=None, properties=None, reply_handler=None, error_handler=None)[source]

Find DS entries that match the query provided.

Keyword arguments: query – a dictionary containing metadata key value pairs

for a fulltext search use the key ‘query’ e.g. {‘query’: ‘blue*’} other possible well-known properties are: ‘activity’: ‘my.organization.MyActivity’ ‘activity_id’: ‘6f7f3acacca87886332f50bdd522d805f0abbf1f’ ‘title’: ‘My new project’ ‘title_set_by_user’: ‘0’ ‘keep’: ‘0’ ‘ctime’: ‘1972-05-12T18:41:08’ ‘mtime’: ‘2007-06-16T03:42:33’ ‘timestamp’: 1192715145 ‘preview’: ByteArray(png file data, 300x225 px) ‘icon-color’: ‘#ff0000,#ffff00’ ‘mime_type’: ‘application/x-my-activity’ ‘share-scope’: # if shared ‘buddies’: ‘{}’ ‘description’: ‘some longer text’ ‘tags’: ‘one two’

sorting – key to order results by e.g. ‘timestamp’ (default None) limit – return only limit results (default None) offset – return only results starting at offset (default None) properties – you can specify here a list of metadata you want to be

present in the result e.g. [‘title, ‘keep’] (default None)

reply_handler – will be called with the method’s return values as

arguments (default None)

error_handler – will be called with an instance of a DBusException

representing a remote exception (default None)

Return: DSObjects matching the query, number of matches

sugar.datastore.datastore.copy(ds_object, mount_point)[source]

Copy a datastore entry

Keyword arguments: ds_object – DSObject to copy mount_point – mount point of the new datastore entry

Returns: new_ds_object – DSObject copied

sugar.datastore.datastore.get_unique_values(key)[source]

Retrieve an array of unique values for a field.

Keyword arguments: key – only the property activity is currently supported

Return: list of activities

Module contents