# SPDX-FileCopyrightText: 2022 James R. Barlow # SPDX-License-Identifier: CC0-1.0 from __future__ import annotations import os import xml.etree.ElementTree as ET from pathlib import Path from subprocess import PIPE, STDOUT, run from typing import Optional import pytest from pikepdf import Pdf VERAPDF: Path | None = None try: VERAPDF = Path(os.environ['HOME']) / 'verapdf' / 'verapdf' if not VERAPDF.is_file(): VERAPDF = None except Exception: # pylint: disable=broad-except pass def verapdf_validate(filename) -> bool: assert VERAPDF is not None proc = run([VERAPDF, filename], stdout=PIPE, stderr=STDOUT, check=True) result = proc.stdout.decode('utf-8') xml_start = result.find('