• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python entities.get函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: _transition_state_to_expired

    def _transition_state_to_expired(cls, review_step_key):
        step = entities.get(review_step_key)

        if not step:
            COUNTER_EXPIRE_REVIEW_STEP_MISS.inc()
            raise KeyError(
                'No review step found with key %s' % repr(review_step_key))

        if step.removed:
            COUNTER_EXPIRE_REVIEW_CANNOT_TRANSITION.inc()
            raise domain.RemovedError(
                'Cannot transition step %s' % repr(review_step_key),
                step.removed)

        if step.state in (
                domain.REVIEW_STATE_COMPLETED, domain.REVIEW_STATE_EXPIRED):
            COUNTER_EXPIRE_REVIEW_CANNOT_TRANSITION.inc()
            raise domain.TransitionError(
                'Cannot transition step %s' % repr(review_step_key),
                step.state, domain.REVIEW_STATE_EXPIRED)

        summary = entities.get(step.review_summary_key)

        if not summary:
            COUNTER_EXPIRE_REVIEW_SUMMARY_MISS.inc()
            raise KeyError(
                'No review summary found with key %s' % repr(
                    step.review_summary_key))

        summary.decrement_count(step.state)
        step.state = domain.REVIEW_STATE_EXPIRED
        summary.increment_count(step.state)
        return entities.put([step, summary])[0]
开发者ID:UniMOOC,项目名称:gcb-new-module,代码行数:33,代码来源:review.py


示例2: get_reviews_by_keys

    def get_reviews_by_keys(cls, keys):
        """Gets reviews by their keys.

        Args:
            keys: [db.Key of review.Review]. Keys to fetch.

        Returns:
            [domain.Review or None]. Missed keys return None in place in result
            list.
        """
        return [cls._make_domain_review(model) for model in entities.get(keys)]
开发者ID:UniMOOC,项目名称:gcb-new-module,代码行数:11,代码来源:review.py


示例3: _mark_review_step_removed

    def _mark_review_step_removed(cls, review_step_key):
        step = entities.get(review_step_key)
        if not step:
            COUNTER_DELETE_REVIEWER_STEP_MISS.inc()
            raise KeyError(
                'No review step found with key %s' % repr(review_step_key))
        if step.removed:
            COUNTER_DELETE_REVIEWER_ALREADY_REMOVED.inc()
            raise domain.RemovedError(
                'Cannot remove step %s' % repr(review_step_key), step.removed)
        summary = entities.get(step.review_summary_key)

        if not summary:
            COUNTER_DELETE_REVIEWER_SUMMARY_MISS.inc()
            raise KeyError(
                'No review summary found with key %s' % repr(
                    step.review_summary_key))

        step.removed = True
        summary.decrement_count(step.state)
        return entities.put([step, summary])[0]
开发者ID:UniMOOC,项目名称:gcb-new-module,代码行数:21,代码来源:review.py


示例4: _add_reviewer_update_step

    def _add_reviewer_update_step(cls, step):
        should_increment_human = False
        should_increment_reassigned = False
        should_increment_unremoved = False
        summary = entities.get(step.review_summary_key)

        if not summary:
            COUNTER_ADD_REVIEWER_BAD_SUMMARY_KEY.inc()
            raise AssertionError(
                'Found invalid review summary key %s' % repr(
                    step.review_summary_key))

        if not step.removed:

            if step.state == domain.REVIEW_STATE_EXPIRED:
                should_increment_reassigned = True
                step.state = domain.REVIEW_STATE_ASSIGNED
                summary.decrement_count(domain.REVIEW_STATE_EXPIRED)
                summary.increment_count(domain.REVIEW_STATE_ASSIGNED)
            elif (step.state == domain.REVIEW_STATE_ASSIGNED or
                  step.state == domain.REVIEW_STATE_COMPLETED):
                COUNTER_ADD_REVIEWER_UNREMOVED_STEP_FAILED.inc()
                raise domain.TransitionError(
                    'Unable to add new reviewer to step %s' % (
                        repr(step.key())),
                    step.state, domain.REVIEW_STATE_ASSIGNED)
        else:
            should_increment_unremoved = True
            step.removed = False

            if step.state != domain.REVIEW_STATE_EXPIRED:
                summary.increment_count(step.state)
            else:
                should_increment_reassigned = True
                step.state = domain.REVIEW_STATE_ASSIGNED
                summary.decrement_count(domain.REVIEW_STATE_EXPIRED)
                summary.increment_count(domain.REVIEW_STATE_ASSIGNED)

        if step.assigner_kind != domain.ASSIGNER_KIND_HUMAN:
            should_increment_human = True
            step.assigner_kind = domain.ASSIGNER_KIND_HUMAN

        step_key = entities.put([step, summary])[0]

        if should_increment_human:
            COUNTER_ADD_REVIEWER_SET_ASSIGNER_KIND_HUMAN.inc()
        if should_increment_reassigned:
            COUNTER_ADD_REVIEWER_EXPIRED_STEP_REASSIGNED.inc()
        if should_increment_unremoved:
            COUNTER_ADD_REVIEWER_REMOVED_STEP_UNREMOVED.inc()

        return step_key
