当前位置: 首页>>代码示例>>Python>>正文


Python datastore.find函数代码示例

本文整理汇总了Python中sugar3.datastore.datastore.find函数的典型用法代码示例。如果您正苦于以下问题:Python find函数的具体用法?Python find怎么用?Python find使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了find函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _resume_activity

    def _resume_activity(self, text, pattern, name, day):
        logging.warning('Voice command: %s' % text)
        logging.warning('Activity: %s' % name)
        logging.warning('Day: %s' % day)

        properties = ['uid', 'title', 'icon-color', 'activity', 'activity_id',
                      'mime_type', 'mountpoint', 'timestamp']

        timestamp = None
        t = date.today()

        if not _(day) == _('journal'):
            if _(day) == _('yesterday'):
                delta = -1
            else:
                delta = abs(t.weekday() - _WEEK_DAYS.index(_(day))) - 7

            d = t + timedelta(days=delta)
            n = d + timedelta(days=1)
            start = time.mktime(d.timetuple())
            end = time.mktime(n.timetuple())
            timestamp = {'start': start, 'end':end}

        query = {}
        if name:
            query['activity'] = _NAME_TO_ID.get(_(name))
        if timestamp:
            query['timestamp'] = timestamp

        datastore.find(query, sorting=['+timestamp'],
                   limit=1,
                   properties=properties,
                   reply_handler=self.__get_last_activity_reply_handler_cb,
                   error_handler=self.__get_last_activity_error_handler_cb)
开发者ID:rparrapy,项目名称:listen-trailicon,代码行数:34,代码来源:listen.py

示例2: _get_last_activity_async

 def _get_last_activity_async(self, bundle_id, properties):
     query = {'activity': bundle_id}
     datastore.find(query, sorting=['+timestamp'],
                    limit=self._MAX_RESUME_ENTRIES,
                    properties=properties,
                    reply_handler=self.__get_last_activity_reply_handler_cb,
                    error_handler=self.__get_last_activity_error_handler_cb)
开发者ID:salil93,项目名称:sugar,代码行数:7,代码来源:favoritesview.py

示例3: get_entry_info_format

    def get_entry_info_format(self, query, mime):
        books = []
        if query is not None and len(query) > 0:
            ds_objects, num_objects = datastore.find(
                    {'mime_type': '%s' % mime,
                    'query': '*%s*' % query})
        else:
            ds_objects, num_objects = datastore.find(
                    {'mime_type': '%s' % mime})

        logging.error('Local search %d books found %s format', num_objects,
                    mime)
        for i in range(0, num_objects):
            entry = {}
            entry['title'] = ds_objects[i].metadata['title']
            entry['mime'] = ds_objects[i].metadata['mime_type']
            entry['object_id'] = ds_objects[i].object_id

            if 'author' in ds_objects[i].metadata:
                entry['author'] = ds_objects[i].metadata['author']
            else:
                entry['author'] = ''

            if 'publisher' in ds_objects[i].metadata:
                entry['dcterms_publisher'] = \
                    ds_objects[i].metadata['publisher']
            else:
                entry['dcterms_publisher'] = ''

            if 'language' in ds_objects[i].metadata:
                entry['dcterms_language'] = \
                    ds_objects[i].metadata['language']
            else:
                entry['dcterms_language'] = ''

            if 'source' in ds_objects[i].metadata:
                entry['source'] = \
                    ds_objects[i].metadata['source']
            else:
                entry['source'] = ''

            if entry['source'] in _SOURCES_CONFIG:
                repo_configuration = _SOURCES_CONFIG[entry['source']]
                summary_field = repo_configuration['summary_field']
                if 'summary' in ds_objects[i].metadata:
                    entry[summary_field] = ds_objects[i].metadata['summary']
                else:
                    entry[summary_field] = ''
            else:
                repo_configuration = None
            books.append(opds.Book(repo_configuration, entry, ''))
        return books
开发者ID:leonardcj,项目名称:get-books-activity,代码行数:52,代码来源:GetIABooksActivity.py

