From 1cdc99bf7d41ed9523b52f18c6f81c61cf0c6d5a Mon Sep 17 00:00:00 2001 From: nepochal Date: Wed, 9 Nov 2016 10:06:34 +0100 Subject: [PATCH] Fixed another issue with piping output --- wallabag/wallabag_show.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/wallabag/wallabag_show.py b/wallabag/wallabag_show.py index 4df6075..988cfaf 100755 --- a/wallabag/wallabag_show.py +++ b/wallabag/wallabag_show.py @@ -6,6 +6,7 @@ import json import os from sys import exit +import sys from bs4 import BeautifulSoup import api import conf @@ -27,11 +28,13 @@ def show(entry_id, colors=True, raw=False, html=False): 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) @@ -96,7 +99,12 @@ def html2text(html, colors=True): def __format_text(text): - maxcol = os.get_terminal_size().columns + try: + maxcol = os.get_terminal_size().columns + # piped output to file or other process + except OSError: + maxcol = sys.maxsize + ret = "" for line in text.splitlines():