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


Python DatabaseHandler.getStats方法代码示例

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


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

示例1: formatCardData

# 需要导入模块: import DatabaseHandler [as 别名]
# 或者: from DatabaseHandler import getStats [as 别名]
def formatCardData(card, isExpanded):
    if isExpanded:
        requestStats = DatabaseHandler.getStats(card['name'])
        
        if card['cardtype'].lower() == 'monster':
            return MONSTER_CARD_TEMPLATE_EXPANDED.format(
                name = '[**{}**]'.format(card['name']),
                image = '({})'.format(card['image']) if card['image'] else '(http://i.imgur.com/paNkvJ5.jpg)',
                wikia = '[Wikia]({})'.format(card['wikia']),
                infosyntax = ', ' if card['pricedata'] else '',
                pricedata = '[($)]({})'.format(card['pricedata']) if card['pricedata'] else '',
                leveltype = '{}: '.format(card['leveltype']),
                level = '{}, '.format(card['level']),
                cardtype = 'Category: {}, '.format(card['cardtype'].title()),
                types = 'Type: {}, '.format(' / '.join(str(i[1]) for i in enumerate(card['types']))),
                attribute = 'Attribute: {}'.format(card['attribute'].upper()),
                text = '>{}'.format(card['text']),
                att = '>ATK: {}, '.format(card['att']),
                defn = 'DEF: {}'.format(card['def']),
                stats = 'Stats: {total} requests - {percentage}% of all requests'.format(
                    total=requestStats['total'],
                    percentage=str(round(requestStats['totalAsPercentage'],2))))
        else:
            return SPELL_CARD_TEMPLATE_EXPANDED.format(
                name = '[**{}**]'.format(card['name']),
                image = '({})'.format(card['image']) if card['image'] else '(http://i.imgur.com/paNkvJ5.jpg)',
                wikia = '[Wikia]({})'.format(card['wikia']),
                infosyntax = ', ' if card['pricedata'] else '',
                pricedata = '[($)]({})'.format(card['pricedata']) if card['pricedata'] else '',
                cardtype = 'Category: {}, '.format(card['cardtype'].title()),
                cardproperty = 'Property: {}'.format(card['property']),
                text = '>{}'.format(card['text']),
                stats = 'Stats: {total} requests - {percentage}% of all requests'.format(
                    total=requestStats['total'],
                    percentage=str(round(requestStats['totalAsPercentage'],2))))
    else:
        if card['cardtype'].lower() == 'monster':
            return MONSTER_CARD_TEMPLATE_NORMAL.format(
                name = '[**{}**]'.format(card['name']),
                image = '({})'.format(card['image']) if card['image'] else '(http://i.imgur.com/paNkvJ5.jpg)',
                wikia = '[Wikia]({})'.format(card['wikia']),
                infosyntax = ', ' if card['pricedata'] else '',
                pricedata = '[($)]({})'.format(card['pricedata']) if card['pricedata'] else '')
        else:
            return SPELL_CARD_TEMPLATE_NORMAL.format(
                name = '[**{}**]'.format(card['name']),
                image = '({})'.format(card['image']) if card['image'] else '(http://i.imgur.com/paNkvJ5.jpg)',
                wikia = '[Wikia]({})'.format(card['wikia']),
                infosyntax = ', ' if card['pricedata'] else '',
                pricedata = '[($)]({})'.format(card['pricedata']) if card['pricedata'] else '')
开发者ID:Nihilate,项目名称:YugiohLinkBot,代码行数:52,代码来源:CommentBuilder.py


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