diff options
Diffstat (limited to 'FileShare.activity/ShareFavorites.py')
-rw-r--r-- | FileShare.activity/ShareFavorites.py | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/FileShare.activity/ShareFavorites.py b/FileShare.activity/ShareFavorites.py new file mode 100644 index 0000000..f5db68a --- /dev/null +++ b/FileShare.activity/ShareFavorites.py @@ -0,0 +1,33 @@ +from sugar.datastore import datastore + +def load_journal_table(): + """ + Carga la metadata del Diario de Sugar + Retorna una lista de objetos de datastore + """ + ds_mounts = datastore.mounts() + mountpoint_id = None + if len(ds_mounts) == 1 and ds_mounts[0]['id'] == 1: + query = { 'sorting':'timestamp', 'keep':'1' } + else: + # we're in sugar 0.82 + query = { 'order_by':'-timestamp' } + for mountpoint in ds_mounts: + id = mountpoint['id'] + uri = mountpoint['uri'] + if uri.startswith('/home'): + mountpoint_id = id + + if mountpoint_id is not None: + query['mountpoints'] = [ mountpoint_id ] + + ds_objects, num_objects = datastore.find( + query, properties=['title_set_by_user','activity', + 'title', 'mime_type', 'mtime', 'share-scope','uid', + 'keep', 'tags', 'description']) + + return ds_objects + +if __name__ == '__main__': + for obj in load_journal_table(): + print obj.metadata.get_dictionary()['title'] |