miscs
This commit is contained in:
1 parent
0d8970061e
commit
c30aac0572
14 files changed
+343
-48
No files matched your search
@@ -41,9 +41,13 @@ PAGE_SPLITTER_KB = {
|
||||
# Conversion factor: 1 cm to points (1 inch = 2.54 cm, 72 points = 1 inch)
|
||||
CM_TO_POINTS = (1 / 2.54) * 72
|
||||
|
||||
def list_pdf_files(directory: str | Path) -> list[Path]:
|
||||
def list_pdf_files(
|
||||
directory: str | Path, workspace: EvaluationWorkspace | None = None,
|
||||
) -> list[Path]:
|
||||
workspace = workspace or EvaluationWorkspace(Path(directory))
|
||||
paths = sorted(Path(directory).glob("*.pdf"), key=lambda path: path.name.casefold())
|
||||
return [path for path in paths if "enonce" not in path.name.casefold()]
|
||||
return [path for path in paths if "enonce" not in path.name.casefold()
|
||||
and not workspace.is_statement_pdf(workspace.root / path.name)]
|
||||
|
||||
|
||||
def _temporary_sibling(path: Path, purpose: str) -> Path:
|
||||
@@ -177,7 +181,7 @@ class PDFPreviewer:
|
||||
f"'{fmt('rotate_page')}': Rotate page 180°, '{fmt('rotate_all_pages')}' : rotate all pages, '{fmt('rotate_all_files')}' : rotate all files\n"
|
||||
f"{fmt('keep_left')} {fmt('next_page')} {fmt('discard_page')} {fmt('keep_right')} {fmt('keep_as_is')}: keep left, next page, keep none, keep right, keep as is\n"
|
||||
f"{fmt('send_end')}: send page to end, '{fmt('arranger')}': pdf arranger, '{fmt('restart_file')}': restart file, '{fmt('prev_file')}': previous file\n"
|
||||
f"{fmt('add_secondary_splitter')}: add secondary line, {fmt('delete_secondary_splitter')}: delete newest (arrows move newest; orange = active)\n"
|
||||
f"{fmt('add_secondary_splitter')}: add secondary line, {fmt('delete_secondary_splitter')}: delete newest (arrows move newest; main line red, active secondary orange)\n"
|
||||
f"'{fmt('reverse_pages')}': reverse page order and restart from the new first page\n"
|
||||
)
|
||||
|
||||
@@ -302,7 +306,7 @@ class PDFPreviewer:
|
||||
# The line position is scaled by the same zoom factor
|
||||
line_x_scaled = self.current_line_x * self.current_zoom
|
||||
draw.line([(line_x_scaled, 0), (line_x_scaled, pix.height)],
|
||||
fill="red" if self.secondary_splitters else "orange", width=3)
|
||||
fill="red", width=3)
|
||||
for index, position in enumerate(self.secondary_splitters):
|
||||
x = position * self.current_zoom
|
||||
active = index == len(self.secondary_splitters) - 1
|
||||
@@ -664,12 +668,14 @@ def _selected_inputs(
|
||||
if target.is_file():
|
||||
if target.suffix.casefold() != ".pdf":
|
||||
raise CliError(f"Target is not a PDF: {target}", ExitCode.INVALID_ARGUMENTS)
|
||||
if workspace.is_statement_pdf(workspace.root / target.name):
|
||||
raise CliError(f"Target is the statement PDF, not a copy: {target}", ExitCode.INVALID_ARGUMENTS)
|
||||
backup = workspace.original_copies_dir / target.name
|
||||
return [backup if backup.is_file() else target]
|
||||
|
||||
directory = target
|
||||
if target == workspace.copies_dir:
|
||||
candidates = list_pdf_files(workspace.copies_dir)
|
||||
candidates = list_pdf_files(workspace.copies_dir, workspace)
|
||||
candidates = [
|
||||
(
|
||||
workspace.original_copies_dir / path.name
|
||||
@@ -679,7 +685,7 @@ def _selected_inputs(
|
||||
for path in candidates
|
||||
]
|
||||
else:
|
||||
candidates = list_pdf_files(directory)
|
||||
candidates = list_pdf_files(directory, workspace)
|
||||
return list(reversed(candidates))
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user