Ggit.Config

g GObject.Object GObject.Object Ggit.ObjectFactoryBase Ggit.ObjectFactoryBase GObject.Object->Ggit.ObjectFactoryBase Ggit.Config Ggit.Config Ggit.Native Ggit.Native Ggit.Native->Ggit.Config Ggit.ObjectFactoryBase->Ggit.Native

Subclasses:

None

Methods

Inherited:

GObject.Object (37)

Structs:

GObject.ObjectClass (5)

class

find_global ()

class

find_system ()

class

new ()

class

new_default ()

class

new_from_file (file)

add_file (file, level, force)

delete_entry (name)

foreach (callback, *user_data)

get_bool (name)

get_entry (name)

get_int32 (name)

get_int64 (name)

get_string (name)

match (regex)

match_foreach (regex, callback, *user_data)

open_level (level)

set_bool (name, value)

set_int32 (name, value)

set_int64 (name, value)

set_string (name, value)

snapshot ()

Virtual Methods

Inherited:

GObject.Object (7)

Properties

Inherited:

Ggit.Native (1)

Signals

Inherited:

GObject.Object (1)

Fields

Inherited:

GObject.Object (1)

Class Details

class Ggit.Config(**kwargs)
Bases:

Ggit.Native

Abstract:

No

Structure:

Ggit.ConfigClass

Represents a git configuration.

classmethod find_global()
Returns:

a Gio.File or None if the global config could not be found.

Return type:

Gio.File

Find the file representing the users global git configuration. This file is usually located at $HOME/.gitconfig. This function will try to guess the full path to that file, if the file exists. The returned file may then be used with Ggit.Config.new_from_file or Ggit.Config.add_file. This function returns None if the global config could not be found.

classmethod find_system()
Returns:

a Gio.File or None if the system config could not be found.

Return type:

Gio.File

Find the file representing the systems global git configuration. This file is usually located at /etc/gitconfig on UNIX type systems or %PROGRAMFILES%\Git\etc\gitconfig on windows. This function will try to guess the full path to that file, if the file exists. The returned file may then be used with Ggit.Config.new_from_file or Ggit.Config.add_file. This function returns None if the system config could not be found.

classmethod new()
Returns:

a Ggit.Config.

Return type:

Ggit.Config

Create a new config. See also ggit_config_get_default() to get a Ggit.Config representing the global, XDG and system configuration files. To get a Ggit.Config for a repository use Ggit.Repository.get_config instead.

classmethod new_default()
Raises:

GLib.Error

Returns:

A Ggit.Config

Return type:

Ggit.Config

Get the global, XDG and system configuration files merged into one Ggit.Config with their appropriate priority levels. If an error occured trying to load the various configuration files, this function will return None and error will be set accordingly.

classmethod new_from_file(file)
Parameters:

file (Gio.File) – the file to load.

Raises:

GLib.Error

Returns:

a Ggit.Config.

Return type:

Ggit.Config

Create a new config from a single on disk file. This is a convenience API and is exactly the same as creating an empty Ggit.Config using Ggit.Config.new and adding the file with Ggit.Config.add_file. The level will be set to Ggit.ConfigLevel.LOCAL. If the config could not be loaded this function returns None and error will be set accordingly.

add_file(file, level, force)
Parameters:
Raises:

GLib.Error

Add an on-disk config file instance to an existing config

The on-disk file pointed at by file will be opened and parsed; it’s expected to be a native Git config file following the default Git config syntax (see man git-config).

Further queries on this config object will access each of the config file instances in order (instances with a higher priority level will be accessed first).

delete_entry(name)
Parameters:

name (str) – the configuration value.

Raises:

GLib.Error

Returns:

True if the configuration value was deleted, False otherwise.

Return type:

bool

Delete a config variable from the config file.

foreach(callback, *user_data)
Parameters:
Raises:

GLib.Error

Returns:

True if successfull, False otherwise

Return type:

bool

Call callback for each configuration value.

get_bool(name)
Parameters:

name (str) – the name of the configuration value.

Raises:

GLib.Error

Returns:

the value.

Return type:

bool

Get a boolean configuration value.

get_entry(name)
Parameters:

name (str) – the configuration name.

Raises:

GLib.Error

Returns:

the entry of name, or None if such a value does not exist.

Return type:

Ggit.ConfigEntry

Get Ggit.ConfigEntry of a config variable.

get_int32(name)
Parameters:

name (str) – the name of the configuration value.

Raises:

GLib.Error

Returns:

the value.

Return type:

int

Get a int32 configuration value.

get_int64(name)
Parameters:

name (str) – the name of the configuration value.

Raises:

GLib.Error

Returns:

the value.

Return type:

int

Get a int64 configuration value.

get_string(name)
Parameters:

name (str) – the name of the configuration value.

Raises:

GLib.Error

Returns:

the string value of name, or None if such a value does not exist

Return type:

str or None

Get the configuration value of name as string.

match(regex)
Parameters:

regex (GLib.Regex) – a GLib.Regex.

Raises:

GLib.Error

Returns:

the value of that matched configuration

match_info:

a GLib.MatchInfo.

Return type:

(str or None, match_info: GLib.MatchInfo)

Matches a configuration against a regular expression. match_info will contain the match information if the return value is not None, otherwise error will be set.

match_foreach(regex, callback, *user_data)
Parameters:
Raises:

GLib.Error

Returns:

True if matches were successfull, False otherwise

Return type:

bool

Call callback for all configurations matching regex.

open_level(level)
Parameters:

level (Ggit.ConfigLevel) – the level to open.

Raises:

GLib.Error

Returns:

the configuration at level, or None.

Return type:

Ggit.Config

Open a specific level config derived from a multi-level one.

set_bool(name, value)
Parameters:
  • name (str) – the name of the configuration value.

  • value (bool) – the new value.

Raises:

GLib.Error

Returns:

True if the value was successfully set, False otherwise.

Return type:

bool

Set a boolean value.

set_int32(name, value)
Parameters:
  • name (str) – the name of the configuration value.

  • value (int) – the new value.

Raises:

GLib.Error

Returns:

True if the value was successfully set, False otherwise.

Return type:

bool

Set a int32 value.

set_int64(name, value)
Parameters:
  • name (str) – the name of the configuration value.

  • value (int) – the new value.

Raises:

GLib.Error

Returns:

True if the value was successfully set, False otherwise.

Return type:

bool

Set a int64 value.

set_string(name, value)
Parameters:
  • name (str) – the name of the configuration value.

  • value (str) – the new value.

Raises:

GLib.Error

Returns:

True if the value was successfully set, False otherwise.

Return type:

bool

Set a new string value of a configuration.

snapshot()
Raises:

GLib.Error

Returns:

a new Ggit.Config, or None if an error occurred.

Return type:

Ggit.Config

Create a snapshot of the current state of the configuration, which allows you to look into a consistent view of the configuration for looking up complex values (e.g. a remote, submodule).