本文整理汇总了Python中sugar3.datastore.datastore.get函数的典型用法代码示例。如果您正苦于以下问题:Python get函数的具体用法?Python get怎么用?Python get使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: load_from_journal
def load_from_journal(self, journal_data):
for card in self._card_data:
alphabet = card[0]
if alphabet in journal_data:
for images in journal_data[alphabet]:
imagedataobject = datastore.get(images[0])
audiodataobject = datastore.get(images[1])
if imagedataobject and audiodataobject:
imagepath = imagedataobject.get_file_path()
pixbuf = image_file_to_pixbuf(imagepath, self._card_width,
self._card_height)
audiopath = audiodataobject.get_file_path()
s = Sprite(self._sprites, 0, 0, pixbuf)
self._image_data[alphabet].append((s, audiopath))
self._pictures.append(s)
开发者ID:leonardcj,项目名称:lettermatch,代码行数:15,代码来源:page.py
示例2: _process_tags
def _process_tags(self, text_buffer, text):
""" process tag data from textview """
self._reflection.data["tags"] = []
label = ""
tags = text.split()
for tag in tags:
if len(label) > 0:
label += ", "
tag = tag.rstrip(",")
tag = tag.rstrip(";")
if tag[0] == "#":
self._reflection.data["tags"].append(tag)
label += tag
else:
self._reflection.data["tags"].append("#" + tag)
label += "#" + tag
text_buffer.set_text(label.replace("\12", ""))
if self._reflection.activity.sharing:
data = json.dumps(self._reflection.data["tags"])
self._reflection.activity.send_event("%s|%s|%s" % (TAG_CMD, self._reflection.data["obj_id"], data))
self._reflection.set_modification_time()
# Update journal entry
dsobj = datastore.get(self._reflection.data["obj_id"])
logging.error("setting tags to %s" % label)
dsobj.metadata["tags"] = label
datastore.write(
dsobj,
update_mtime=False,
reply_handler=self.datastore_write_cb,
error_handler=self.datastore_write_error_cb,
)
开发者ID:samdroid-apps,项目名称:reflect,代码行数:32,代码来源:reflectwindow.py
示例3: create_preview
def create_preview(self, object_id):
jobject = datastore.get(object_id)
if 'preview' in jobject.metadata:
preview = jobject.metadata['preview']
if preview is None or preview == '' or preview == 'None':
if jobject.metadata['mime_type'] .startswith('image/') and \
jobject.metadata['mime_type'] != 'image/vnd.djvu':
filename = jobject.get_file_path()
self.show_image(filename)
return
if jobject.metadata['mime_type'] == 'application/x-cbz':
filename = jobject.get_file_path()
fname = self.extract_image(filename)
self.show_image(fname)
os.remove(fname)
return
self.show_image('xoimage.jpg')
return
if 'preview' in jobject.metadata and \
len(jobject.metadata['preview']) > 4:
preview_data = jobject.metadata['preview']
loader = GdkPixbuf.PixbufLoader()
loader.write(preview_data)
scaled_buf = loader.get_pixbuf()
loader.close()
self.image.set_from_pixbuf(scaled_buf)
self.image.show()
else:
self.image.clear()
self.image.show()
开发者ID:leonardcj,项目名称:sugar-commander,代码行数:32,代码来源:sugarcommander.py
示例4: update_entry
def update_entry(self):
needs_update = False
if self.selected_journal_entry is None:
return
object_id = self.selected_journal_entry.object_id
jobject = datastore.get(object_id)
old_title = jobject.metadata.get('title', None)
if old_title != self.title_entry.props.text:
jobject.metadata['title'] = self.title_entry.props.text
jobject.metadata['title_set_by_user'] = '1'
self.update_log_entries += '\n' + _('Entry title changed to %s') % self.title_entry.props.text
needs_update = True
old_tags = jobject.metadata.get('tags', None)
new_tags = self.tags_textview.props.buffer.props.text
if old_tags != new_tags:
jobject.metadata['tags'] = new_tags
self.update_log_entries += '\n' + _('Entry %s tags updated.') % self.title_entry.props.text
needs_update = True
old_description = jobject.metadata.get('description', None)
new_description = self.description_textview.props.buffer.props.text
if old_description != new_description:
jobject.metadata['description'] = new_description
self.update_log_entries += '\n' + _('Entry %s description updated.') % self.title_entry.props.text
needs_update = True
if needs_update:
datastore.write(jobject, update_mtime=False,
reply_handler=self.datastore_write_cb,
error_handler=self.datastore_write_error_cb)
self.btn_save.props.sensitive = False
开发者ID:leonardcj,项目名称:sugar-commander,代码行数:35,代码来源:sugarcommander.py
示例5: selection_journal_cb
def selection_journal_cb(self, selection):
self.btn_delete.props.sensitive = True
tv = selection.get_tree_view()
model = tv.get_model()
sel = selection.get_selected()
if sel:
model, iter = sel
jobject = model.get_value(iter,COLUMN_JOBJECT)
jobject = datastore.get(jobject.object_id)
self.selected_journal_entry = jobject
self.set_form_fields(jobject)
if jobject.metadata['mime_type'] .startswith('image/') \
and jobject.metadata['mime_type'] != 'image/vnd.djvu':
self.btn_resize.show()
self.resize_width_entry.show()
filename = jobject.get_file_path()
im = pygame.image.load(filename)
image_width, image_height = im.get_size()
self.dimension_label.set_text(str(image_width) + "x" + str(image_height))
self.dimension_label.show()
else:
self.btn_resize.hide()
self.resize_width_entry.hide()
self.dimension_label.hide()
self.selected_path = model.get_path(iter)
开发者ID:leonardcj,项目名称:sugar-commander,代码行数:25,代码来源:sugarcommander.py
示例6: _process_tags
def _process_tags(self, text_buffer, text):
''' process tag data from textview '''
self._reflection.data['tags'] = []
label = ''
tags = text.split()
for tag in tags:
if len(label) > 0:
label += ', '
tag = tag.rstrip(',')
tag = tag.rstrip(';')
if tag[0] == '#':
self._reflection.data['tags'].append(tag)
label += tag
else:
self._reflection.data['tags'].append('#' + tag)
label += '#' + tag
text_buffer.set_text(label.replace('\12', ''))
if self._reflection.activity.sharing:
data = json.dumps(self._reflection.data['tags'])
self._reflection.activity.send_event(TAG_CMD,
{"obj_id": self._refelection.data["ob_id"],
"reflection": data})
self._reflection.set_modification_time()
# Update journal entry
dsobj = datastore.get(self._reflection.data['obj_id'])
logging.error('setting tags to %s' % label)
dsobj.metadata['tags'] = label
datastore.write(dsobj,
update_mtime=False,
reply_handler=self.datastore_write_cb,
error_handler=self.datastore_write_error_cb)
开发者ID:AbrahmAB,项目名称:reflect,代码行数:32,代码来源:reflectwindow.py
示例7: insert_comment
def insert_comment(self, obj_id, comment):
for item in self._reflections:
if item.obj_id == obj_id:
item.graphics.add_new_comment(comment)
item.graphics.notify_button.show()
# Update journal entry
if obj_id[0:4] == 'obj-':
break
try:
dsobj = datastore.get(obj_id)
except Exception as e:
logging.error('Could not open %s: %e' % (obj_id, e))
break
if 'comments' in dsobj.metadata:
data = json.loads(dsobj.metadata['comments'])
else:
data = []
data.append({'from': comment['nick'],
'message': comment['comment'],
'icon-color': '%s,%s' % (
comment['color'], comment['color'])
})
dsobj.metadata['comments'] = json.dumps(data)
datastore.write(dsobj,
update_mtime=False,
reply_handler=self.datastore_write_cb,
error_handler=self.datastore_write_error_cb)
break
开发者ID:AbrahmAB,项目名称:reflect,代码行数:28,代码来源:reflectwindow.py
示例8: _comment_activate_cb
def _comment_activate_cb(self, entry):
text = entry.props.text
if not 'comments' in self._reflection.data:
self._reflection.data['comments'] = []
data = {'nick': profile.get_nick_name(),
'color': self._reflection.activity.fg_color.get_html(),
'comment': text}
self._reflection.data['comments'].append(data)
self.add_new_comment(data)
# Send the comment
if self._reflection.activity.sharing:
send_data = data.copy()
send_data["obj_id"] = self._reflection.data["obj_id"]
self._reflection.activity.send_event(COMMENT_CMD, send_data)
entry.set_text('')
# Update journal entry
dsobj = datastore.get(self._reflection.data['obj_id'])
if 'comments' in dsobj.metadata:
data = json.loads(dsobj.metadata['comments'])
else:
data = []
data.append({'from': profile.get_nick_name(),
'message': text,
'icon-color': profile.get_color().to_string()})
dsobj.metadata['comments'] = json.dumps(data)
datastore.write(dsobj,
update_mtime=False,
reply_handler=self.datastore_write_cb,
error_handler=self.datastore_write_error_cb)
开发者ID:AbrahmAB,项目名称:reflect,代码行数:31,代码来源:reflectwindow.py
示例9: get_bundle
def get_bundle(bundle_id=None, object_id=None):
if bundle_id is None and object_id is None:
logging.error('At least one parameter has to be passed')
return None
if bundle_id is None:
obj = datastore.get(object_id)
if obj.metadata['mime_type'] is None:
return None
mime_type = str(obj.metadata['mime_type'])
activities = get_activities_for_mime(mime_type)
if not activities:
logging.warning('No activity can start object with type, %s.',
mime_type)
return None
return activities[0]
else:
bundle = bundleregistry.get_registry().get_bundle(bundle_id)
if bundle is None:
logging.warning('Activity with the bundle_id %s was not found',
mime_type)
return None
return bundle
开发者ID:AbrahmAB,项目名称:sugar,代码行数:27,代码来源:bundlelauncher.py
示例10: _image_file_from_metadata
def _image_file_from_metadata(self, image_path):
""" Load a pixbuf from a Journal object. """
try:
metadata = self._get_metadata()
if 'mime_type' in metadata and 'image' in metadata['mime_type']:
ds_object = datastore.get(metadata['uid'])
pixbuf = GdkPixbuf.Pixbuf.new_from_file(ds_object.file_path)
else:
pixbufloader = \
GdkPixbuf.PixbufLoader.new_with_mime_type('image/png')
pixbufloader.set_size(300, 225)
pixbufloader.write(metadata['preview'])
pixbuf = pixbufloader.get_pixbuf()
pixbufloader.close()
except Exception as ex:
logging.error("_image_file_from_metadata: %s" % (str(ex)))
return False
try:
pixbuf.savev(image_path, 'png', [], [])
logging.debug('_image_file_from_metadata: success %s' %
(image_path))
return True
except Exception as ex:
logging.error("_image_file_from_metadata: %s" % (str(ex)))
return False
开发者ID:walterbender,项目名称:facebook,代码行数:27,代码来源:account.py
示例11: _fb_comments_downloaded_cb
def _fb_comments_downloaded_cb(self, fb_photo, comments):
logging.debug('_fb_comments_downloaded_cb')
ds_object = datastore.get(self._metadata['uid'])
if not COMMENTS in ds_object.metadata:
ds_comments = []
else:
ds_comments = json.loads(ds_object.metadata[COMMENTS])
if not COMMENT_IDS in ds_object.metadata:
ds_comment_ids = []
else:
ds_comment_ids = json.loads(ds_object.metadata[COMMENT_IDS])
new_comment = False
for comment in comments:
if comment['id'] not in ds_comment_ids:
# TODO: get avatar icon and add it to icon_theme
ds_comments.append({'from': comment['from'],
'message': comment['message'],
'icon': 'facebook-share'})
ds_comment_ids.append(comment['id'])
new_comment = True
if new_comment:
ds_object.metadata[COMMENTS] = json.dumps(ds_comments)
ds_object.metadata[COMMENT_IDS] = json.dumps(ds_comment_ids)
self.emit('comments-changed', ds_object.metadata[COMMENTS])
datastore.write(ds_object, update_mtime=False)
开发者ID:tchx84,项目名称:facebook,代码行数:27,代码来源:account.py
示例12: _photo_created_cb
def _photo_created_cb(self, fb_photo, fb_object_id, tmp_file):
logging.debug("_photo_created_cb")
if os.path.exists(tmp_file):
os.unlink(tmp_file)
metadata = self._get_metadata()
comment = ''
if 'title' in metadata:
comment += '%s:' % str(metadata['title'])
if 'description' in metadata:
comment += str(metadata['description'])
fb_photo.connect('comment-added', self._comment_added_cb)
fb_photo.connect('comment-add-failed', self._comment_add_failed_cb)
fb_photo.add_comment(comment)
try:
ds_object = datastore.get(metadata['uid'])
ds_object.metadata['fb_object_id'] = fb_object_id
datastore.write(ds_object, update_mtime=False)
except Exception as ex:
logging.debug("_photo_created_cb failed to write to datastore: " %
str(ex))
开发者ID:walterbender,项目名称:facebook,代码行数:25,代码来源:account.py
示例13: load_file
def load_file(self, jobject, title=None):
if isinstance(jobject, datastore.RawObject):
logging.debug('Loading a datastore.RawObject')
file_path = mime_path = jobject.file_path
title = jobject.metadata['title']
elif isinstance(jobject, datastore.DSObject):
# This file is stored in the Journal (datastore)
logging.debug('Loading a datastore.DSObject')
file_path = 'journal://' + jobject.object_id
mime_path = datastore.get(jobject.object_id).file_path
title = jobject.metadata['title']
else:
logging.debug('Loading a %s', type(jobject))
file_path = mime_path = jobject
mimetype = mime.get_for_file('file://' + mime_path)
logging.info('read_file mime %s', mimetype)
if mimetype == 'audio/x-mpegurl':
# is a M3U playlist:
self._load_m3u_playlist(file_path)
else:
# is not a M3U playlist
self._load_stream(file_path, title)
missing_tracks = self._get_missing_tracks()
if len(missing_tracks) > 0:
logging.info('%s tracks not found', len(missing_tracks))
self.emit('missing-tracks', missing_tracks)
# set the focus in the first row
self._set_cursor(0)
开发者ID:cristian99garcia,项目名称:jukebox-activity,代码行数:31,代码来源:playlist.py
示例14: _comment_activate_cb
def _comment_activate_cb(self, entry):
text = entry.props.text
if not "comments" in self._reflection.data:
self._reflection.data["comments"] = []
data = {
"nick": profile.get_nick_name(),
"color": self._reflection.activity.fg_color.get_html(),
"comment": text,
}
self._reflection.data["comments"].append(data)
self.add_new_comment(data)
# Send the comment
if self._reflection.activity.sharing:
self._reflection.activity.send_event(
"%s|%s|%s|%s|%s"
% (COMMENT_CMD, self._reflection.data["obj_id"], data["nick"], data["color"], data["comment"])
)
entry.set_text("")
# Update journal entry
dsobj = datastore.get(self._reflection.data["obj_id"])
if "comments" in dsobj.metadata:
data = json.loads(dsobj.metadata["comments"])
else:
data = []
data.append({"from": profile.get_nick_name(), "message": text, "icon-color": profile.get_color().to_string()})
dsobj.metadata["comments"] = json.dumps(data)
datastore.write(
dsobj,
update_mtime=False,
reply_handler=self.datastore_write_cb,
error_handler=self.datastore_write_error_cb,
)
开发者ID:samdroid-apps,项目名称:reflect,代码行数:33,代码来源:reflectwindow.py
示例15: _get_data
def _get_data(self, metadata=None):
if not metadata:
metadata = self._get_metadata()
jobject = datastore.get(metadata['uid'])
path = str(jobject.file_path)
return path
开发者ID:i5o,项目名称:sugar-gdrive,代码行数:7,代码来源:account.py
示例16: insert_comment
def insert_comment(self, obj_id, comment):
for item in self._reflections:
if item.obj_id == obj_id:
item.graphics.add_new_comment(comment)
item.graphics.notify_button.show()
# Update journal entry
if obj_id[0:4] == "obj-":
break
try:
dsobj = datastore.get(obj_id)
except Exception as e:
logging.error("Could not open %s: %e" % (obj_id, e))
break
if "comments" in dsobj.metadata:
data = json.loads(dsobj.metadata["comments"])
else:
data = []
data.append(
{
"from": comment["nick"],
"message": comment["comment"],
"icon-color": "%s,%s" % (comment["color"], comment["color"]),
}
)
dsobj.metadata["comments"] = json.dumps(data)
datastore.write(
dsobj,
update_mtime=False,
reply_handler=self.datastore_write_cb,
error_handler=self.datastore_write_error_cb,
)
break
开发者ID:samdroid-apps,项目名称:reflect,代码行数:32,代码来源:reflectwindow.py
示例17: _setup_canvas
def _setup_canvas(self):
''' Create a canvas in a Gtk.Fixed '''
self.fixed = Gtk.Fixed()
self.fixed.connect('size-allocate', self._fixed_resize_cb)
self.fixed.show()
self.set_canvas(self.fixed)
self._vbox = Gtk.VBox(False, 0)
self._vbox.set_size_request(Gdk.Screen.width(), Gdk.Screen.height())
self.fixed.put(self._vbox, 0, 0)
self._vbox.show()
self._canvas = Gtk.DrawingArea()
self._canvas.set_size_request(int(Gdk.Screen.width()),
int(Gdk.Screen.height()))
self._canvas.show()
self.show_all()
self._vbox.pack_end(self._canvas, True, True, 0)
self._vbox.show()
self.show_all()
self.vmw = Game(self._canvas, parent=self, card_type=MODE)
self.vmw.level = self._play_level
LEVEL_BUTTONS[self._play_level].set_active(True)
self.vmw.card_type = self._card_type
self.vmw.robot = False
self.vmw.robot_time = self._robot_time
self.vmw.low_score = self._low_score
self.vmw.all_scores = self._all_scores
self.vmw.numberO = self._numberO
self.vmw.numberC = self._numberC
self.vmw.matches = self._matches
self.vmw.robot_matches = self._robot_matches
self.vmw.total_time = self._total_time
self.vmw.buddies = []
self.vmw.word_lists = self._word_lists
self.vmw.editing_word_list = self._editing_word_list
if hasattr(self, '_custom_object') and self._custom_object is not None:
self.vmw._find_custom_paths(datastore.get(self._custom_object))
for i in range(9):
if hasattr(self, '_custom_jobject') and \
self._custom_jobject[i] is not None:
self.vmw.custom_paths[i] = datastore.get(
self._custom_jobject[i])
self.button_custom.set_sensitive(True)
return self._canvas
开发者ID:sugarlabs,项目名称:dimensions,代码行数:47,代码来源:Dimensions.py
示例18: _status_updated_cb
def _status_updated_cb(self, status, data, tmp_file):
if os.path.exists(tmp_file):
os.unlink(tmp_file)
try:
ds_object = datastore.get(self._metadata['uid'])
ds_object.metadata['twr_object_id'] = status._status_id
datastore.write(ds_object, update_mtime=False)
except Exception as e:
logging.debug('_status_updated_cb failed to write: %s', str(e))
开发者ID:tchx84,项目名称:social-sugar,代码行数:9,代码来源:account.py
示例19: get_journal_entry_cover_image
def get_journal_entry_cover_image(self, object_id):
ds_object = datastore.get(object_id)
if 'cover_image' in ds_object.metadata:
cover_data = ds_object.metadata['cover_image']
return base64.b64decode(cover_data)
elif 'preview' in ds_object.metadata:
return ds_object.metadata['preview']
else:
return ""
开发者ID:leonardcj,项目名称:get-books-activity,代码行数:9,代码来源:GetIABooksActivity.py
示例20: get_media_from_datastore
def get_media_from_datastore(id):
media_object = None
try:
media_object = datastore.get(id)
except:
pass
return media_object
开发者ID:sugarlabs,项目名称:maps-activity,代码行数:9,代码来源:serialize.py
注:本文中的sugar3.datastore.datastore.get函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论