chore: reformat with black
This commit is contained in:
parent
b33da2a881
commit
8bfc4a5900
@ -11,6 +11,7 @@ ProcessId = NewType("ProcessId", int)
|
|||||||
@dataclass
|
@dataclass
|
||||||
class _Reference:
|
class _Reference:
|
||||||
"""Reference to a location within a file."""
|
"""Reference to a location within a file."""
|
||||||
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
@ -64,6 +65,7 @@ PDFReference = Union[PDFPage, PDFSection]
|
|||||||
# replace this with an union if that happens
|
# replace this with an union if that happens
|
||||||
Reference = PDFReference
|
Reference = PDFReference
|
||||||
|
|
||||||
|
|
||||||
# PyMuPDF type
|
# PyMuPDF type
|
||||||
@dataclass
|
@dataclass
|
||||||
class FitzBookmark:
|
class FitzBookmark:
|
||||||
|
@ -4,6 +4,7 @@ from datatypes import PDFPage, PDFSection, PDFReference, Reference
|
|||||||
from typing import assert_never
|
from typing import assert_never
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
|
|
||||||
def format_pdf_link(ref: PDFReference) -> str:
|
def format_pdf_link(ref: PDFReference) -> str:
|
||||||
path_str = environ.get("TYPST_ROOT", None)
|
path_str = environ.get("TYPST_ROOT", None)
|
||||||
if path_str is None:
|
if path_str is None:
|
||||||
@ -31,10 +32,13 @@ def format_pdf_link(ref: PDFReference) -> str:
|
|||||||
assert_never(obj)
|
assert_never(obj)
|
||||||
|
|
||||||
if relative:
|
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:
|
else:
|
||||||
return f'#link("pdfref://{format_path}?{urlencode(params)}")[{default_label}]'
|
return f'#link("pdfref://{format_path}?{urlencode(params)}")[{default_label}]'
|
||||||
|
|
||||||
|
|
||||||
def ref(ref: Reference) -> str:
|
def ref(ref: Reference) -> str:
|
||||||
"""Formats a Reference."""
|
"""Formats a Reference."""
|
||||||
|
|
||||||
|
14
util.py
14
util.py
@ -3,6 +3,7 @@ import pydbus
|
|||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class RofiResult:
|
class RofiResult:
|
||||||
"""Data returned from Rofi.
|
"""Data returned from Rofi.
|
||||||
@ -18,12 +19,15 @@ class RofiResult:
|
|||||||
custom_bind
|
custom_bind
|
||||||
ID of custom bind used to select entry. None if no custom bind was used.
|
ID of custom bind used to select entry. None if no custom bind was used.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
index: Optional[int]
|
index: Optional[int]
|
||||||
value: str
|
value: str
|
||||||
custom_bind: Optional[int]
|
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.
|
"""Start a Rofi prompt.
|
||||||
|
|
||||||
Returns
|
Returns
|
||||||
@ -39,8 +43,10 @@ def rofi(entries: list[str], prompt: str="> ", fuzzy=True, extra_args=[]) -> Opt
|
|||||||
args += extra_args
|
args += extra_args
|
||||||
|
|
||||||
ret = RofiResult(None, "", None)
|
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:
|
match res.returncode:
|
||||||
case 0:
|
case 0:
|
||||||
pass
|
pass
|
||||||
@ -59,7 +65,7 @@ def rofi(entries: list[str], prompt: str="> ", fuzzy=True, extra_args=[]) -> Opt
|
|||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
|
||||||
def notify(title:str, txt: str) -> None:
|
def notify(title: str, txt: str) -> None:
|
||||||
"""Send a text notification."""
|
"""Send a text notification."""
|
||||||
bus = pydbus.SessionBus()
|
bus = pydbus.SessionBus()
|
||||||
notifs = bus.get(".Notifications")
|
notifs = bus.get(".Notifications")
|
||||||
|
Loading…
Reference in New Issue
Block a user