Component

class appstream_python.Component.InternetRelationDict

the type for the content of the Internet attribute

value: Literal['alwaysoffline-onlyfirst-run']
bandwidth_mbitps: Optional[int]
class appstream_python.Component.TranslateableTag

Represents a translatable tag

get_default_text() str

Returns the untranslated text

Return type

str

set_default_text(text: str) None

Sets the untranslated text

Parameters

text (str) –

Return type

None

get_translated_text(lang: str) Optional[str]

Returns the translated text

Parameters

lang (str) –

Return type

Optional[str]

get_translated_text_default(lang: str) Optional[str]

Returns the translated text. Returns the default text, if the translation does not exists

Parameters

lang (str) –

Return type

Optional[str]

set_translated_text(lang: str, text: str) None

Sets the translated text

Parameters
  • lang (str) –

  • text (str) –

Return type

None

get_available_languages() list[str]

Returns a list with all languages of the tag

Return type

list[str]

load_tags(tag_list: list[lxml.etree.Element]) None

Load a list of Tags

Parameters

tag_list (list[lxml.etree.Element]) –

Return type

None

write_tags(parent_tag: Element, tag_name: str) None

Writes a Tag

Parameters
  • parent_tag (Element) –

  • tag_name (str) –

Return type

None

clear() None

Resets all data

Return type

None

class appstream_python.Component.TranslateableList

Represents a translatable list

get_default_list() list[str]

Returns a list with the default items

Return type

list[str]

get_translated_list(lang: str) list[str]

Returns the translated list for the given language

Parameters

lang (str) –

Return type

list[str]

load_tag(tag: Element) None

Loads an Tag. Only for internal use.

Parameters

tag (Element) –

Return type

None

write_all_tag(parent_tag: Element, tag_name: str) None

Writes the XML tags. Onnly for internal use.

Parameters
  • parent_tag (Element) –

  • tag_name (str) –

Return type

None

write_untranslated_tags(parent_tag: Element, tag_name: str) None

Writes the untranslated XML tags. Onnly for internal use.

Parameters
  • parent_tag (Element) –

  • tag_name (str) –

Return type

None

write_translated_tags(parent_tag: Element, tag_name: str, lang: str) None

Writes the translated XML tags. Onnly for internal use.

Parameters
  • parent_tag (Element) –

  • tag_name (str) –

  • lang (str) –

Return type

None

clear() None

Resets all data

Return type

None

class appstream_python.Component.DescriptionItem

The Interface for a Description Item

get_type() Literal['paragraph', 'unordered-list', 'ordered-list']

Retutns the Type of the Item

Return type

Literal[‘paragraph’, ‘unordered-list’, ‘ordered-list’]

load_tags(tag_list: list[lxml.etree.Element]) None

Loads teh XML tags into the Elemnt. Only for internal use.

Parameters

tag_list (list[lxml.etree.Element]) –

Return type

None

get_tags(parent_tag: Element) None

Get the XML Tag from the Element. Only for internal use.

Parameters

parent_tag (Element) –

Return type

None

get_translated_tag(lang: Optional[str]) Element

Loads the tag for a given language

Parameters

lang (Optional[str]) –

Return type

Element

to_plain_text(lang: Optional[str] = None) str

Returns the content as plain text

Parameters

lang (Optional[str]) –

Return type

str

class appstream_python.Component.DescriptionParagraph

Represents a paragraph <p> in the Description

content

The Text of the Paragraph

get_type() Literal['paragraph', 'unordered-list', 'ordered-list']

Retutns the Type of the Item

Return type

Literal[‘paragraph’, ‘unordered-list’, ‘ordered-list’]

load_tags(tag_list: list[lxml.etree.Element]) None

Loads teh XML tags into the Elemnt. Only for internal use.

Parameters

tag_list (list[lxml.etree.Element]) –

Return type

None

get_tags(parent_tag: Element) None

Get the XML Tag from the Element. Only for internal use.

Parameters

