chore: reformat with black
This commit is contained in:
parent
b33da2a881
commit
8bfc4a5900
@ -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:
|
||||
|
@ -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."""
|
||||
|
||||
|
12
util.py
12
util.py
@ -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
|
||||
@ -40,7 +44,9 @@ def rofi(entries: list[str], prompt: str="> ", fuzzy=True, extra_args=[]) -> Opt
|
||||
|
||||
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")
|
||||
|
Loading…
Reference in New Issue
Block a user