AppStream.Validator

g AppStream.Validator AppStream.Validator GObject.Object GObject.Object GObject.Object->AppStream.Validator

Subclasses:

None

Methods

Inherited:

GObject.Object (37)

Structs:

GObject.ObjectClass (5)

class

new ()

add_override (tag, severity_override)

add_release_bytes (release_fname, release_metadata)

add_release_file (release_file)

check_success ()

clear_release_data ()

get_allow_net ()

get_issue_files_count ()

get_issues ()

get_issues_per_file ()

get_report_yaml ()

get_strict ()

get_tag_explanation (tag)

get_tag_severity (tag)

get_tags ()

set_allow_net (value)

set_strict (is_strict)

validate_bytes (metadata)

validate_data (metadata)

validate_file (metadata_file)

validate_tree (root_dir)

Virtual Methods

Inherited:

GObject.Object (7)

Properties

None

Signals

Inherited:

GObject.Object (1)

Fields

Inherited:

GObject.Object (1)

Name

Type

Access

Description

parent_instance

GObject.Object

r

Class Details

class AppStream.Validator(**kwargs)
Bases:

GObject.Object

Abstract:

No

Structure:

AppStream.ValidatorClass

classmethod new()
Returns:

an AppStream.Validator

Return type:

AppStream.Validator

Creates a new AppStream.Validator.

add_override(tag, severity_override)
Parameters:
  • tag (str) – the issue tag to override, e.g. “release-time-missing”

  • severity_override (AppStream.IssueSeverity) – the new severity for the tag.

Raises:

GLib.Error

Return type:

bool

Override the severity of a selected tag. For most tags, the severity can not be lowered to a value that makes a validation that would otherwise fail pass (so e.g. an ERROR can not become an INFO). Some tags are explicitly allowed to have their severity lowered to enable validation of e.g. incomplete metadata during development. Increasing the severity of any tag is always allowed.

New in version 0.15.4.

add_release_bytes(release_fname, release_metadata)
Parameters:
  • release_fname (str) – File basename of the release metadata file to add.

  • release_metadata (GLib.Bytes) – Data of the release metadata file.

Raises:

GLib.Error

Return type:

bool

Add release metadata explicitly from bytes.

New in version 0.16.0.

add_release_file(release_file)
Parameters:

release_file (Gio.File) – Release metadata file to add.

Raises:

GLib.Error

Return type:

bool

Add a release metadata file to the validation process.

New in version 0.16.0.

check_success()
Returns:

True if previously validated files were valid.

Return type:

bool

Check the current registered values again and return True if no issues were found that would make the previously validated files fail validation.

Usually you do not need to call this function explicitly, as the as_validator_validate_* functions will already return whether data was valid as return value.

clear_release_data()

Clear all release information that was explicitly added to the validation process.

New in version 0.16.0.

get_allow_net()
Returns:

True in case we allow network access.

Return type:

bool

get_issue_files_count()
Returns:

The number of files that have issues.

Return type:

int

Get the number of files for which issues have been found.

New in version 0.16.0.

get_issues()
Returns:

a list of AppStream.ValidatorIssue instances, free with g_list_free()

Return type:

[AppStream.ValidatorIssue]

Get a list of found metadata format issues.

get_issues_per_file()
Returns:

a file to issue list mapping

Return type:

{str: [AppStream.ValidatorIssue]}

Get a hash table of filenames mapped to lists of issues. This is useful if validation was requested for multiple files and a list of issues per-file is desired without prior explicit sorting.

New in version 0.12.8.

get_report_yaml()
Raises:

GLib.Error

Return type:

str

get_strict()
Returns:

True in case we are in strict mode and consider any issues as fatal.

Return type:

bool

New in version 0.15.4.

get_tag_explanation(tag)
Parameters:

tag (str) –

Returns:

Explanation text.

Return type:

str

Get the explanatory text for a given issue tag.

get_tag_severity(tag)
Parameters:

tag (str) –

Returns:

The AppStream.IssueSeverity

Return type:

AppStream.IssueSeverity

Get the severity for a given issue tag.

get_tags()
Returns:

A string array of tags

Return type:

[str]

Get an array of all tags known to the validator.

set_allow_net(value)
Parameters:

value (bool) – True if remote URLs should be checked for availability.

If set to True, the validator will be allowed to connect to the internet to e.g. check URLs for validity.

set_strict(is_strict)
Parameters:

is_strict (bool) – True to enable strict mode.

Enable or disable strict mode. In strict mode, any found issue will result in a failed validation (except for issues of “pedantic” severity). Otherwise, only a “warning” or “error” will cause the validation to fail.

New in version 0.15.4.

validate_bytes(metadata)
Parameters:

metadata (GLib.Bytes) – XML metadata as GLib.Bytes.

Returns:

True if bytes validated successfully.

Return type:

bool

Validate AppStream XML data from a byte array. Remember to run %as_validator_clear_issues if you do not want previous validation runs to affect the outcome of this validation.

New in version 0.14.0.

validate_data(metadata)
Parameters:

metadata (str) – XML metadata.

Returns:

True if data validated successfully.

Return type:

bool

Validate AppStream XML data.

validate_file(metadata_file)
Parameters:

metadata_file (Gio.File) – An AppStream XML file.

Returns:

True if file validated successfully.

Return type:

bool

Validate an AppStream XML file.

validate_tree(root_dir)
Parameters:

root_dir (str) – The root directory of the filesystem tree that should be validated.

Returns:

True if file validated successfully.

Return type:

bool

Validate a full directory tree for issues in AppStream metadata.