wallabag_show.py 文件源码

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

项目:wallabag-cli 作者: Nepochal 项目源码 文件源码
def show(entry_id, colors=True, raw=False, html=False):
    """
    Main function for showing an entry.
    """
    conf.load()
    try:
        request = api.api_get_entry(entry_id)
        __handle_request_error(request)
        entr = entry.Entry(json.loads(request.response))
    except api.OAuthException as ex:
        print("Error: {0}".format(ex.text))
        print()
        exit(-1)

    title = entr.title

    try:
        delimiter = "".ljust(os.get_terminal_size().columns, '=')
    # piped output to file or other process
    except OSError:
        delimiter = "\n"

    article = entr.content
    if not html:
        article = html2text(article, colors)

    output = "{0}\n{1}\n{2}".format(title, delimiter, article)

    if not raw:
        output = __format_text(output)

    print(output)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号