chore: reformat with black

This commit is contained in:
dogeystamp 2023-07-23 20:02:36 -04:00
parent b33da2a881
commit 8bfc4a5900
Signed by: dogeystamp
GPG Key ID: 7225FE3592EFFA38
3 changed files with 17 additions and 5 deletions

View File

@ -11,6 +11,7 @@ ProcessId = NewType("ProcessId", int)
@dataclass
class _Reference:
"""Reference to a location within a file."""
pass
@ -64,6 +65,7 @@ PDFReference = Union[PDFPage, PDFSection]
# replace this with an union if that happens
Reference = PDFReference
# PyMuPDF type
@dataclass
class FitzBookmark:

View File

@ -4,6 +4,7 @@ from datatypes import PDFPage, PDFSection, PDFReference, Reference
from typing import assert_never
from pathlib import Path
def format_pdf_link(ref: PDFReference) -> str:
path_str = environ.get("TYPST_ROOT", None)
if path_str is None:
@ -31,10 +32,13 @@ def format_pdf_link(ref: PDFReference) -> str:
assert_never(obj)
if relative:
return f'#lref("{format_path}?{urlencode(params)}", pdfref: true)[{default_label}]'
return (
f'#lref("{format_path}?{urlencode(params)}", pdfref: true)[{default_label}]'
)
else:
return f'#link("pdfref://{format_path}?{urlencode(params)}")[{default_label}]'
def ref(ref: Reference) -> str:
"""Formats a Reference."""

14
util.py
View File

@ -3,6 +3,7 @@ import pydbus
from dataclasses import dataclass
from typing import Optional
@dataclass
class RofiResult:
"""Data returned from Rofi.
@ -18,12 +19,15 @@ class RofiResult:
custom_bind
ID of custom bind used to select entry. None if no custom bind was used.
"""
index: Optional[int]
value: str
custom_bind: Optional[int]
def rofi(entries: list[str], prompt: str="> ", fuzzy=True, extra_args=[]) -> Optional[RofiResult]:
def rofi(
entries: list[str], prompt: str = "> ", fuzzy=True, extra_args=[]
) -> Optional[RofiResult]:
"""Start a Rofi prompt.
Returns
@ -39,8 +43,10 @@ def rofi(entries: list[str], prompt: str="> ", fuzzy=True, extra_args=[]) -> Opt
args += extra_args
ret = RofiResult(None, "", None)
res = subprocess.run(args, input="\0".join(entries), stdout=subprocess.PIPE, text=True)
res = subprocess.run(
args, input="\0".join(entries), stdout=subprocess.PIPE, text=True
)
match res.returncode:
case 0:
pass
@ -59,7 +65,7 @@ def rofi(entries: list[str], prompt: str="> ", fuzzy=True, extra_args=[]) -> Opt
return ret
def notify(title:str, txt: str) -> None:
def notify(title: str, txt: str) -> None:
"""Send a text notification."""
bus = pydbus.SessionBus()
notifs = bus.get(".Notifications")