inventory_views.py 文件源码

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

项目:optf2 作者: Lagg 项目源码 文件源码
def GET(self, app, user, iid):
        markup.init_theme(app)

        try:
            user, items = models.load_inventory(user, scope = app)
        except steam.api.HTTPError as E:
            raise web.NotFound(template.errors.generic("Couldn't connect to Steam (HTTP {0})".format(E)))
        except steam.user.ProfileError as E:
            raise web.NotFound(template.errors.generic("Can't retrieve user profile data: {0}".format(E)))
        except steam.items.InventoryError as E:
            raise web.NotFound(template.errors.generic("Couldn't open backpack: {0}".format(E)))

        item = None
        try:
            item = items["items"][iid]
        except KeyError:
            for cid, bpitem in items["items"].iteritems():
                oid = bpitem.get("oid")
                if oid == long(iid):
                    item = bpitem
                    break
            if not item:
                raise web.NotFound(template.item_error_notfound(iid))

        if web.input().get("contents"):
            contents = item.get("contents")
            if contents:
                item = contents

        # Strip off quality prefix for possessive name
        itemname = item["mainname"]
        if itemname.startswith("The "):
            item["ownedname"] = itemname[4:]
        else:
            item["ownedname"] = itemname

        return template.item(app, user, item)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号