开发者ID:UniMOOC,项目名称:gcb-new-module,代码行数:52,代码来源:review.py


示例5: get_submission_and_review_step_keys

    def get_submission_and_review_step_keys(cls, unit_id, reviewee_key):
        """Gets the submission key/review step keys for the given pair.

        Note that keys for review steps marked removed are included in the
        result set.

        Args:
            unit_id: string. Id of the unit to restrict the query to.
            reviewee_key: db.Key of models.models.Student. The student who
                authored the submission.

        Raises:
            domain.ConstraintError: if multiple review summary keys were found
                for the given unit_id, reviewee_key pair.
            KeyError: if there is no review summary for the given unit_id,
                reviewee pair.

        Returns:
            (db.Key of Submission, [db.Key of peer.ReviewStep]) if submission
            found for given unit_id, reviewee_key pair; None otherwise.
        """
        COUNTER_GET_SUBMISSION_AND_REVIEW_STEP_KEYS_START.inc()

        try:
            submission_key = db.Key.from_path(
                student_work.Submission.kind(),
                student_work.Submission.key_name(unit_id, reviewee_key))
            submission = entities.get(submission_key)
            if not submission:
                COUNTER_GET_SUBMISSION_AND_REVIEW_STEP_KEYS_SUBMISSION_MISS.inc(
                    )
                return

            step_keys_query = peer.ReviewStep.all(
                keys_only=True
            ).filter(
                peer.ReviewStep.submission_key.name, submission_key
            )

            step_keys = step_keys_query.fetch(_REVIEW_STEP_QUERY_LIMIT)
            results = (submission_key, step_keys)

        except Exception as e:
            COUNTER_GET_SUBMISSION_AND_REVIEW_STEP_KEYS_FAILED.inc()
            raise e

        COUNTER_GET_SUBMISSION_AND_REVIEW_STEP_KEYS_SUCCESS.inc()
        COUNTER_GET_SUBMISSION_AND_REVIEW_STEP_KEYS_RETURNED.inc(
            increment=len(step_keys))
        return results
开发者ID:UniMOOC,项目名称:gcb-new-module,代码行数:50,代码来源:review.py


示例6: _attempt_review_assignment

    def _attempt_review_assignment(
        cls, review_summary_key, reviewer_key, last_change_date):
        COUNTER_GET_NEW_REVIEW_ASSIGNMENT_ATTEMPTED.inc()
        summary = entities.get(review_summary_key)
        if not summary:
            raise KeyError('No review summary found with key %s' % repr(
                review_summary_key))
        if summary.change_date != last_change_date:
            # The summary has changed since we queried it. We cannot know for
            # sure what the edit was, but let's skip to the next one because it
            # was probably a review assignment.
            COUNTER_GET_NEW_REVIEW_SUMMARY_CHANGED.inc()
            return

        step = peer.ReviewStep.get_by_key_name(
            peer.ReviewStep.key_name(summary.submission_key, reviewer_key))

        if not step:
            step = peer.ReviewStep(
                assigner_kind=domain.ASSIGNER_KIND_AUTO,
                review_summary_key=summary.key(),
                reviewee_key=summary.reviewee_key, reviewer_key=reviewer_key,
                state=domain.REVIEW_STATE_ASSIGNED,
                submission_key=summary.submission_key, unit_id=summary.unit_id)
        else:
            if step.state == domain.REVIEW_STATE_COMPLETED:
                # Reviewer has previously done this review and the review
                # has been deleted. Skip to the next one.
                COUNTER_GET_NEW_REVIEW_CANNOT_UNREMOVE_COMPLETED.inc()
                return

            if step.removed:
                # We can reassign the existing review step.
                COUNTER_GET_NEW_REVIEW_REASSIGN_EXISTING.inc()
                step.removed = False
                step.assigner_kind = domain.ASSIGNER_KIND_AUTO
                step.state = domain.REVIEW_STATE_ASSIGNED
            else:
                # Reviewee has already reviewed or is already assigned to review
                # this submission, so we cannot reassign the step.
                COUNTER_GET_NEW_REVIEW_ALREADY_ASSIGNED.inc()
                return

        summary.increment_count(domain.REVIEW_STATE_ASSIGNED)
        return entities.put([step, summary])[0]
开发者ID:UniMOOC,项目名称:gcb-new-module,代码行数:45,代码来源:review.py


