pep8'd sugar3.datastore
This commit is contained in:
parent
9e4454a2ed
commit
220c9b68ef
@ -157,7 +157,7 @@ class DSObject(object):
|
|||||||
self._update_signal_match.remove()
|
self._update_signal_match.remove()
|
||||||
if object_id is not None:
|
if object_id is not None:
|
||||||
self._update_signal_match = _get_data_store().connect_to_signal(
|
self._update_signal_match = _get_data_store().connect_to_signal(
|
||||||
'Updated', self.__object_updated_cb, arg0=object_id)
|
'Updated', self.__object_updated_cb, arg0=object_id)
|
||||||
|
|
||||||
self._object_id = object_id
|
self._object_id = object_id
|
||||||
|
|
||||||
@ -228,15 +228,15 @@ class RawObject(object):
|
|||||||
stat = os.stat(file_path)
|
stat = os.stat(file_path)
|
||||||
client = GConf.Client.get_default()
|
client = GConf.Client.get_default()
|
||||||
metadata = {
|
metadata = {
|
||||||
'uid': file_path,
|
'uid': file_path,
|
||||||
'title': os.path.basename(file_path),
|
'title': os.path.basename(file_path),
|
||||||
'timestamp': stat.st_mtime,
|
'timestamp': stat.st_mtime,
|
||||||
'mime_type': Gio.content_type_guess(file_path, None)[0],
|
'mime_type': Gio.content_type_guess(file_path, None)[0],
|
||||||
'activity': '',
|
'activity': '',
|
||||||
'activity_id': '',
|
'activity_id': '',
|
||||||
'icon-color': client.get_string('/desktop/sugar/user/color'),
|
'icon-color': client.get_string('/desktop/sugar/user/color'),
|
||||||
'description': file_path,
|
'description': file_path,
|
||||||
}
|
}
|
||||||
|
|
||||||
self.object_id = file_path
|
self.object_id = file_path
|
||||||
self._metadata = DSMetadata(metadata)
|
self._metadata = DSMetadata(metadata)
|
||||||
@ -255,7 +255,7 @@ class RawObject(object):
|
|||||||
if self._file_path is None:
|
if self._file_path is None:
|
||||||
data_path = os.path.join(env.get_profile_path(), 'data')
|
data_path = os.path.join(env.get_profile_path(), 'data')
|
||||||
self._file_path = tempfile.mktemp(
|
self._file_path = tempfile.mktemp(
|
||||||
prefix='rawobject', dir=data_path)
|
prefix='rawobject', dir=data_path)
|
||||||
if not os.path.exists(data_path):
|
if not os.path.exists(data_path):
|
||||||
os.makedirs(data_path)
|
os.makedirs(data_path)
|
||||||
os.symlink(self.object_id, self._file_path)
|
os.symlink(self.object_id, self._file_path)
|
||||||
@ -314,18 +314,18 @@ def create():
|
|||||||
|
|
||||||
|
|
||||||
def _update_ds_entry(uid, properties, filename, transfer_ownership=False,
|
def _update_ds_entry(uid, properties, filename, transfer_ownership=False,
|
||||||
reply_handler=None, error_handler=None, timeout=-1):
|
reply_handler=None, error_handler=None, timeout=-1):
|
||||||
debug_properties = properties.copy()
|
debug_properties = properties.copy()
|
||||||
if 'preview' in debug_properties:
|
if 'preview' in debug_properties:
|
||||||
debug_properties['preview'] = '<omitted>'
|
debug_properties['preview'] = '<omitted>'
|
||||||
logging.debug('dbus_helpers.update: %s, %s, %s, %s', uid, filename,
|
logging.debug('dbus_helpers.update: %s, %s, %s, %s', uid, filename,
|
||||||
debug_properties, transfer_ownership)
|
debug_properties, 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,
|
||||||
reply_handler=reply_handler,
|
reply_handler=reply_handler,
|
||||||
error_handler=error_handler,
|
error_handler=error_handler,
|
||||||
timeout=timeout)
|
timeout=timeout)
|
||||||
else:
|
else:
|
||||||
_get_data_store().update(uid, dbus.Dictionary(properties),
|
_get_data_store().update(uid, dbus.Dictionary(properties),
|
||||||
filename, transfer_ownership)
|
filename, transfer_ownership)
|
||||||
@ -333,7 +333,7 @@ def _update_ds_entry(uid, properties, filename, transfer_ownership=False,
|
|||||||
|
|
||||||
def _create_ds_entry(properties, filename, transfer_ownership=False):
|
def _create_ds_entry(properties, filename, transfer_ownership=False):
|
||||||
object_id = _get_data_store().create(dbus.Dictionary(properties), filename,
|
object_id = _get_data_store().create(dbus.Dictionary(properties), filename,
|
||||||
transfer_ownership)
|
transfer_ownership)
|
||||||
return object_id
|
return object_id
|
||||||
|
|
||||||
|
|
||||||
@ -379,7 +379,7 @@ def write(ds_object, update_mtime=True, transfer_ownership=False,
|
|||||||
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' \
|
logging.warning('datastore.write() cannot currently be called'
|
||||||
'async for creates, see ticket 3071')
|
'async for creates, see ticket 3071')
|
||||||
ds_object.object_id = _create_ds_entry(properties, file_path,
|
ds_object.object_id = _create_ds_entry(properties, file_path,
|
||||||
transfer_ownership)
|
transfer_ownership)
|
||||||
@ -505,4 +505,4 @@ def get_unique_values(key):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
return _get_data_store().get_uniquevaluesfor(
|
return _get_data_store().get_uniquevaluesfor(
|
||||||
key, dbus.Dictionary({}, signature='ss'))
|
key, dbus.Dictionary({}, signature='ss'))
|
||||||
|
Loading…
Reference in New Issue
Block a user