Libxfce4util.Rc

Fields

None

Methods

class

config_open (type, resource, readonly)

class

simple_open (filename, readonly)

close ()

delete_entry (key, global_)

delete_group (group, global_)

flush ()

get_entries (group)

get_group ()

get_groups ()

get_locale ()

has_entry (key)

has_group (group)

is_dirty ()

is_readonly ()

read_bool_entry (key, fallback)

read_entry (key, fallback)

read_entry_untranslated (key, fallback)

read_int_entry (key, fallback)

read_list_entry (key, delimiter)

rollback ()

set_group (group)

write_bool_entry (key, value)

write_entry (key, value)

write_int_entry (key, value)

write_list_entry (key, value, separator)

Details

class Libxfce4util.Rc
classmethod config_open(type, resource, readonly)
Parameters:
  • type (Libxfce4util.ResourceType) – The resource type being opened

  • resource (str) – The resource name to open

  • readonly (bool) – whether to open resource readonly.

Returns:

the newly created Libxfce4util.Rc object, or None on error.

Return type:

Libxfce4util.Rc

If readonly is True parsing is generally faster, because only untranslated entries and entries that match the current locale will be loaded. Also if you pass True for readonly, #xfce_rc_config will fail if resource does not reference a regular file.

It is no error if readonly is False and the file referenced by resource does not exists. In this case you’ll start with a fresh config, which contains only the default group and no entries.

New in version 4.2.

classmethod simple_open(filename, readonly)
Parameters:
  • filename (str) – name of the filename to open.

  • readonly (bool) – whether to open filename readonly.

Returns:

the newly created Libxfce4util.Rc object, or None on error.

Return type:

Libxfce4util.Rc

Parses the resource config file specified by filename.

If readonly is True parsing is generally faster, because only untranslated entries and entries that match the current locale will be loaded. Also if you pass True for readonly, Libxfce4util.Rc.simple_open will fail if filename does not reference a regular file.

It is no error if readonly is False and the file referenced by filename does not exists. In this case you’ll start with a fresh config, which contains only the default group and no entries.

New in version 4.2.

close()

Destructs self.

If self was opened read-write and contains dirty (modified) entries, these will be flushed to permanent storage first.

New in version 4.2.

delete_entry(key, global_)
Parameters:
  • key (str) – the key to delete.

  • global (bool) – whether to delete key globally.

Similar to Libxfce4util.Rc.delete_group, but works on an entry in the current group.

New in version 4.2.

delete_group(group, global_)
Parameters:
  • group (str) – name of the group to delete.

  • global (bool) – whether to delete the group globally.

If self is a simple config object and group exists, it is deleted. All entries within group will be deleted. For simple config objects, global is ignored.

If self is a complex config object and group exists, it will be deleted will all entries. If global is True, the entry will be marked as deleted globally, therefore all calls to Libxfce4util.Rc.read_entry and related functions will return the fallback values. If global is False, the group will be deleted in the per-user config file, and further calls to Libxfce4util.Rc.read_entry will most probably return the system-wide config entries.

New in version 4.2.

flush()

Flushes all changes that currently reside only in memory back to permanent storage. Dirty configuration entries are written in the most specific file available.

New in version 4.2.

get_entries(group)
Parameters:

group (str) – the name of the group to get entries from.

Returns:

a None-terminated string array with all entries in group. Has to be freed using GLib.strfreev() if no longer needed. If the specified group does not exists, None is returned. If the group has no entries, an empty string array is returned.

Return type:

[str]

Returns the names of all entries in group if any.

None is a valid input value for group. Libxfce4util.Rc.get_entries will then return all entries in the so called “None group”. Though this “None group” should only be used for backward compatibility with old applications. You should not use it in newly written code.

New in version 4.2.

get_group()
Returns:

the name of the current group.

Return type:

str

Returns the name of the group in which we are searching for keys and from which we are retrieving entries. If the currently active group is the default group (the so called “None group”), None will be returned.

New in version 4.2.

get_groups()
Returns:

a None-terminated string array will the names of all groups in self. Should be freed using GLib.strfreev() when no longer needed.

Return type:

[str]

Returns the names of all known groups in self.

Since the default groups (the “None group”) name is None, it will not be returned with this functions. But it does not matter at all, since the default group is known to always exist.

New in version 4.2.

get_locale()
Returns:

a string representing the current locale.

Return type:

str

Returns current locale used by self to lookup translated entries.

