onixcheck¶
-
onixcheck.
validate
(infile, schemas=(u'xsd', ))[source]¶ Validate an ONIX file.
Parameters: - infile (file or str) – File or path to file
- schemas (collections.Iterable[str]) – Iterable with paths to custom valdation profiles
Returns: List of Message objects (invalid ONIX) or empty list (valid ONIX)
Return type: list[Message]
-
class
onixcheck.models.
Message
[source]¶ A Validation message representing a single error condition.
Parameters: - level (str) – Error level
- validator (str) – The validator that raised the error
- location (str) – Location of error (filename:line:column)
- message (str) – Description of the error condiction
- error_type (str) – Type of error
-
classmethod
from_exception
(exc, filename=u'')[source]¶ Parameters: - exc (Exception) –
- filename (str) – Optional filename to prefix error location
Return Message:
-
classmethod
from_logentry
(logentry, filename=u'')[source]¶ Instanciate Message from lxml LogEntry object
Parameters: - logentry (_LogEntry) – Validatation error from LXML
- filename (str) – Optional filename to prefix error location
Return Message:
-
short
¶ Short string representation of message
-
class
onixcheck.models.
OnixFile
(infile)[source]¶ Convenience file object wrapper.
Parameters: infile (file or str) – File or path to file
-
class
onixcheck.models.
OnixMeta
[source]¶ Read and detect minimal ONIX file properties needed for validation.
Onix XML files may or may not have release and xmlns attributes on their root element. OnixMeta.from_file(infile) will detect Onix Version and Style and also patch the root element with the appropriate namespace needed for validation.
Parameters: - xml_version (str) – XML Version as str (“1.0”).
- xml_encoding (str) – XML Encoding as str (“utf-8”).
- onix_version (str) – Onix Version as string (“2.1” or “3.0”)
- onix_style (str) – Onix Style as str (“short” or “reference”)
- namespaces (dict) – dict of str with namspaces from the root element
-
onixcheck.utils.
iter_files
(root, exts=None, recursive=False)[source]¶ Iterate over file paths within root filtered by specified extensions.
Parameters: - root (str) – Root folder to start collecting files
- exts (iterable) – Restrict results to given file extensions
- recursive (bool) – Wether to walk the complete directory tree
Rtype collections.Iterable[str]: absolute file paths with given extensions