GIRepository.Repository

g GIRepository.Repository GIRepository.Repository GObject.Object GObject.Object GObject.Object->GIRepository.Repository

Subclasses:

None

Methods

Inherited:

GObject.Object (37)

Structs:

GObject.ObjectClass (5)

class

dump (arg)

class

error_quark ()

class

get_default ()

class

get_option_group ()

class

get_search_path ()

class

prepend_library_path (directory)

class

prepend_search_path (directory)

enumerate_versions (namespace_)

find_by_error_domain (domain)

find_by_gtype (gtype)

find_by_name (namespace_, name)

get_c_prefix (namespace_)

get_dependencies (namespace_)

get_immediate_dependencies (namespace_)

get_info (namespace_, index)

get_loaded_namespaces ()

get_n_infos (namespace_)

get_object_gtype_interfaces (gtype)

get_shared_library (namespace_)

get_typelib_path (namespace_)

get_version (namespace_)

is_registered (namespace_, version)

load_typelib (typelib, flags)

require (namespace_, version, flags)

require_private (typelib_dir, namespace_, version, flags)

Virtual Methods

Inherited:

GObject.Object (7)

Properties

None

Signals

Inherited:

GObject.Object (1)

Fields

Inherited:

GObject.Object (1)

Name

Type

Access

Description

parent

GObject.Object

r

Class Details

class GIRepository.Repository(**kwargs)
Bases:

GObject.Object

Abstract:

No

Structure:

GIRepository.RepositoryClass

GIRepository.Repository is used to manage repositories of namespaces. Namespaces are represented on disk by type libraries (.typelib files).

### Discovery of type libraries

GIRepository.Repository will typically look for a girepository-1.0 directory under the library directory used when compiling gobject-introspection.

It is possible to control the search paths programmatically, using GIRepository.Repository.prepend_search_path(). It is also possible to modify the search paths by using the GI_TYPELIB_PATH environment variable. The environment variable takes precedence over the default search path and the GIRepository.Repository.prepend_search_path() calls.

classmethod dump(arg)
Parameters:

arg (str) –

Raises:

GLib.Error

Return type:

bool

classmethod error_quark()
Return type:

int

classmethod get_default()
Returns:

The global singleton GIRepository.Repository

Return type:

GIRepository.Repository

Returns the singleton process-global default GIRepository.Repository. It is not currently supported to have multiple repositories in a particular process, but this function is provided in the unlikely eventuality that it would become possible, and as a convenience for higher level language bindings to conform to the GObject.Object method call conventions.

All methods on GIRepository.Repository also accept None as an instance parameter to mean this default repository, which is usually more convenient for C.

classmethod get_option_group()
Returns:

the option group

Return type:

GLib.OptionGroup

Obtain the option group for girepository, it’s used by the dumper and for programs that wants to provide introspection information

classmethod get_search_path()
Returns:

GLib.SList of strings

Return type:

[str]

Returns the current search path GIRepository.Repository will use when loading typelib files. The list is internal to GIRepository.Repository and should not be freed, nor should its string elements.

classmethod prepend_library_path(directory)
Parameters:

directory (str) –

classmethod prepend_search_path(directory)
Parameters:

directory (str) – directory name to prepend to the typelib search path

Prepends directory to the typelib search path.

See also: GIRepository.Repository.get_search_path().

enumerate_versions(namespace_)
Parameters:

namespace (str) – GI namespace, e.g. “Gtk”

Returns:

the array of versions.

Return type:

[str]

Obtain an unordered list of versions (either currently loaded or available) for namespace_ in this self.

find_by_error_domain(domain)
Parameters:

domain (int) – a GLib.Error domain

Returns:

#GIEnumInfo representing metadata about domain's enum type, or None

Return type:

GIRepository.BaseInfo

Searches for the enum type corresponding to the given GLib.Error domain. Before calling this function for a particular namespace, you must call GIRepository.Repository.require() once to load the namespace, or otherwise ensure the namespace has already been loaded.

New in version 1.30.

find_by_gtype(gtype)
Parameters:

gtype (GObject.GType) – GObject.GType to search for

Returns:

GIRepository.BaseInfo representing metadata about type, or None

Return type:

GIRepository.BaseInfo

Searches all loaded namespaces for a particular GObject.GType. Note that in order to locate the metadata, the namespace corresponding to the type must first have been loaded. There is currently no mechanism for determining the namespace which corresponds to an arbitrary GObject.GType - thus, this function will operate most reliably when you know the GObject.GType to originate from be from a loaded namespace.

find_by_name(namespace_, name)
Parameters:
  • namespace (str) – Namespace which will be searched

  • name (str) – Entry name to find

Returns:

GIRepository.BaseInfo representing metadata about name, or None

Return type:

GIRepository.BaseInfo

Searches for a particular entry in a namespace. Before calling this function for a particular namespace, you must call GIRepository.Repository.require() once to load the namespace, or otherwise ensure the namespace has already been loaded.

get_c_prefix(namespace_)
Parameters:

namespace (str) – Namespace to inspect

Returns:

C namespace prefix, or None if none associated

Return type:

str

This function returns the “C prefix”, or the C level namespace associated with the given introspection namespace. Each C symbol starts with this prefix, as well each GObject.GType in the library.