示例4: run_activity

    def run_activity(self, bundle_id, resume_mode):
        if not resume_mode:
            registry = bundleregistry.get_registry()
            bundle = registry.get_bundle(bundle_id)
            misc.launch(bundle)
            return

        self._activity_selected = bundle_id
        query = {'activity': bundle_id}
        properties = ['uid', 'title', 'icon-color', 'activity', 'activity_id',
                      'mime_type', 'mountpoint']
        datastore.find(query, sorting=['+timestamp'],
                       limit=1, properties=properties,
                       reply_handler=self.__get_last_activity_reply_handler_cb,
                       error_handler=self.__get_last_activity_error_handler_cb)
开发者ID:AxEofBone7,项目名称:sugar,代码行数:15,代码来源:activitieslist.py

示例5: get_rtf

def get_rtf():
    dsobjects, nobjects = datastore.find({'mime_type': ['text/rtf',
                                                        'application/rtf']})
    paths = []
    for dsobject in dsobjects:
        paths.append(dsobject.file_path)
    return paths
开发者ID:walterbender,项目名称:OneSupport,代码行数:7,代码来源:utils.py

示例6: get_image

def get_image():
    paths = []
    dsobjects, nobjects = datastore.find({'mime_type': ['image/png',
                                                        'image/jpeg']})
    for dsobject in dsobjects:
        paths.append(dsobject.file_path)
    return paths
开发者ID:walterbender,项目名称:OneSupport,代码行数:7,代码来源:utils.py

示例7: _find_starred

 def _find_starred(self):
     ''' Find all the _stars in the Journal. '''
     self.dsobjects, self._nobjects = datastore.find({'keep': '1'})
     for dsobj in self.dsobjects:
         if self._found_obj_id(dsobj.object_id):
             continue  # Already have this object -- TODO: update it
         self._add_new_from_journal(dsobj)
开发者ID:AbrahmAB,项目名称:reflect,代码行数:7,代码来源:activity.py

示例8: get_odt

def get_odt():
    dsobjects, nobjects = datastore.find(
        {'mime_type':
         ['application/vnd.oasis.opendocument.text']})
    paths = []
    for dsobject in dsobjects:
        paths.append(dsobject.file_path)
    return paths
开发者ID:walterbender,项目名称:OneSupport,代码行数:8,代码来源:utils.py

示例9: publish

def publish(activity, force=False):
    if not [i for i in book.custom.index if i['ready']]:
        alert = NotifyAlert(5)
        alert.props.title = _('Nothing to publish')
        alert.props.msg = _('Mark arcticles from "Custom" '
                            'panel and try again.')
        alert.connect('response', __alert_notify_response_cb, activity)
        activity.add_alert(alert)
        alert.show()
        return

    title = activity.metadata['title']
    jobject = datastore.find({
            'activity_id': activity.get_id(),
            'activity'   : book.custom.uid})[0] or None

    logger.debug('publish: title=%s jobject=%s force=%s' \
            % (title, jobject and jobject[0].metadata['activity'], force))

    if jobject:
        if force:
            jobject = jobject[0]
        else:
            alert = ConfirmationAlert()
            alert.props.title = _('Overwrite existed bundle?')
            alert.props.msg = _('A bundle for current object was already created. '
                                'Click "OK" to overwrite it.')
            alert.connect('response', __alert_response_cb, activity, True)
            activity.add_alert(alert)
            alert.show()
            jobject[0].destroy()
            return
    else:
        jobject = datastore.create()
        jobject.metadata['activity_id'] = activity.get_id()
        jobject.metadata['activity'] = book.custom.uid
        jobject.metadata['mime_type'] = 'application/vnd.olpc-content'
        jobject.metadata['description'] = \
                'This is a bundle containing articles on %s.\n' \
                'To view these articles, open the \'Browse\' Activity.\n' \
                'Go to \'Books\', and select \'%s\'.' % (title, title)

    book.custom.sync_article()
    book.custom.revision += 1

    jobject.metadata['title'] = title
    _publish(title, jobject)
    jobject.destroy()

    book.custom.sync_index()

    alert = NotifyAlert()
    alert.props.title = _('Book published to your Journal')
    alert.props.msg = _('You can read the book in Browse or '
                        'access the .xol file from your Journal')
    alert.connect('response', __alert_notify_response_cb, activity)
    activity.add_alert(alert)
    alert.show()
