EDataServer.Collator

Fields

None

Methods

class

error_quark ()

class

new (locale)

class

new_interpret_country (locale)

collate (str_a, str_b)

generate_key (str)

generate_key_for_index (index)

get_index (str)

get_index_labels ()

ref ()

unref ()

Details

class EDataServer.Collator

An opaque object used for locale specific string comparisons and sort ordering.

New in version 3.12.

classmethod error_quark()
Return type:

int

classmethod new(locale)
Parameters:

locale (str) – The locale under which to sort

Raises:

GLib.Error

Returns:

A newly created EDataServer.Collator.

Return type:

EDataServer.Collator

Creates a new EDataServer.Collator for the given locale, the returned collator should be freed with EDataServer.Collator.unref().

New in version 3.12.

classmethod new_interpret_country(locale)
Parameters:

locale (str) – The locale under which to sort

Raises:

GLib.Error

Returns:

A newly created EDataServer.Collator.

country_code:

A location to store the interpreted country code from locale

Return type:

(EDataServer.Collator, country_code: str)

Creates a new EDataServer.Collator for the given locale, the returned collator should be freed with EDataServer.Collator.unref().

In addition, this also reliably interprets the country code from the locale string and stores it to country_code.

New in version 3.12.

collate(str_a, str_b)
Parameters:
  • str_a (str or None) – A string to compare

  • str_b (str or None) – The string to compare with str_a

Raises:

GLib.Error

Returns:

True on success, otherwise if False is returned then error will be set.

result:

A location to store the comparison result

Return type:

(bool, result: int)

Compares str_a with str_b, the order of strings is determined by the parameters of self.

The result will be set to integer less than, equal to, or greater than zero if str_a is found, respectively, to be less than, to match, or be greater than str_b.

Either str_a or str_b can be None, None strings are considered to sort below other strings.

This function will first ensure that both strings are valid UTF-8.

New in version 3.12.

generate_key(str)
Parameters:

str (str) – The string to generate a collation key for

Raises:

GLib.Error

Returns:

A collation key for str, or None on failure with error set.

Return type:

str

Generates a collation key for str, the result of comparing two collation keys with strcmp() will be the same result of calling EDataServer.Collator.collate() on the same original strings.

This function will first ensure that str is valid UTF-8 encoded.

New in version 3.12.

generate_key_for_index(index)
Parameters:

index (int) – An index into the alphabetic labels

Returns:

A sort key for the given index

Return type:

str

Generates a sort key for the given alphabetic index.

The generated sort key is guaranteed to sort below any sort keys for words beginning with any variant of the given letter.

For instance, a sort key generated for the index 5 of a latin alphabet, where the fifth index is ‘E’ will sort below any sort keys generated for words starting with the characters ‘e’, ‘E’, ‘é’, ‘É’, ‘è’ or ‘È’. It will also sort above any sort keys generated for words starting with the characters ‘d’ or ‘D’.

New in version 3.12.

get_index(str)
Parameters:

str (str) – A string

Returns:

The alphabetic index under which str would sort

Return type:

int

Checks which index, as determined by EDataServer.Collator.get_index_labels(), that str should sort under.

New in version 3.12.

get_index_labels()
Returns:

The array of displayable labels for each index in the active alphabet(s).

n_labels:

The number of labels/indexes available for self

underflow:

The underflow index, for any words which sort below the active alphabet(s)

inflow:

The inflow index, for any words which sort between the active alphabets (if there is more than one)

overflow:

The overflow index, for any words which sort above the active alphabet(s)

Return type:

([str], n_labels: int, underflow: int, inflow: int, overflow: int)

Fetches the displayable labels and index positions for the active alphabet.

New in version 3.12.

ref()
Returns:

self

Return type:

EDataServer.Collator

Increases the reference count of self.

New in version 3.12.

unref()

Decreases the reference count of self. If the reference count reaches 0 then the collator is freed

New in version 3.12.