pylint sugar.datastore, little issues left
This commit is contained in:
parent
a31549ae26
commit
aebf0f3bd2
@ -27,7 +27,6 @@ from sugar import activity
|
|||||||
from sugar.activity.activityhandle import ActivityHandle
|
from sugar.activity.activityhandle import ActivityHandle
|
||||||
from sugar.bundle.contentbundle import ContentBundle
|
from sugar.bundle.contentbundle import ContentBundle
|
||||||
from sugar.bundle.activitybundle import ActivityBundle
|
from sugar.bundle.activitybundle import ActivityBundle
|
||||||
from sugar.bundle.contentbundle import ContentBundle
|
|
||||||
from sugar import mime
|
from sugar import mime
|
||||||
|
|
||||||
class DSMetadata(gobject.GObject):
|
class DSMetadata(gobject.GObject):
|
||||||
@ -122,7 +121,7 @@ class DSObject(object):
|
|||||||
result = registry.get_activities_for_type(mime_type)
|
result = registry.get_activities_for_type(mime_type)
|
||||||
if not result:
|
if not result:
|
||||||
for parent_mime in mime.get_mime_parents(mime_type):
|
for parent_mime in mime.get_mime_parents(mime_type):
|
||||||
result.extend(registry.get_activities_for_type(parent_mime))
|
result.extend(registry.get_activities_for_type(parent_mime))
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def get_activities(self):
|
def get_activities(self):
|
||||||
@ -158,7 +157,7 @@ class DSObject(object):
|
|||||||
|
|
||||||
if self.is_activity_bundle():
|
if self.is_activity_bundle():
|
||||||
if bundle_id is not None:
|
if bundle_id is not None:
|
||||||
raise ValueError('Object is a bundle, cannot be resumed as an activity.')
|
raise ValueError('Bundle cannot be resumed as an activity.')
|
||||||
|
|
||||||
logging.debug('Creating activity bundle')
|
logging.debug('Creating activity bundle')
|
||||||
bundle = ActivityBundle(self.file_path)
|
bundle = ActivityBundle(self.file_path)
|
||||||
@ -169,7 +168,8 @@ class DSObject(object):
|
|||||||
logging.debug('Upgrading activity bundle')
|
logging.debug('Upgrading activity bundle')
|
||||||
bundle.upgrade()
|
bundle.upgrade()
|
||||||
|
|
||||||
logging.debug('activityfactory.creating bundle with id %r', bundle.get_bundle_id())
|
logging.debug('activityfactory.creating bundle with id %r',
|
||||||
|
bundle.get_bundle_id())
|
||||||
activityfactory.create(bundle.get_bundle_id())
|
activityfactory.create(bundle.get_bundle_id())
|
||||||
else:
|
else:
|
||||||
if not self.get_activities() and bundle_id is None:
|
if not self.get_activities() and bundle_id is None:
|
||||||
@ -192,7 +192,6 @@ class DSObject(object):
|
|||||||
def destroy(self):
|
def destroy(self):
|
||||||
if self._destroyed:
|
if self._destroyed:
|
||||||
logging.warning('This DSObject has already been destroyed!.')
|
logging.warning('This DSObject has already been destroyed!.')
|
||||||
import traceback;traceback.print_stack()
|
|
||||||
return
|
return
|
||||||
self._destroyed = True
|
self._destroyed = True
|
||||||
if self._file_path and self._owns_file:
|
if self._file_path and self._owns_file:
|
||||||
@ -204,7 +203,7 @@ class DSObject(object):
|
|||||||
def __del__(self):
|
def __del__(self):
|
||||||
if not self._destroyed:
|
if not self._destroyed:
|
||||||
logging.warning('DSObject was deleted without cleaning up first. ' \
|
logging.warning('DSObject was deleted without cleaning up first. ' \
|
||||||
'Please call DSObject.destroy() before disposing it.')
|
'Call DSObject.destroy() before disposing it.')
|
||||||
self.destroy()
|
self.destroy()
|
||||||
|
|
||||||
def copy(self):
|
def copy(self):
|
||||||
@ -224,7 +223,8 @@ def create():
|
|||||||
metadata['timestamp'] = int(time.time())
|
metadata['timestamp'] = int(time.time())
|
||||||
return DSObject(object_id=None, metadata=metadata, file_path=None)
|
return DSObject(object_id=None, metadata=metadata, file_path=None)
|
||||||
|
|
||||||
def write(ds_object, update_mtime=True, transfer_ownership=False, reply_handler=None, error_handler=None, timeout=-1):
|
def write(ds_object, update_mtime=True, transfer_ownership=False,
|
||||||
|
reply_handler=None, error_handler=None, timeout=-1):
|
||||||
logging.debug('datastore.write')
|
logging.debug('datastore.write')
|
||||||
|
|
||||||
properties = ds_object.metadata.get_dictionary().copy()
|
properties = ds_object.metadata.get_dictionary().copy()
|
||||||
@ -250,8 +250,8 @@ def write(ds_object, update_mtime=True, transfer_ownership=False, reply_handler=
|
|||||||
timeout=timeout)
|
timeout=timeout)
|
||||||
else:
|
else:
|
||||||
if reply_handler or error_handler:
|
if reply_handler or error_handler:
|
||||||
logging.warning('datastore.write() cannot currently be called async' \
|
logging.warning('datastore.write() cannot currently be called' \
|
||||||
' for creates, see https://dev.laptop.org/ticket/3071')
|
'async for creates, see ticket 3071')
|
||||||
ds_object.object_id = dbus_helpers.create(properties,
|
ds_object.object_id = dbus_helpers.create(properties,
|
||||||
file_path,
|
file_path,
|
||||||
transfer_ownership)
|
transfer_ownership)
|
||||||
@ -274,7 +274,8 @@ def find(query, sorting=None, limit=None, offset=None, properties=[],
|
|||||||
if offset:
|
if offset:
|
||||||
query['offset'] = offset
|
query['offset'] = offset
|
||||||
|
|
||||||
props_list, total_count = dbus_helpers.find(query, properties, reply_handler, error_handler)
|
props_list, total_count = dbus_helpers.find(query, properties,
|
||||||
|
reply_handler, error_handler)
|
||||||
|
|
||||||
objects = []
|
objects = []
|
||||||
for props in props_list:
|
for props in props_list:
|
||||||
|
@ -20,9 +20,6 @@ import logging
|
|||||||
|
|
||||||
import dbus
|
import dbus
|
||||||
import dbus.glib
|
import dbus.glib
|
||||||
import gobject
|
|
||||||
|
|
||||||
from sugar import util
|
|
||||||
|
|
||||||
DS_DBUS_SERVICE = "org.laptop.sugar.DataStore"
|
DS_DBUS_SERVICE = "org.laptop.sugar.DataStore"
|
||||||
DS_DBUS_INTERFACE = "org.laptop.sugar.DataStore"
|
DS_DBUS_INTERFACE = "org.laptop.sugar.DataStore"
|
||||||
@ -51,7 +48,8 @@ def update(uid, properties, filename, transfer_ownership=False,
|
|||||||
debug_props = properties.copy()
|
debug_props = properties.copy()
|
||||||
if debug_props.has_key("preview"):
|
if debug_props.has_key("preview"):
|
||||||
debug_props["preview"] = "<omitted>"
|
debug_props["preview"] = "<omitted>"
|
||||||
logging.debug('dbus_helpers.update: %s, %s, %s, %s' % (uid, filename, debug_props, transfer_ownership))
|
logging.debug('dbus_helpers.update: %s, %s, %s, %s' %
|
||||||
|
(uid, filename, debug_props, transfer_ownership))
|
||||||
if reply_handler and error_handler:
|
if reply_handler and error_handler:
|
||||||
_get_data_store().update(uid, dbus.Dictionary(properties), filename,
|
_get_data_store().update(uid, dbus.Dictionary(properties), filename,
|
||||||
transfer_ownership,
|
transfer_ownership,
|
||||||
@ -59,7 +57,8 @@ def update(uid, properties, filename, transfer_ownership=False,
|
|||||||
error_handler=error_handler,
|
error_handler=error_handler,
|
||||||
timeout=timeout)
|
timeout=timeout)
|
||||||
else:
|
else:
|
||||||
_get_data_store().update(uid, dbus.Dictionary(properties), filename, transfer_ownership)
|
_get_data_store().update(uid, dbus.Dictionary(properties),
|
||||||
|
filename, transfer_ownership)
|
||||||
|
|
||||||
def delete(uid):
|
def delete(uid):
|
||||||
logging.debug('dbus_helpers.delete: %r' % uid)
|
logging.debug('dbus_helpers.delete: %r' % uid)
|
||||||
@ -92,7 +91,8 @@ def mounts():
|
|||||||
return _get_data_store().mounts()
|
return _get_data_store().mounts()
|
||||||
|
|
||||||
def get_unique_values(key):
|
def get_unique_values(key):
|
||||||
return _get_data_store().get_uniquevaluesfor(key, dbus.Dictionary({}, signature='ss'))
|
return _get_data_store().get_uniquevaluesfor(
|
||||||
|
key, dbus.Dictionary({}, signature='ss'))
|
||||||
|
|
||||||
def complete_indexing():
|
def complete_indexing():
|
||||||
return _get_data_store().complete_indexing()
|
return _get_data_store().complete_indexing()
|
||||||
|
Loading…
Reference in New Issue
Block a user