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


Python FirebasePusher.pushMatch方法代码示例

本文整理汇总了Python中helpers.firebase.firebase_pusher.FirebasePusher.pushMatch方法的典型用法代码示例。如果您正苦于以下问题:Python FirebasePusher.pushMatch方法的具体用法?Python FirebasePusher.pushMatch怎么用?Python FirebasePusher.pushMatch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在helpers.firebase.firebase_pusher.FirebasePusher的用法示例。


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

示例1: updateMerge

# 需要导入模块: from helpers.firebase.firebase_pusher import FirebasePusher [as 别名]
# 或者: from helpers.firebase.firebase_pusher.FirebasePusher import pushMatch [as 别名]
    def updateMerge(self, new_match, old_match):
        """
        Given an "old" and a "new" Match object, replace the fields in the
        "old" team that are present in the "new" team, but keep fields from
        the "old" team that are null in the "new" team.
        """
        immutable_attrs = [
            "comp_level",
            "event",
            "set_number",
            "match_number",
        ] # These build key_name, and cannot be changed without deleting the model.

        attrs = [
            "alliances_json",
            "game",
            "no_auto_update",
            "time",
            "time_string",
        ]

        list_attrs = [
            "team_key_names",
            "tba_videos",
            "youtube_videos"
        ]

        push_match = not old_match.has_been_played and new_match.has_been_played

        for attr in attrs:
            if getattr(new_match, attr) is not None:
                if getattr(new_match, attr) != getattr(old_match, attr):
                    setattr(old_match, attr, getattr(new_match, attr))
                    if attr == 'alliances_json':
                        # Necessary since 'alliances' doesn't get changed
                        # when mutating 'alliances_json'
                        old_match.clearAlliances()
                    old_match.dirty = True

        for attr in list_attrs:
            if len(getattr(new_match, attr)) > 0:
                if getattr(new_match, attr) != getattr(old_match, attr):
                    setattr(new_match, attr, getattr(new_match, attr))
                    old_match.dirty = True
                    
        if push_match:
            try:
                FirebasePusher.pushMatch(old_match)
            except:
                logging.warning("Enqueuing Firebase push failed!")
        return old_match
开发者ID:germy,项目名称:the-blue-alliance,代码行数:53,代码来源:match_manipulator.py


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