New in version 4.2.

has_entry(key)
Parameters:

key (str) – the key to search for.

Returns:

True if the key is available, else False.

Return type:

bool

Checks whether the key has an entry in the current group.

New in version 4.2.

has_group(group)
Parameters:

group (str) – the group to search for.

Returns:

True if the group exists.

Return type:

bool

Returns True if the specified group is known about.

New in version 4.2.

is_dirty()
Returns:

True if self has any dirty (modified) entries.

Return type:

bool

Checks whether self has any dirty (modified) entries.

New in version 4.2.

is_readonly()
Returns:

the read-only status.

Return type:

bool

Returns the read-only status of self.

New in version 4.2.

read_bool_entry(key, fallback)
Parameters:
  • key (str) – the key to search for.

  • fallback (bool) – a default value returned if the key was not found.

Returns:

the value for this key.

Return type:

bool

Reads the value of an entry specified by key in the current group and interpret it as a boolean value. Currently “on”, “true” and “yes” are accepted as true, everything else is false.

New in version 4.2.

read_entry(key, fallback)
Parameters:
  • key (str) – the key to search for.

  • fallback (str) – a default value returned if the key was not found.

Returns:

the value for this key, or fallback if key was not found.

Return type:

str

Reads the value of an entry specified by key in the current group.

New in version 4.2.

read_entry_untranslated(key, fallback)
Parameters:
  • key (str) – the key to search for.

  • fallback (str) – a default value returned if the key was not found.

Returns:

the untranslated value for this key, or fallback if key was not found.

Return type:

str

Reads the value of an entry specified by key in the current group. The untranslated entry is returned. You normally do not need this.

New in version 4.2.

read_int_entry(key, fallback)
Parameters:
  • key (str) – the key to search for.

  • fallback (int) – a default value returned if the key was not found.

Returns:

the value for this key.

Return type:

int

Reads the value of an entry specified by key in the current group and interprets it as an integer value.

New in version 4.2.

read_list_entry(key, delimiter)
Parameters:
  • key (str) – the key to search for.

  • delimiter (str) – a string which specifies the places at which to split the string. The delimiter is not included in any of the resulting strings. If None, “,” is used.

Returns:

the list or None if the entry does not exist.

Return type:

[str]

Reads a list of strings in the entry specified by key in the current group. The returned list has to be freed using GLib.strfreev() when no longer needed.

This does not support delimiter escaping. If you need this feature, use GLib.KeyFile.get_string_list() instead.

New in version 4.2.

rollback()

Mark self as “clean”, i.e. don’t write dirty entries at destruction time. If you then call Libxfce4util.Rc.write_entry again, the dirty flag is set again and dirty entries will be written at a subsequent Libxfce4util.Rc.flush call.

New in version 4.2.

set_group(group)
Parameters:

group (str) – the name of the new group or None to to switch back to the default group.

Specifies the group in which keys will be read and written. Subsequent calls to Libxfce4util.Rc.read_entry and Libxfce4util.Rc.write_entry will be applied only in the active group.

If group references a group that does not exists, it will be created for you. But note, that empty groups will not be synced to permanent storage.

New in version 4.2.

write_bool_entry(key, value)
Parameters:
  • key (str) – the key to write.

  • value (bool) – the value to write.

Wrapper for Libxfce4util.Rc.write_entry, that stores a boolean value.

New in version 4.2.

write_entry(key, value)
Parameters:
  • key (str) – the key to write.

  • value (str) – the value to write.

Writes a key/value pair. This has no effect if the resource config was opened readonly, else the value will be written to permanent storage on the next call to Libxfce4util.Rc.flush or when self is destroyed using Libxfce4util.Rc.close.

If self was opened using Libxfce4util.Rc.config_open, the value will be written to the most specific config file.

New in version 4.2.

write_int_entry(key, value)
Parameters:
  • key (str) – the key to write.

  • value (int) – the value to write.

Wrapper for Libxfce4util.Rc.write_entry, that stores an integer value.

New in version 4.2.

write_list_entry(key, value, separator)
Parameters:
  • key (str) – the key to write.

  • value (str) – a None terminated list of strings to store in the entry specified by key.

  • separator (str) – the list separator. Defaults to “,” if None.

Wrapper for Libxfce4util.Rc.write_entry, that stores a string list value.

This does not support delimiter escaping. If you need this feature, use GLib.KeyFile.set_string_list() instead.

New in version 4.2.