mirror of
https://github.com/Ascyii/typstar.git
synced 2026-01-01 05:24:24 -05:00
style: format python code using ruff
This commit is contained in:
@@ -31,7 +31,11 @@ class TypstCompiler:
|
||||
def __init__(self, typst_root_dir: Path, typst_cmd: str):
|
||||
self.typst_cmd = typst_cmd
|
||||
self.typst_root_dir = typst_root_dir
|
||||
self.max_processes = round(os.cpu_count() * 1.5)
|
||||
n_cpus = os.cpu_count()
|
||||
if n_cpus is None:
|
||||
self.max_processes = 10
|
||||
else:
|
||||
self.max_processes = round(1.5 * n_cpus)
|
||||
|
||||
async def _compile(self, src: str, directory: Path) -> bytes:
|
||||
tmp_path = f"{directory}/tmp_{random.randint(1, 1000000000)}.typ"
|
||||
@@ -50,8 +54,12 @@ class TypstCompiler:
|
||||
|
||||
async def _compile_flashcard(self, card: Flashcard):
|
||||
preamble = default_preamble if card.preamble is None else card.preamble
|
||||
front = await self._compile(preamble + "\n" + card.as_typst(True), card.file_handler.directory_path)
|
||||
back = await self._compile(preamble + "\n" + card.as_typst(False), card.file_handler.directory_path)
|
||||
front = await self._compile(
|
||||
preamble + "\n" + card.as_typst(True), card.file_handler.directory_path
|
||||
)
|
||||
back = await self._compile(
|
||||
preamble + "\n" + card.as_typst(False), card.file_handler.directory_path
|
||||
)
|
||||
card.set_svgs(front, back)
|
||||
|
||||
async def compile_flashcards(self, cards: List[Flashcard]):
|
||||
@@ -62,7 +70,9 @@ class TypstCompiler:
|
||||
async with semaphore:
|
||||
return await self._compile_flashcard(card)
|
||||
|
||||
results = await asyncio.gather(*(compile_coro(card) for card in cards), return_exceptions=True)
|
||||
results = await asyncio.gather(
|
||||
*(compile_coro(card) for card in cards), return_exceptions=True
|
||||
)
|
||||
for result in results:
|
||||
if isinstance(result, Exception):
|
||||
raise result
|
||||
|
||||
Reference in New Issue
Block a user