Add YAPF style + ignore, and format tracked Python files
This commit is contained in:
@@ -9,7 +9,6 @@ from SYS.logger import log
|
||||
from result_table import ResultTable
|
||||
import pipeline as ctx
|
||||
|
||||
|
||||
_TELEGRAM_PENDING_ITEMS_KEY = "telegram_pending_items"
|
||||
|
||||
|
||||
@@ -101,6 +100,7 @@ def _extract_title(item: Any) -> str:
|
||||
|
||||
|
||||
def _extract_file_path(item: Any) -> Optional[str]:
|
||||
|
||||
def _maybe(value: Any) -> Optional[str]:
|
||||
if value is None:
|
||||
return None
|
||||
@@ -194,13 +194,18 @@ def _run(_result: Any, args: Sequence[str], config: Dict[str, Any]) -> int:
|
||||
pass
|
||||
try:
|
||||
chat_usernames = list(
|
||||
dict.fromkeys([str(u).strip() for u in chat_usernames if str(u).strip()])
|
||||
dict.fromkeys(
|
||||
[str(u).strip() for u in chat_usernames if str(u).strip()]
|
||||
)
|
||||
)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
if not chat_ids and not chat_usernames:
|
||||
log("No Telegram chat selected (use @N on the Telegram table)", file=sys.stderr)
|
||||
log(
|
||||
"No Telegram chat selected (use @N on the Telegram table)",
|
||||
file=sys.stderr
|
||||
)
|
||||
return 1
|
||||
|
||||
pending_items = ctx.load_value(_TELEGRAM_PENDING_ITEMS_KEY, default=[])
|
||||
@@ -221,7 +226,10 @@ def _run(_result: Any, args: Sequence[str], config: Dict[str, Any]) -> int:
|
||||
)
|
||||
continue
|
||||
title = _extract_title(item)
|
||||
file_jobs.append({"path": p, "title": title})
|
||||
file_jobs.append({
|
||||
"path": p,
|
||||
"title": title
|
||||
})
|
||||
|
||||
# De-dupe file paths (preserve order).
|
||||
try:
|
||||
@@ -242,7 +250,9 @@ def _run(_result: Any, args: Sequence[str], config: Dict[str, Any]) -> int:
|
||||
|
||||
try:
|
||||
provider.send_files_to_chats(
|
||||
chat_ids=chat_ids, usernames=chat_usernames, files=file_jobs
|
||||
chat_ids=chat_ids,
|
||||
usernames=chat_usernames,
|
||||
files=file_jobs
|
||||
)
|
||||
except Exception as exc:
|
||||
log(f"Telegram send failed: {exc}", file=sys.stderr)
|
||||
@@ -276,7 +286,8 @@ def _run(_result: Any, args: Sequence[str], config: Dict[str, Any]) -> int:
|
||||
# Only show dialogs you can typically post to.
|
||||
try:
|
||||
rows = [
|
||||
r for r in (rows or []) if str(r.get("type") or "").strip().lower() in {"group", "user"}
|
||||
r for r in (rows or [])
|
||||
if str(r.get("type") or "").strip().lower() in {"group", "user"}
|
||||
]
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
Reference in New Issue
Block a user