misc.py 文件源码

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

项目:librarian 作者: HERA-Team 项目源码 文件源码
def inject_globals():
    import datetime
    import dateutil.tz
    import pytz

    utc = datetime.datetime.now(tz=pytz.utc)
    sa_tz = pytz.timezone('Africa/Johannesburg')
    sa = utc.astimezone(sa_tz)
    local_tz = dateutil.tz.tzlocal()
    local = utc.astimezone(local_tz)

    cti = utc.strftime('%Y-%m-%d %H:%M') + ' (UTC) • ' + sa.strftime('%H:%M (%Z)')

    if local.tzname() not in ('UTC', sa.tzname()):
        cti += ' • ' + local.strftime('%H:%M (%Z)')

    vi = 'Librarian %s (%s)' % (app.config['_version_string'], app.config['_git_hash'])

    lds_info = app.config.get('local_disk_staging')
    if lds_info is not None:
        staging_available = True
        staging_dest_displayed = lds_info['displayed_dest']
        staging_dest_path = lds_info['dest_prefix']
        staging_username_placeholder = lds_info['username_placeholder']
    else:
        staging_available = False
        staging_dest_displayed = None
        staging_dest_path = None
        staging_username_placeholder = None

    return {
        'current_time_info': cti,
        'version_info': vi,
        'staging_available': staging_available,
        'staging_dest_displayed': staging_dest_displayed,
        'staging_dest_path': staging_dest_path,
        'staging_username_placeholder': staging_username_placeholder,
    }


# JSON API
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号