dcclib_cli ¶
adapters ¶
adapt_schematron_result ¶
adapt_schematron_result(
result: SchematronValidationResult, filename: str, elapsed_seconds: float = 0.0
) -> ValidationResultData
Convert SchematronValidationResult to generic ValidationResultData.
For Schematron, the 'test' attribute is a stable XPath expression from the schema and serves as the check id. The same test can fail at multiple locations in the document; these are grouped by id in the JUnit formatter.
adapt_xsd_result ¶
adapt_xsd_result(result: XsdValidationResult, filename: str, elapsed_seconds: float = 0.0) -> ValidationResultData
Convert XsdValidationResult to generic ValidationResultData.
For XSD, each error type (type_name) is used as the stable check id. Multiple errors of the same type are grouped by id in the JUnit formatter.
file_adapter ¶
validation_adapter ¶
adapt_schematron_result ¶
adapt_schematron_result(
result: SchematronValidationResult, filename: str, elapsed_seconds: float = 0.0
) -> ValidationResultData
Convert SchematronValidationResult to generic ValidationResultData.
For Schematron, the 'test' attribute is a stable XPath expression from the schema and serves as the check id. The same test can fail at multiple locations in the document; these are grouped by id in the JUnit formatter.
adapt_xsd_result ¶
adapt_xsd_result(result: XsdValidationResult, filename: str, elapsed_seconds: float = 0.0) -> ValidationResultData
Convert XsdValidationResult to generic ValidationResultData.
For XSD, each error type (type_name) is used as the stable check id. Multiple errors of the same type are grouped by id in the JUnit formatter.
decorators ¶
with_formatter ¶
with_formatter(formats: list[str] | None = None)
Decorator to add --format/-f option and inject formatter into Click context.
This decorator adds a --format option to commands and creates a formatter instance based on the user's choice. The formatter is stored in ctx.obj for the command to use.
Args: formats: List of allowed format strings (e.g. ["plain", "table", "json"]). If None, defaults to ["plain", "table", "json"]. Validation commands should explicitly include "junit".
Usage: @click.command() @with_formatter(formats=["plain", "table", "json", "junit"]) @click.pass_context def my_command(ctx, ...): formatter = ctx.obj['formatter'] result = do_work() output = formatter.format(result) click.echo(output)
output ¶
with_formatter ¶
with_formatter(formats: list[str] | None = None)
Decorator to add --format/-f option and inject formatter into Click context.
This decorator adds a --format option to commands and creates a formatter instance based on the user's choice. The formatter is stored in ctx.obj for the command to use.
Args: formats: List of allowed format strings (e.g. ["plain", "table", "json"]). If None, defaults to ["plain", "table", "json"]. Validation commands should explicitly include "junit".
Usage: @click.command() @with_formatter(formats=["plain", "table", "json", "junit"]) @click.pass_context def my_command(ctx, ...): formatter = ctx.obj['formatter'] result = do_work() output = formatter.format(result) click.echo(output)
formatters ¶
BaseFormatter ¶
Bases: ABC
Base class for output formatters with generic dispatch.
format_combined_validation ¶
format_combined_validation(data: CombinedValidationData) -> str
Format combined validation results – default: format each result separately.
format_formula_evaluation
abstractmethod
¶
format_formula_evaluation(data: FormulaEvaluationData) -> str
Format formula evaluation data.
format_signature_verification
abstractmethod
¶
format_signature_verification(data: SignatureVerificationData) -> str
Format signature verification data.
format_validation
abstractmethod
¶
format_validation(data: ValidationResultData) -> str
Format validation results.
JUnitXMLFormatter ¶
Bases: BaseFormatter
JUnit XML formatter compatible with GitLab CI test reports.
GitLab parses the following fields (all others are ignored or optional): testsuites.time → total execution time testsuite.name → internal grouping label testsuite.time → suite execution time testcase.classname → displayed as the suite name in the GitLab UI testcase.name → individual test name (stable check id) testcase.file → file path testcase.time → test execution time in seconds failure / error → element TEXT CONTENT shown as message/stack trace system-out → additional output (not used here)
One
When the same check fails at multiple document locations, all locations are
consolidated in the
JsonFormatter ¶
PlainTextFormatter ¶
Bases: BaseFormatter
Plain text formatter without colors or tables.
format_combined_validation ¶
format_combined_validation(data: CombinedValidationData) -> str
Format combined validation results – default: format each result separately.
format_signature_verification ¶
format_signature_verification(data: SignatureVerificationData) -> str
Format signature verification results as plain text.
format_validation ¶
format_validation(data: ValidationResultData) -> str
Format validation results as plain text.
TableFormatter ¶
Bases: BaseFormatter
Table formatter with colors using Rich.
get_formatter ¶
get_formatter(format_type: OutputFormat) -> BaseFormatter
Factory function to get formatter instance.
base ¶
BaseFormatter ¶
Bases: ABC
Base class for output formatters with generic dispatch.
format_combined_validation ¶
format_combined_validation(data: CombinedValidationData) -> str
Format combined validation results – default: format each result separately.
format_formula_evaluation
abstractmethod
¶
format_formula_evaluation(data: FormulaEvaluationData) -> str
Format formula evaluation data.
format_signature_verification
abstractmethod
¶
format_signature_verification(data: SignatureVerificationData) -> str
Format signature verification data.
format_validation
abstractmethod
¶
format_validation(data: ValidationResultData) -> str
Format validation results.
json ¶
CustomEncoder ¶
Bases: json.JSONEncoder
Custom JSON encoder to handle types like datetime.
JsonFormatter ¶
junit ¶
JUnitXMLFormatter ¶
Bases: BaseFormatter
JUnit XML formatter compatible with GitLab CI test reports.
GitLab parses the following fields (all others are ignored or optional): testsuites.time → total execution time testsuite.name → internal grouping label testsuite.time → suite execution time testcase.classname → displayed as the suite name in the GitLab UI testcase.name → individual test name (stable check id) testcase.file → file path testcase.time → test execution time in seconds failure / error → element TEXT CONTENT shown as message/stack trace system-out → additional output (not used here)
One
When the same check fails at multiple document locations, all locations are
consolidated in the
plain ¶
PlainTextFormatter ¶
Bases: BaseFormatter
Plain text formatter without colors or tables.
format_combined_validation ¶
format_combined_validation(data: CombinedValidationData) -> str
Format combined validation results – default: format each result separately.
format_signature_verification ¶
format_signature_verification(data: SignatureVerificationData) -> str
Format signature verification results as plain text.
format_validation ¶
format_validation(data: ValidationResultData) -> str
Format validation results as plain text.
table ¶
TableFormatter ¶
Bases: BaseFormatter
Table formatter with colors using Rich.
models ¶
CombinedValidationData
dataclass
¶
CombinedValidationData(filename: str, results: list[ValidationResultData])
FormulaCallResult
dataclass
¶
FormulaCallResult(formula: str, inputs: dict[str, Quantity], output: Quantity)
A single evaluation of a formula with its concrete inputs and output.
OutputData
dataclass
¶
OutputData()
Bases: ABC
Base class for all output data structures.
accept
abstractmethod
¶
accept(formatter: Any) -> str
Accepts a formatter to implement double-dispatch formatting.
Quantity
dataclass
¶
Quantity(values: list[Any], unit: str | None = None, uncertainties: list[float] | None = None)
Machine-readable representation of a (possibly unit-aware) value.
SignatureVerificationData
dataclass
¶
SignatureVerificationData(
subject: str,
issuer: str,
validity_start: datetime,
validity_end: datetime,
serial_number: int,
signature_algorithm: str,
)
TableData
dataclass
¶
TableData(columns: list[str], rows: list[dict[str, Any]], title: str | None = None)
ValidationIssue
dataclass
¶
ValidationIssue(id: str, message: str, severity: str, location: dict = dict(), metadata: dict = dict())
Base class for validation issues (errors, warnings, info).
ValidationResultData
dataclass
¶
ValidationResultData(
is_valid: bool,
validation_type: str,
filename: str,
issues: list[ValidationIssue],
passed_checks: list[ValidationIssue] = list(),
elapsed_seconds: float = 0.0,
)
formula_data ¶
FormulaCallResult
dataclass
¶
FormulaCallResult(formula: str, inputs: dict[str, Quantity], output: Quantity)
A single evaluation of a formula with its concrete inputs and output.
Quantity
dataclass
¶
Quantity(values: list[Any], unit: str | None = None, uncertainties: list[float] | None = None)
Machine-readable representation of a (possibly unit-aware) value.
output_data ¶
signature_data ¶
SignatureVerificationData
dataclass
¶
SignatureVerificationData(
subject: str,
issuer: str,
validity_start: datetime,
validity_end: datetime,
serial_number: int,
signature_algorithm: str,
)
table_data ¶
TableData
dataclass
¶
TableData(columns: list[str], rows: list[dict[str, Any]], title: str | None = None)
validation_data ¶
CombinedValidationData
dataclass
¶
CombinedValidationData(filename: str, results: list[ValidationResultData])
ValidationResultData
dataclass
¶
ValidationResultData(
is_valid: bool,
validation_type: str,
filename: str,
issues: list[ValidationIssue],
passed_checks: list[ValidationIssue] = list(),
elapsed_seconds: float = 0.0,
)