adsfolio.pdf.files

Enumerate PDF files in a library directory.

adsfolio.pdf.files.iter_pdf_paths(directory, recursive)[source]

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.files.move_file_exclusive(source, destination)[source]

Move a file without replacing a destination created by another process.

Parameters:
  • source (Path) – Existing file entry to move.

  • destination (Path) – New path on the same filesystem. Its parent must already exist.

Returns:

Destination after the source entry is removed.

Return type:

Path

Raises:

OSError – Linking or removing a directory entry failed. An existing destination remains unchanged. If source removal fails, remove the new link.

adsfolio.pdf.files.sha256_file(path)[source]

Return the SHA-256 hex digest of a file, read in 1 MiB chunks.

Raises:

OSError – If the file cannot be opened or read, including FileNotFoundError when it no longer exists.

Parameters:

path (pathlib.Path)

Return type:

str