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


Python NamedGlobals.get方法代码示例

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


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

示例1: GET_index

# 需要导入模块: from r2.models.keyvalue import NamedGlobals [as 别名]
# 或者: from r2.models.keyvalue.NamedGlobals import get [as 别名]
 def GET_index(self):
     quote = self._get_quote()
     images = self._get_images()
     stats = NamedGlobals.get("about_reddit_stats", None)
     content = About(
         quote=quote,
         images=images,
         stats=stats,
         events=g.plugins["about"].timeline_data,
         sites=g.plugins["about"].sites_data,
     )
     return AboutPage("about-main", _("we power awesome communities."), _("about reddit"), content).render()
开发者ID:rram,项目名称:reddit-plugin-about,代码行数:14,代码来源:about.py

示例2: get_current_press

# 需要导入模块: from r2.models.keyvalue import NamedGlobals [as 别名]
# 或者: from r2.models.keyvalue.NamedGlobals import get [as 别名]
def get_current_press():
    key = _CURRENT_PRESS_KEY()
    val = g.thebuttoncache.get(key)
    if val is None:
        try:
            val = NamedGlobals.get(key)
        except NotFoundException:
            val = NONE
        g.thebuttoncache.set(key, val)

    if val == NONE:
        return None
    elif val:
        return _deserialize_datetime(val)
开发者ID:jakeclawson,项目名称:reddit-plugin-thebutton,代码行数:16,代码来源:models.py

示例3: GET_index

# 需要导入模块: from r2.models.keyvalue import NamedGlobals [as 别名]
# 或者: from r2.models.keyvalue.NamedGlobals import get [as 别名]
 def GET_index(self):
     quote = self._get_quote()
     images = self._get_images()
     stats = NamedGlobals.get('about_reddit_stats', None)
     c.js_preload.set('#images', images)
     content = About(
         quote=quote,
         images=images,
         stats=stats,
         events=g.plugins['about'].timeline_data,
         sites=g.plugins['about'].sites_data,
     )
     return AboutPage(
         content_id='about-main',
         title_msg=_('we power awesome communities.'),
         pagename=_('about reddit'),
         content=content,
     ).render()
开发者ID:GodOfConquest,项目名称:reddit-plugin-about,代码行数:20,代码来源:about.py

示例4: has_timer_expired

# 需要导入模块: from r2.models.keyvalue import NamedGlobals [as 别名]
# 或者: from r2.models.keyvalue.NamedGlobals import get [as 别名]
def has_timer_expired():
    # note: this only checks if the timer has been marked as expired, it doesn't
    # actually check its value (that's done in check_timer)
    key = _EXPIRED_KEY()
    val = g.thebuttoncache.get(key)
    if val is None:
        try:
            val = NamedGlobals.get(key)
        except NotFoundException:
            # has never been set, set the key
            val = False
            NamedGlobals.set(key, val)
        # update the cache
        g.thebuttoncache.set(key, val)

    if val:
        return _deserialize_datetime(val)

    return val
开发者ID:jakeclawson,项目名称:reddit-plugin-thebutton,代码行数:21,代码来源:models.py

示例5: health_check

# 需要导入模块: from r2.models.keyvalue import NamedGlobals [as 别名]
# 或者: from r2.models.keyvalue.NamedGlobals import get [as 别名]
def health_check():
    """Calculate the number of seconds since promotions were last updated"""
    return time.time() - int(NamedGlobals.get(PROMO_HEALTH_KEY, default=0))
开发者ID:AD42,项目名称:reddit,代码行数:5,代码来源:promote.py

示例6: get_trending_subreddits

# 需要导入模块: from r2.models.keyvalue import NamedGlobals [as 别名]
# 或者: from r2.models.keyvalue.NamedGlobals import get [as 别名]
def get_trending_subreddits():
    return NamedGlobals.get(TRENDING_SUBREDDITS_KEY, None)
开发者ID:0xcd03,项目名称:reddit,代码行数:4,代码来源:trending.py

示例7: health_check

# 需要导入模块: from r2.models.keyvalue import NamedGlobals [as 别名]
# 或者: from r2.models.keyvalue.NamedGlobals import get [as 别名]
def health_check():
    return NamedGlobals.get(PROMO_HEALTH_KEY, default=0)
开发者ID:chrisrote,项目名称:reddit,代码行数:4,代码来源:promote.py


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