parent_tag (Element) –

Return type

None

get_translated_tag(lang: Optional[str]) Element

Loads the tag for a given language

Parameters

lang (Optional[str]) –

Return type

Element

to_plain_text(lang: Optional[str] = None) str

Returns the content as plain text

Parameters

lang (Optional[str]) –

Return type

str

class appstream_python.Component.DescriptionList(list_type: str)

Represents a list <ul>/<ol> in the Description

Parameters

list_type (str) –

content: TranslateableList

The list

get_type() Literal['paragraph', 'unordered-list', 'ordered-list']

Retutns the Type of the Item

Return type

Literal[‘paragraph’, ‘unordered-list’, ‘ordered-list’]

load_tags(tag_list: list[lxml.etree.Element]) None

Loads the XML tags into the Elemnt. Only for internal use.

Parameters

tag_list (list[lxml.etree.Element]) –

Return type

None

get_tags(parent_tag: Element) None

Get the XML Tag from the Element. Only for internal use.

Parameters

parent_tag (Element) –

Return type

None

get_translated_tag(lang: Optional[str] = None) Element

Loads the tag for a given language

Parameters

lang (Optional[str]) –

Return type

Element

to_plain_text(lang: Optional[str] = None) str

Returns the content as plain text

Parameters

lang (Optional[str]) –

Return type

str

class appstream_python.Component.Description

Represents a <description> tag

items: list[appstream_python.Component.DescriptionItem]

All Description Items

load_tags(tag: Element) None

Load a XML tag. Onyl for internal use.

Parameters

tag (Element) –

Return type

None

get_tags(parent_tag: Element) None

Writes a Description tag. Only for internal use.

Parameters

parent_tag (Element) –

Return type

None

to_html(lang: Optional[str] = None) str

Get the HTML code of the description in the given language

Parameters

lang (Optional[str]) –

Return type

str

to_plain_text(lang: Optional[str] = None) str

Converts the Description into Plain Text

Parameters

lang (Optional[str]) – The language

Returns

The Description

Return type

str

class appstream_python.Component.Release

Represents a <release> tag

version: str

The version

date: Optional[date]

The date

description

The description

load_tag(tag: Element) None

Loads a release tag

Parameters

tag (Element) –

Return type

None

class appstream_python.Component.Image

Represents a <image> tag

url: str

The image URL

type: Literal['source', 'thumbnail']

The image type

width: Optional[int]

The width

height: Optional[int]

The height

language: Optional[str]

The language

load_tag(tag: Element) None

Loads a image tag

Parameters

tag (Element) –

Return type

None

class appstream_python.Component.Screenshot

Represents a <screenshot> tag

images: list[appstream_python.Component.Image]

the list with thumbnail images

caption: TranslateableTag

The caption

get_source_image() Optional[Image]

Returns the soucre image

Return type

Optional[Image]

get_thumbnail_images() list[appstream_python.Component.Image]

Returns the thumbnail images

Return type

list[appstream_python.Component.Image]

load_tag(tag: Element) None

Load a screenshot tag

Parameters

tag (Element) –

Return type

None

class appstream_python.Component.DisplayLength(px: int = 0, compare: Optional[str] = None)

Represents a <display_length> tag

Parameters
  • px (int) –

  • compare (Optional[str]) –

px: int

The logical pixels

compare: Optional[str]

Compare

compare_px(value: int) bool

Compares the length with the given logical pixels

Parameters

value (int) – The logical pixels to compare

Returns

If it is valid

Return type

bool

get_tag() Element

Returns the XML Tag

Returns

The Tag

Return type

Element

classmethod from_tag(tag: Element) DisplayLength

Creates the Object from an XML Tag

Parameters

tag (Element) –

Return type

DisplayLength

static string_to_px(string: str) int

Converts a Lenght String (e.g.small) to logical pixels value

Parameters

string (str) – The String

Raises

ValueError – The Length String is invalid

Returns

The logical pixels pixels

Return type

int

