AppStreamGlib.ContentRating

g AppStreamGlib.ContentRating AppStreamGlib.ContentRating GObject.Object GObject.Object GObject.Object->AppStreamGlib.ContentRating

Subclasses:

None

Methods

Inherited:

GObject.Object (37)

Structs:

GObject.ObjectClass (5)

class

attribute_from_csm_age (id, age)

class

attribute_get_description (id, value)

class

attribute_to_csm_age (id, value)

class

get_all_rating_ids ()

class

new ()

class

system_format_age (system, age)

class

system_from_locale (locale)

class

system_get_csm_ages (system)

class

system_get_formatted_ages (system)

class

system_to_string (system)

class

value_from_string (value)

class

value_to_string (value)

add_attribute (id, value)

get_kind ()

get_minimum_age ()

get_rating_ids ()

get_value (id)

set_kind (kind)

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 AppStreamGlib.ContentRating(**kwargs)
Bases:

GObject.Object

Abstract:

No

Structure:

AppStreamGlib.ContentRatingClass

classmethod attribute_from_csm_age(id, age)[source]
Parameters:
  • id (str) – the subsection ID e.g. violence-cartoon

  • age (int) – the CSM age

Returns:

the AppStreamGlib.ContentRatingValue, or AppStreamGlib.ContentRatingValue.UNKNOWN if unknown

Return type:

AppStreamGlib.ContentRatingValue

Gets the highest AppStreamGlib.ContentRatingValue which is allowed to be seen by the given Common Sense Media age for the given subsection id.

For example, if the CSM age mappings for violence-bloodshed are:

New in version 0.7.18.

classmethod attribute_get_description(id, value)[source]
Parameters:
Returns:

a human-readable description of id and value

Return type:

str

Get a human-readable description of what content would be expected to require the content rating attribute given by id and value.

New in version 0.7.18.

classmethod attribute_to_csm_age(id, value)[source]
Parameters:
Returns:

The age in years, or 0 for no details.

Return type:

int

Gets the Common Sense Media approved age for a specific rating level.

New in version 0.7.15.

classmethod get_all_rating_ids()[source]
Returns:

a None-terminated array of IDs, to be freed with GLib.free() (the element values are owned by libappstream-glib and must not be freed)

Return type:

[str]

Returns a list of all the valid OARS content rating attribute IDs as could be passed to AppStreamGlib.ContentRating.add_attribute() or AppStreamGlib.ContentRating.attribute_to_csm_age().

New in version 0.7.15.

classmethod new()[source]
Returns:

a AppStreamGlib.ContentRating

Return type:

AppStreamGlib.ContentRating

Creates a new AppStreamGlib.ContentRating.

New in version 0.5.12.

classmethod system_format_age(system, age)[source]
Parameters:
Returns:

a newly allocated formatted version of age, or None if the given system has no representation for age

Return type:

str or None

Format age as a human-readable string in the given rating system. This is the way to present system-specific strings in a UI.

New in version 0.7.18.

classmethod system_from_locale(locale)[source]
Parameters:

locale (str) – a locale, in the format described in man 3 setlocale

Returns:

the most relevant AppStreamGlib.ContentRatingSystem

Return type:

AppStreamGlib.ContentRatingSystem

Determine the most appropriate AppStreamGlib.ContentRatingSystem for the given locale. Content rating systems are selected by territory. If no content rating system seems suitable, AppStreamGlib.ContentRatingSystem.IARC is returned.

New in version 0.7.18.

classmethod system_get_csm_ages(system)[source]
Parameters:

system (AppStreamGlib.ContentRatingSystem) – an AppStreamGlib.ContentRatingSystem

Returns:

an array of CSM ages

Return type:

[int]

Get the CSM ages corresponding to the entries returned by AppStreamGlib.ContentRating.system_get_formatted_ages() for this system.

New in version 0.7.18.

classmethod system_get_formatted_ages(system)[source]
Parameters:

system (AppStreamGlib.ContentRatingSystem) – an AppStreamGlib.ContentRatingSystem

Returns:

None-terminated array of human-readable age strings

Return type:

[str]

Get an array of all the possible return values of AppStreamGlib.ContentRating.system_format_age() for the given system. The array is sorted with youngest CSM age first.

New in version 0.7.18.

classmethod system_to_string(system)[source]
Parameters:

system (AppStreamGlib.ContentRatingSystem) – an AppStreamGlib.ContentRatingSystem

Returns:

a human-readable string for system, or None if unknown

Return type:

str or None

Get a human-readable string to identify system. None will be returned for AppStreamGlib.ContentRatingSystem.UNKNOWN.

New in version 0.7.18.

classmethod value_from_string(value)[source]
Parameters:

value (str) – the string.

Returns:

a AppStreamGlib.ContentRatingValue or AppStreamGlib.ContentRatingValue.UNKNOWN for unknown

Return type:

AppStreamGlib.ContentRatingValue

Converts the text representation to an enumerated value.

New in version 0.5.12.

classmethod value_to_string(value)[source]
Parameters:

value (AppStreamGlib.ContentRatingValue) – the AppStreamGlib.ContentRatingValue.

Returns:

string version of value

Return type:

str

Converts the enumerated value to an text representation.

New in version 0.5.12.

add_attribute(id, value)[source]
Parameters:

Adds an attribute value to the content rating.

New in version 0.7.14.

get_kind()[source]
Returns:

a string, e.g. “oars-1.0”, or None

Return type:

str

Gets the content_rating kind.

New in version 0.5.12.

get_minimum_age()[source]
Returns:

The age in years, 0 for no rating, or GObject.G_MAXUINT for no details.

Return type:

int

Gets the lowest Common Sense Media approved age for the content_rating block. NOTE: these numbers are based on the data and descriptions available from https://www.commonsensemedia.org/about-us/our-mission/about-our-ratings and you may disagree with them.

You’re free to disagree with these, and of course you should use your own brain to work our if your child is able to cope with the concepts enumerated here. Some 13 year olds may be fine with the concept of mutilation of body parts; others may get nightmares.

New in version 0.5.12.

get_rating_ids()[source]
Returns:

None-terminated array of ratings IDs; each ratings ID is owned by the AppStreamGlib.ContentRating and must not be freed, but the container must be freed with GLib.free()

Return type:

[str]

Gets the set of ratings IDs which are present in this self. An example of a ratings ID is violence-bloodshed.

The IDs are returned in lexicographical order.

New in version 0.7.15.

get_value(id)[source]
Parameters:

id (str) – A ratings ID, e.g. violence-bloodshed.

Returns:

the AppStreamGlib.ContentRatingValue, or AppStreamGlib.ContentRatingValue.UNKNOWN

Return type:

AppStreamGlib.ContentRatingValue

Gets the set value of a content rating key.

New in version 0.6.4.

set_kind(kind)[source]
Parameters:

kind (str) – the rating kind, e.g. “oars-1.0”

Sets the content rating kind.

New in version 0.5.12.