Note: The namespace must have already been loaded using a function such as GIRepository.Repository.require() before calling this function.

get_dependencies(namespace_)
Parameters:

namespace (str) – Namespace of interest

Returns:

all versioned dependencies

Return type:

[str]

Retrieves all (transitive) versioned dependencies for namespace_.

The strings are of the form namespace-version.

Note: namespace_ must have already been loaded using a function such as GIRepository.Repository.require() before calling this function.

To get only the immediate dependencies for namespace_, use GIRepository.Repository.get_immediate_dependencies().

get_immediate_dependencies(namespace_)
Parameters:

namespace (str) – Namespace of interest

Returns:

Zero-terminated string array of immediate versioned dependencies

Return type:

[str]

Return an array of the immediate versioned dependencies for namespace_. Returned strings are of the form namespace-version.

Note: namespace_ must have already been loaded using a function such as GIRepository.Repository.require() before calling this function.

To get the transitive closure of dependencies for namespace_, use GIRepository.Repository.get_dependencies().

New in version 1.44.

get_info(namespace_, index)
Parameters:
  • namespace (str) – Namespace to inspect

  • index (int) – 0-based offset into namespace metadata for entry

Returns:

GIRepository.BaseInfo containing metadata

Return type:

GIRepository.BaseInfo

This function returns a particular metadata entry in the given namespace namespace_. The namespace must have already been loaded before calling this function. See GIRepository.Repository.get_n_infos() to find the maximum number of entries.

get_loaded_namespaces()
Returns:

List of namespaces

Return type:

[str]

Return the list of currently loaded namespaces.

get_n_infos(namespace_)
Parameters:

namespace (str) – Namespace to inspect

Returns:

number of metadata entries

Return type:

int

This function returns the number of metadata entries in given namespace namespace_. The namespace must have already been loaded before calling this function.

get_object_gtype_interfaces(gtype)
Parameters:

gtype (GObject.GType) – a GObject.GType whose fundamental type is GObject.TYPE_OBJECT

Returns:

Interfaces for gtype

Return type:

interfaces_out: [GIRepository.BaseInfo]

Look up the implemented interfaces for gtype. This function cannot fail per se; but for a totally “unknown” GObject.GType, it may return 0 implemented interfaces.

The semantics of this function are designed for a dynamic binding, where in certain cases (such as a function which returns an interface which may have “hidden” implementation classes), not all data may be statically known, and will have to be determined from the GObject.GType of the object. An example is g_file_new_for_path() returning a concrete class of #GLocalFile, which is a GObject.GType we see at runtime, but not statically.

New in version 1.62.

get_shared_library(namespace_)
Parameters:

namespace (str) – Namespace to inspect

Returns:

Comma-separated list of paths to shared libraries, or None if none are associated

Return type:

str or None

This function returns a comma-separated list of paths to the shared C libraries associated with the given namespace namespace_. There may be no shared library path associated, in which case this function will return None.

Note: The namespace must have already been loaded using a function such as GIRepository.Repository.require() before calling this function.

get_typelib_path(namespace_)
Parameters:

namespace (str) – GI namespace to use, e.g. “Gtk”

Returns:

Filesystem path (or $lt;builtin$gt;) if successful, None if namespace is not loaded

Return type:

str

If namespace namespace_ is loaded, return the full path to the .typelib file it was loaded from. If the typelib for namespace namespace_ was included in a shared library, return the special string “<builtin>”.

get_version(namespace_)
Parameters:

namespace (str) – Namespace to inspect

Returns:

Loaded version

Return type:

str

This function returns the loaded version associated with the given namespace namespace_.

Note: The namespace must have already been loaded using a function such as GIRepository.Repository.require() before calling this function.

is_registered(namespace_, version)
Parameters:
  • namespace (str) – Namespace of interest

  • version (str or None) – Required version, may be None for latest

Returns:

True if namespace-version is loaded, False otherwise

Return type:

bool

Check whether a particular namespace (and optionally, a specific version thereof) is currently loaded. This function is likely to only be useful in unusual circumstances; in order to act upon metadata in the namespace, you should call GIRepository.Repository.require() instead which will ensure the namespace is loaded, and return as quickly as this function will if it has already been loaded.

load_typelib(typelib, flags)
Parameters:
Raises:

GLib.Error

Return type:

str

TODO

require(namespace_, version, flags)
Parameters:
Raises:

GLib.Error

Returns:

a pointer to the GIRepository.Typelib if successful, None otherwise

Return type:

GIRepository.Typelib

Force the namespace namespace_ to be loaded if it isn’t already. If namespace_ is not loaded, this function will search for a “.typelib” file using the repository search path. In addition, a version version of namespace may be specified. If version is not specified, the latest will be used.

require_private(typelib_dir, namespace_, version, flags)
Parameters:
Raises:

GLib.Error

Returns:

a pointer to the GIRepository.Typelib if successful, None otherwise

Return type:

GIRepository.Typelib

Force the namespace namespace_ to be loaded if it isn’t already. If namespace_ is not loaded, this function will search for a “.typelib” file within the private directory only. In addition, a version version of namespace should be specified. If version is not specified, the latest will be used.