mirror of
https://github.com/ihabunek/toot.git
synced 2024-12-04 14:46:33 -05:00
Tweak timeline output
This commit is contained in:
parent
3f79b76aab
commit
b3d81c43cc
@ -109,7 +109,8 @@ def test_timeline(mock_get, monkeypatch, capsys):
|
||||
|
||||
out, err = capsys.readouterr()
|
||||
assert "The computer can't tell you the emotional story." in out
|
||||
assert "Frank Zappa @fz" in out
|
||||
assert "Frank Zappa" in out
|
||||
assert "@fz" in out
|
||||
|
||||
|
||||
@mock.patch('toot.http.post')
|
||||
|
@ -124,16 +124,18 @@ def print_timeline(items):
|
||||
return chain(*[wrapper.wrap(l) for l in text.split("\n")])
|
||||
|
||||
def timeline_rows(item):
|
||||
name = item['name']
|
||||
display_name = item['account']['display_name']
|
||||
username = "@" + item['account']['username']
|
||||
time = item['time'].strftime('%Y-%m-%d %H:%M%Z')
|
||||
|
||||
left_column = [name, time]
|
||||
if 'reblogged' in item:
|
||||
left_column.append(item['reblogged'])
|
||||
left_column = [display_name]
|
||||
if display_name != username:
|
||||
left_column.append(username)
|
||||
left_column.append(time)
|
||||
if item['reblogged']:
|
||||
left_column.append("Reblogged @{}".format(item['reblogged']))
|
||||
|
||||
text = item['text']
|
||||
|
||||
right_column = wrap_text(text, 80)
|
||||
right_column = wrap_text(item['text'], 80)
|
||||
|
||||
return zip_longest(left_column, right_column, fillvalue="")
|
||||
|
||||
@ -142,15 +144,14 @@ def print_timeline(items):
|
||||
|
||||
def _parse_item(item):
|
||||
content = item['reblog']['content'] if item['reblog'] else item['content']
|
||||
reblogged = item['reblog']['account']['username'] if item['reblog'] else ""
|
||||
reblogged = item['reblog']['account']['username'] if item['reblog'] else None
|
||||
|
||||
name = item['account']['display_name'] + " @" + item['account']['username']
|
||||
soup = BeautifulSoup(content, "html.parser")
|
||||
text = soup.get_text().replace(''', "'")
|
||||
time = datetime.strptime(item['created_at'], "%Y-%m-%dT%H:%M:%S.%fZ")
|
||||
|
||||
return {
|
||||
"name": name,
|
||||
"account": item['account'],
|
||||
"text": text,
|
||||
"time": time,
|
||||
"reblogged": reblogged,
|
||||
|
Loading…
Reference in New Issue
Block a user