reporting_daily.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:garage-door 作者: denniskline 项目源码 文件源码
def combine_histories_and_messages(histories, smsMessages):
    cmdSuccessStyle = 'class="commandSuccess"'
    cmdErrorStyle = 'class="commandError"'
    basicStyle = ''

    from_zone = tz.tzutc()
    to_zone = tz.tzlocal()

    combinedList = []
    for history in histories:
        combinedList.append({"action": history.get('state'), "timestamp": history.get('changedAt'), "style": basicStyle})
    for smsMessage in smsMessages:
        style = cmdSuccessStyle if smsMessage.get('status').lower() == 'processed' else cmdErrorStyle
        createdAt = smsMessage.get('createdAt').replace(tzinfo=from_zone)
        combinedList.append({"action": smsMessage.get('body').lower(), "timestamp": createdAt.astimezone(to_zone), "style": style})

    combinedList.sort(key=lambda c: c.get("timestamp"))
    return combinedList
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号