示例7: _update_review_contents_and_change_state

    def _update_review_contents_and_change_state(
        cls, review_step_key, review_payload, mark_completed):
        should_increment_created_new_review = False
        should_increment_updated_existing_review = False
        should_increment_assigned_to_completed = False
        should_increment_expired_to_completed = False

        step = entities.get(review_step_key)
        if not step:
            COUNTER_WRITE_REVIEW_STEP_MISS.inc()
            raise KeyError(
                'No review step found with key %s' % repr(review_step_key))
        elif step.removed:
            raise domain.RemovedError(
                'Unable to process step %s' % repr(step.key()), step.removed)
        elif mark_completed and step.state == domain.REVIEW_STATE_COMPLETED:
            raise domain.TransitionError(
                'Unable to transition step %s' % repr(step.key()),
                step.state, domain.REVIEW_STATE_COMPLETED)

        if step.review_key:
            review_to_update = entities.get(step.review_key)
            if review_to_update:
                should_increment_updated_existing_review = True
        else:
            review_to_update = student_work.Review(
                contents=review_payload, reviewee_key=step.reviewee_key,
                reviewer_key=step.reviewer_key, unit_id=step.unit_id)
            step.review_key = db.Key.from_path(
                student_work.Review.kind(),
                student_work.Review.key_name(
                    step.unit_id, step.reviewee_key, step.reviewer_key))
            should_increment_created_new_review = True

        if not review_to_update:
            COUNTER_WRITE_REVIEW_REVIEW_MISS.inc()
            raise domain.ConstraintError(
                'No review found with key %s' % repr(step.review_key))

        summary = entities.get(step.review_summary_key)
        if not summary:
            COUNTER_WRITE_REVIEW_SUMMARY_MISS.inc()
            raise domain.ConstraintError(
                'No review summary found with key %s' % repr(
                    step.review_summary_key))

        review_to_update.contents = review_payload
        updated_step_key = None
        if not mark_completed:
            # pylint: disable=unbalanced-tuple-unpacking,unpacking-non-sequence
            _, updated_step_key = entities.put([review_to_update, step])
        else:
            if step.state == domain.REVIEW_STATE_ASSIGNED:
                should_increment_assigned_to_completed = True
            elif step.state == domain.REVIEW_STATE_EXPIRED:
                should_increment_expired_to_completed = True

            summary.decrement_count(step.state)
            step.state = domain.REVIEW_STATE_COMPLETED
            summary.increment_count(step.state)

            # pylint: disable=unbalanced-tuple-unpacking,unpacking-non-sequence
            _, updated_step_key, _ = entities.put(
                [review_to_update, step, summary])

        if should_increment_created_new_review:
            COUNTER_WRITE_REVIEW_CREATED_NEW_REVIEW.inc()
        elif should_increment_updated_existing_review:
            COUNTER_WRITE_REVIEW_UPDATED_EXISTING_REVIEW.inc()

        if should_increment_assigned_to_completed:
            COUNTER_WRITE_REVIEW_COMPLETED_ASSIGNED_STEP.inc()
        elif should_increment_expired_to_completed:
            COUNTER_WRITE_REVIEW_COMPLETED_EXPIRED_STEP.inc()

        return updated_step_key
开发者ID:UniMOOC,项目名称:gcb-new-module,代码行数:76,代码来源:review.py


示例8: OptionParser

        print "Visited links.....", visited
        print "Missing links.....", totalLinks-visited

if __name__ == '__main__':
    parser = OptionParser()
    parser.add_option("-r", "--request", dest="request_id")

    (options, args) = parser.parse_args()
    request_id = options.request_id

    from models import entities



    with db_session:
        request = entities.get(r for r in entities.WSRequest if r.request_id == request_id)

        print "id_proyecto:", request.id_proyecto
        print "nombre_directorio:", request.nombre_directorio

        # claves = entities.get(a for a in entities.Searchkeys_searchkey if a.request_id == request_id)
        searchkeys = Searchkeys_searchkey.select(lambda p: p.request_id == request_id)
        consulta = ""
        for searchKey in searchkeys:
            consulta = consulta + str(searchKey.clave) + " "

        consulta =  " ".join(filter(lambda x:x[0]!='-', consulta.split()))
        nombre_directorio = request.nombre_directorio
        # url_list tiene una lista de (orden, URL)
        url_list = request.urls.order_by(Url.orden)
开发者ID:luislezcair,项目名称:gisiaws,代码行数:30,代码来源:webMiner.py


示例9: getClassByName

def getClassByName(itemName):
    return entities.get(itemName)
开发者ID:EvgenyPopov72,项目名称:UdacityFullStack,代码行数:2,代码来源:controllers.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python event.Event类代码示例发布时间:2022-05-27
下一篇:
Python district_team.DistrictTeam类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap