Update print_account to take an Account object
This commit is contained in:
parent
2c4f7e17c9
commit
dd16627c89
2 changed files with 21 additions and 18 deletions
|
@ -6,7 +6,7 @@ from datetime import datetime, timedelta, timezone
|
|||
from time import sleep, time
|
||||
from toot import api, config, __version__
|
||||
from toot.auth import login_interactive, login_browser_interactive, create_app_interactive
|
||||
from toot.entities import Instance, Notification, Status, from_dict
|
||||
from toot.entities import Account, Instance, Notification, Status, from_dict
|
||||
from toot.exceptions import ApiError, ConsoleError
|
||||
from toot.output import (print_lists, print_out, print_instance, print_account, print_acct_list,
|
||||
print_search_results, print_status, print_timeline, print_notifications, print_tag_list,
|
||||
|
@ -520,12 +520,13 @@ def whoami(app, user, args):
|
|||
if args.json:
|
||||
print(response.text)
|
||||
else:
|
||||
account = response.json()
|
||||
account = from_dict(Account, response.json())
|
||||
print_account(account)
|
||||
|
||||
|
||||
def whois(app, user, args):
|
||||
account = api.find_account(app, user, args.account)
|
||||
account = from_dict(Account, account)
|
||||
print_account(account)
|
||||
|
||||
|
||||
|
|
|
@ -5,8 +5,8 @@ import textwrap
|
|||
|
||||
from functools import lru_cache
|
||||
from toot import settings
|
||||
from toot.entities import Instance, Notification, Poll, Status
|
||||
from toot.utils import get_text, html_to_paragraphs
|
||||
from toot.entities import Account, Instance, Notification, Poll, Status
|
||||
from toot.wcstring import wc_wrap
|
||||
from typing import List
|
||||
from wcwidth import wcswidth
|
||||
|
@ -170,31 +170,33 @@ def print_instance(instance: Instance):
|
|||
print_out(f"Contact: {contact.display_name} @{contact.acct}")
|
||||
|
||||
|
||||
def print_account(account):
|
||||
print_out(f"<green>@{account['acct']}</green> {account['display_name']}")
|
||||
def print_account(account: Account):
|
||||
print_out(f"<green>@{account.acct}</green> {account.display_name}")
|
||||
|
||||
if account["note"]:
|
||||
if account.note:
|
||||
print_out("")
|
||||
print_html(account["note"])
|
||||
print_html(account.note)
|
||||
|
||||
since = account.created_at.strftime('%Y-%m-%d')
|
||||
|
||||
print_out("")
|
||||
print_out(f"ID: <green>{account['id']}</green>")
|
||||
print_out(f"Since: <green>{account['created_at'][:10]}</green>")
|
||||
print_out(f"ID: <green>{account.id}</green>")
|
||||
print_out(f"Since: <green>{since}</green>")
|
||||
print_out("")
|
||||
print_out(f"Followers: <yellow>{account['followers_count']}</yellow>")
|
||||
print_out(f"Following: <yellow>{account['following_count']}</yellow>")
|
||||
print_out(f"Statuses: <yellow>{account['statuses_count']}</yellow>")
|
||||
print_out(f"Followers: <yellow>{account.followers_count}</yellow>")
|
||||
print_out(f"Following: <yellow>{account.following_count}</yellow>")
|
||||
print_out(f"Statuses: <yellow>{account.statuses_count}</yellow>")
|
||||
|
||||
if account["fields"]:
|
||||
for field in account["fields"]:
|
||||
name = field["name"].title()
|
||||
if account.fields:
|
||||
for field in account.fields:
|
||||
name = field.name.title()
|
||||
print_out(f'\n<yellow>{name}</yellow>:')
|
||||
print_html(field["value"])
|
||||
if field["verified_at"]:
|
||||
print_html(field.value)
|
||||
if field.verified_at:
|
||||
print_out("<green>✓ Verified</green>")
|
||||
|
||||
print_out("")
|
||||
print_out(account["url"])
|
||||
print_out(account.url)
|
||||
|
||||
|
||||
HASHTAG_PATTERN = re.compile(r'(?<!\w)(#\w+)\b')
|
||||
|
|
Loading…
Reference in a new issue