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