开发者ID:iamutkarshtiwari,项目名称:infoslicer,代码行数:58,代码来源:xol.py

示例10: _activities

 def _activities(self):
     activities = {}
     entries, count = datastore.find(self._query())
     for entry in entries:
         activity_id = entry.metadata.get('activity', '')
         if activity_id not in activities:
             activities[activity_id] = []
         activities[activity_id].append(self._instance(entry))
     return activities
开发者ID:manuq,项目名称:harvest-client,代码行数:9,代码来源:crop.py

示例11: get_most_recent_instance

def get_most_recent_instance(bundle_id):
    dsobjects, nobjects = datastore.find({'activity': [bundle_id]})
    most_recent_time = -1
    most_recent_instance = None
    for activity in dsobjects:
        last_launch_time = get_last_launch_time(activity)
        if last_launch_time > most_recent_time:
            most_recent_time = get_last_launch_time(activity)
            most_recent_instance = activity
    return most_recent_instance
开发者ID:walterbender,项目名称:OneSupport,代码行数:10,代码来源:utils.py

示例12: __init__

    def __init__(self, bundle, handle):
        """Initialise the handler

        bundle -- the ActivityBundle to launch
        activity_handle -- stores the values which are to
            be passed to the service to uniquely identify
            the activity to be created and the sharing
            service that may or may not be connected with it

            sugar3.activity.activityhandle.ActivityHandle instance

        calls the "create" method on the service for this
        particular activity type and registers the
        _reply_handler and _error_handler methods on that
        call's results.

        The specific service which creates new instances of this
        particular type of activity is created during the activity
        registration process in shell bundle registry which creates
        service definition files for each registered bundle type.

        If the file '/etc/olpc-security' exists, then activity launching
        will be delegated to the prototype 'Rainbow' security service.
        """
        GObject.GObject.__init__(self)

        self._bundle = bundle
        self._service_name = bundle.get_bundle_id()
        self._handle = handle

        bus = dbus.SessionBus()
        bus_object = bus.get_object(_SHELL_SERVICE, _SHELL_PATH)
        self._shell = dbus.Interface(bus_object, _SHELL_IFACE)

        if handle.activity_id is not None and handle.object_id is None:
            datastore.find({'activity_id': self._handle.activity_id},
                           reply_handler=self._find_object_reply_handler,
                           error_handler=self._find_object_error_handler)
        else:
            self._launch_activity()
开发者ID:AbrahmAB,项目名称:sugar-toolkit-gtk3-proto,代码行数:40,代码来源:activityfactory.py

示例13: load_journal_table

    def load_journal_table(self):
        self.btn_save.props.sensitive = False
        self.btn_delete.props.sensitive = False
        query = {}
        ds_objects, num_objects = datastore.find(query, properties=['uid', 
            'title',  'mime_type'])

        self.ls_journal.clear()
        for i in xrange (0, num_objects, 1):
            iter = self.ls_journal.append()
            title = ds_objects[i].metadata['title']
            self.ls_journal.set(iter, COLUMN_TITLE, title)
            mime = ds_objects[i].metadata['mime_type']
            self.ls_journal.set(iter, COLUMN_MIME, mime)
            self.ls_journal.set(iter, COLUMN_JOBJECT, ds_objects[i])
            size = self.get_size(ds_objects[i]) / 1024
            self.ls_journal.set(iter, COLUMN_SIZE, size)

        v_adjustment = self.list_scroller_journal.get_vadjustment()
        v_adjustment.value = 0
开发者ID:leonardcj,项目名称:sugar-commander,代码行数:20,代码来源:sugarcommander.py

示例14: get_audio

def get_audio():
    paths = []
    dsobjects, nobjects = datastore.find({'mime_type': ['audio/ogg']})
    for dsobject in dsobjects:
        paths.append(dsobject.file_path)
    return paths
开发者ID:walterbender,项目名称:OneSupport,代码行数:6,代码来源:utils.py

示例15: get_activity

def get_activity(bundle_id):
    dsobjects, nobjects = datastore.find({'activity': [bundle_id]})
    return dsobjects
开发者ID:walterbender,项目名称:OneSupport,代码行数:3,代码来源:utils.py


注:本文中的sugar3.datastore.datastore.find函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。