class appstream_python.Component.AppstreamComponent

Represents AppStream Component

id: str

The component ID

type: str

The type

name: TranslateableTag

The component name

developer_name: TranslateableTag

The developer name

summary: TranslateableTag

The component summary

description: Description

The description

metadata_license: str

The metadata license

project_license: str

The project license

urls: dict[Literal['homepage', 'bugtracker', 'faq', 'help', 'donation', 'translate', 'contact', 'vcs-browser', 'contribute'], str]

The URLs

oars: dict[Literal['violence-cartoon', 'violence-fantasy', 'violence-realistic', 'violence-bloodshed', 'violence-sexual', 'violence-desecration', 'violence-slavery', 'drugs-alcohol', 'drugs-narcotics', 'drugs_tobacco', 'sex_nudity', 'sex-themes', 'language-profanity', 'language-humor', 'language-discrimination', 'money-advertising', 'money-gambling', 'money-purchasing', 'social-chat', 'social-audio', 'social-contacts', 'social-info', 'social-location'], Literal['none', 'mild', 'moderate', 'intense']]

The content rating

categories: list[str]

The categories

provides: dict[Literal['mediatype', 'library', 'binary', 'font', 'modalias', 'firmware', 'python2', 'python3', 'dbus', 'id'], list[str]]

The provides. The content of the depracted mimetype tag goes intp provides[‘mimetype’]

releases: list[appstream_python.Component.Release]

The releases

screenshots: list[appstream_python.Component.Screenshot]

The screenshots

project_group: Optional[str]

The project group

translation: list[dict[str, str]]

The translations

languages: dict[str, int]

The languages

keywords: TranslateableList

The Keywords

controls: dict[Literal['pointing', 'keyboard', 'console', 'tablet', 'touch', 'gamepad', 'tv-remote', 'voice', 'vision'], Optional[Literal['requires', 'recommends', 'supports']]]

The Controls

display_length: dict[Literal['requires', 'recommends', 'supports'], list[appstream_python.Component.DisplayLength]]

The Display Length

kudos: list[str]

The Kudos

update_contact: Optional[str]

The update contact

replaces: list[str]

The replaces tag

suggests: list[str]

The suggests tag

custom: dict[str, str]

The custom tag

extends: list[str]

The extends tag for addons

clear() None

Resets the Component

Return type

None

get_available_languages() list[str]

Returns a list with all available languages of the Component

Return type

list[str]

parse_component_tag(tag: _ElementTree) None

Parses a XML tag

Parameters

tag (_ElementTree) –

Return type

None

load_file(path: Union[str, PathLike, RawIOBase]) None

Load an appdata.xml or metainfo.xml file

Parameters

path (Union[str, PathLike, RawIOBase]) –

Return type

None

classmethod from_file(path: Union[str, PathLike, RawIOBase]) AppstreamComponent

Load an appdata.xml or metainfo.xml file

Parameters

path (Union[str, PathLike, RawIOBase]) –

Return type

AppstreamComponent

load_bytes(data: bytes, encoding: Optional[str] = None) None

Load an appdata.xml or metainfo.xml byte string

Parameters
  • data (bytes) –

  • encoding (Optional[str]) –

Return type

None

classmethod from_bytes(data: bytes, encoding: Optional[str] = None) AppstreamComponent

Load an appdata.xml or metainfo.xml byte string

Parameters
  • data (bytes) –

  • encoding (Optional[str]) –

Return type

AppstreamComponent

load_string(text: str) None

Load an appdata.xml or metainfo.xml string

Parameters

text (str) –

Return type

None

classmethod from_string(text: str) AppstreamComponent

Load an appdata.xml or metainfo.xml string

Parameters

text (str) –

Return type

AppstreamComponent

get_component_tag() Element

Creates a XML tag from the Component

Return type

Element

get_xml_string() str

Returns the XML data of the Component as string

Return type

str

save_file(path: str) None

Saves the Component as XML file

Parameters

path (str) –

Return type

None