adsfolio.pdf.cli_common

Shared helpers for pdf CLI commands.

adsfolio.pdf.cli_common.get_client(ctx)[source]
Parameters:

ctx (click.core.Context)

Return type:

adsfolio.client.ADSClient

adsfolio.pdf.cli_common.handle_unresolved(pdf_path, output_dir, apply, report=True, label='unresolved')[source]
Parameters:
Return type:

pathlib.Path

adsfolio.pdf.cli_common.is_resolved_record(record)[source]

Return whether a registry record contains a successful ADS match.

Parameters:

record (dict[str, object])

Return type:

bool

adsfolio.pdf.cli_common.iter_pdf_paths(directory, recursive)

Yield PDF files under directory, matching the suffix case-insensitively.

A symbolic link is yielded only if its target is a regular file. Symbolic links to directories are ignored and never entered, and dangling links are not yielded. Paths are not resolved.

Parameters:
  • directory (Path) – Directory to scan.

  • recursive (bool) – Also scan subdirectories.

Yields:

Path – Path of each PDF, built from directory.

Raises:

OSError – If directory or any subdirectory cannot be listed, or an entry’s type cannot be determined (for example, permission denied). Callers must treat the error as an incomplete scan and must not conclude from it that unseen files are missing.

Return type:

collections.abc.Iterator[pathlib.Path]

Notes

os.DirEntry.is_dir() and is_file() return False when the entry no longer exists, so a file removed mid-scan is silently not yielded. Other OSError values propagate.

adsfolio.pdf.cli_common.unique_destination(output_dir, filename)[source]
Parameters:
Return type:

pathlib.Path

adsfolio.pdf.cli_common.validate_author_format(_, __, value)[source]
Parameters:
Return type:

str

adsfolio.pdf.cli_common.validate_char_policy(_, __, value)[source]
Parameters:
Return type:

str