Functions

action_mixin_get_enabled (instance, action)

action_mixin_set_enabled (instance, action, enabled)

build_error_quark ()

dap_protocol_extract_error (node)

dap_protocol_has_error (node)

dap_protocol_unwrap_error (completed, user_data)

dup_projects_directory ()

dup_projects_directory_file ()

file_canonicalize (file)

file_find_in_ancestors (file, name)

file_find_regex_with_depth (file, regex, max_depth)

file_find_with_depth (file, pattern, max_depth)

file_is_in (file, toplevel)

file_list_children_typed (file, file_type, attributes)

file_query_exists_nofollow (file)

file_read_link (file)

file_read_link_recurse (file, max_depth)

file_test (path, test)

flatten_list_model_new (model)

fuzzy_match (haystack, casefold_needle)

get_default_arch ()

get_os_info (key_name)

get_version_string ()

git_clone_error_quark ()

git_initialize (directory, bare)

git_uri_is_valid (uri_string)

host_file_get_contents_bytes (path)

init ()

json_node_from_bytes (bytes)

json_node_new_strv (strv)

json_node_to_bytes (node)

json_node_to_bytes_full (node, pretty_print)

json_node_to_string (node, pretty_print)

json_parser_load_from_file (parser, file)

json_parser_load_from_stream (parser, stream)

key_file_new_from_file (file, flags)

key_file_new_merged (search_dirs, file, flags)

list_model_await (model)

list_model_set_future (model, future)

map_list_model_new (model, map_func, *user_data)

mkdir_with_parents (path, mode)

object_serializer_format_parse (string)

path_collapse (path)

path_expand (path)

pipe (read_fd, write_fd, flags)

pty_create_producer (pty_consumer_fd, blocking)

search_path_append (path, append)

search_path_prepend (path, prepend)

shell_get_default ()

shell_get_default_path ()

shell_supports_dash_c (shell)

shell_supports_dash_login (shell)

subprocess_communicate (subprocess, stdin_bytes)

subprocess_communicate_utf8 (subprocess, stdin_buf)

subprocess_wait_check (subprocess, cancellable)

Details

Foundry.action_mixin_get_enabled(instance, action)
Parameters:
Return type:

bool

Foundry.action_mixin_set_enabled(instance, action, enabled)
Parameters:
Foundry.build_error_quark()
Return type:

int

Foundry.dap_protocol_extract_error(node)
Parameters:

node (Json.Node) –

Return type:

GLib.Error

Foundry.dap_protocol_has_error(node)
Parameters:

node (Json.Node) –

Return type:

bool

Foundry.dap_protocol_unwrap_error(completed, user_data)
Parameters:
Return type:

Dex.Future

Foundry.dup_projects_directory()
Return type:

str

Foundry.dup_projects_directory_file()
Return type:

Gio.File

Foundry.file_canonicalize(file)
Parameters:

file (Gio.File) – a [iface`Gio`.File]

Raises:

GLib.Error

Return type:

Gio.File

Foundry.file_find_in_ancestors(file, name)
Parameters:
  • file (Gio.File) – a [iface`Gio`.File]

  • name (str) – the name of the file to find in the ancestors such as “.gitignore”

Returns:

a [class`Dex`.Future] that resolves to a [iface`Gio`.File] or rejects with error,

Return type:

Dex.Future

Locates name within any of the ancestors of file up to the root of the filesystem.

Foundry.file_find_regex_with_depth(file, regex, max_depth)
Parameters:
  • file (Gio.File) – an [iface`Gio`.File]

  • regex (GLib.Regex) – A regex to match filenames within descendants

  • max_depth (int) – the max depth to recurse

Returns:

a [class`Dex`.Future]

Return type:

Dex.Future

Locates files starting from file matching regex.

The regex will be passed the name within the parent directory, not the enter path from file.

Foundry.file_find_with_depth(file, pattern, max_depth)
Parameters:
  • file (Gio.File) – an [iface`Gio`.File]

  • pattern (str) – the pattern to find

  • max_depth (int) – the max depth to recurse

Returns:

a [class`Dex`.Future] that resolves to a [struct`GLib`.PtrArray] of [iface`Gio`.File].

Return type:

Dex.Future

Locates files starting from file matching pattern.

Foundry.file_is_in(file, toplevel)
Parameters:
Return type:

bool

Foundry.file_list_children_typed(file, file_type, attributes)
Parameters:
Returns:

a [class`Dex`.Future] that resolves to a [struct`GLib`.PtrArray] of [iface`Gio`.File] or rejects with error.

Return type:

Dex.Future

Foundry.file_query_exists_nofollow(file)
Parameters:

file (Gio.File) – a [iface`Gio`.File]

Returns:

a future that resolves to a boolean

Return type:

Dex.Future

Resolves to true if file exists.

Does not follow symlink.

Parameters:

file (Gio.File) – a [iface`Gio`.File]

Returns:

a [class`Dex`.Future] that resolves to a [iface`Gio`.File], or rejects with [struct`GLib`.Error]

Return type:

Dex.Future

Asynchronously resolves file if it is a symbolic link.

If file is not a symbolic link (as determined by [method`Gio`.File.query_info] with Gio.FILE_ATTRIBUTE_STANDARD_IS_SYMLINK), the future resolves to file itself. If it is a symbolic link, the link target is read with [func`GLib`.file_read_link] and a new [iface`Gio`.File] for the resolved path is returned. On failure, the future rejects with an error.

The work is performed in a fiber on the thread pool scheduler.

New in version 1.1.

Parameters:
  • file (Gio.File) – a [iface`Gio`.File]

  • max_depth (int) – maximum number of symbolic links to resolve (must be > 0)

Returns:

a [class`Dex`.Future] that resolves to a [iface`Gio`.File], or rejects with [struct`GLib`.Error]

Return type:

Dex.Future

Asynchronously resolves file by repeatedly following symbolic links until the result is not a symbolic link, or max_depth steps have been taken.

Uses a “seen” set to detect cycles: if the same [iface`Gio`.File] is encountered again while resolving, the future rejects with Gio.IOErrorEnum.FAILED and message “Symbolic link loop detected”.

The work is performed in a fiber on the thread pool scheduler.

New in version 1.1.

Foundry.file_test(path, test)
Parameters:
Returns:

a [class`Dex`.Future] that resolves to a boolean of True if the test was met, otherwise resolves to False.

Return type:

Dex.Future

Similar to GLib.file_test() but performed on the thread pool and yields a future.

Foundry.flatten_list_model_new(model)
Parameters:

model (Gio.ListModel or None) –

Return type:

Gio.ListModel

Foundry.fuzzy_match(haystack, casefold_needle)
Parameters:
Returns:

True if haystack matched casefold_needle, otherwise False.

priority:

An optional location for the score of the match

Return type:

(bool, priority: int)

This helper function can do a fuzzy match for you giving a haystack and casefolded needle.

Casefold your needle using [func`GLib`.utf8_casefold] before running the query.

Score will be set with the score of the match upon success. Otherwise, it will be set to zero.

New in version 1.1.

Foundry.get_default_arch()
Return type:

str

Foundry.get_os_info(key_name)
Parameters:

key_name (str) –

Return type:

str

Foundry.get_version_string()
Return type:

str

Foundry.git_clone_error_quark()
Return type:

int

Foundry.git_initialize(directory, bare)
Parameters:
Returns:

a [class`Dex`.Future] that resolves to any value if successful or rejects with error.

Return type:

Dex.Future

Initializes a new git repository.

Foundry.git_uri_is_valid(uri_string)
Parameters:

uri_string (str) –

Return type:

bool

Foundry.host_file_get_contents_bytes(path)
Parameters:

path (str) – a path to a file on the host

Returns:

a [class`Dex`.Future] that resolves to a [struct`GLib`.Bytes] or rejects with error.

Return type:

Dex.Future

Foundry.init()
Returns:

a Dex.Promise that resolves when the library and dynamically loaded data has completed.

Return type:

Dex.Future

Initializes libfoundry which is completed once the resulting Dex.Future completes.

It is generally fine to use the library after calling this function but some data may not be fully loaded until it resolves. For example, if you need to sniff the user shell or other environment data, await this future before accessing user shell APIs.

Foundry.json_node_from_bytes(bytes)
Parameters:

bytes (GLib.Bytes) – a [struct`GLib`.Bytes]

Returns:

a [class`Dex`.Future] that resolves to a [struct`Json`.Node] or rejects with error.

Return type:

Dex.Future

Bytes to be deocded into a json node

Foundry.json_node_new_strv(strv)
Parameters:

strv (str) –

Return type:

Json.Node

Foundry.json_node_to_bytes(node)
Parameters:

node (Json.Node) –

Returns:

a future that resolves to a [struct`GLib`.Bytes] or rejects with error.

Return type:

Dex.Future

node must not be modified after calling this function until the future as resolved or rejected.

Foundry.json_node_to_bytes_full(node, pretty_print)
Parameters:
  • node (Json.Node) – a [struct`Json`.Node]

  • pretty_print (bool) – whether to pretty print the JSON output

Returns:

a future that resolves to a [struct`GLib`.Bytes] or rejects with error.

Return type:

Dex.Future

Converts node to a [struct`GLib`.Bytes] asynchronously.

If pretty_print is True, the output will be formatted with 4-space indentation for readability.

node must not be modified after calling this function until the future has resolved or rejected.

New in version 1.1.

Foundry.json_node_to_string(node, pretty_print)
Parameters:
  • node (Json.Node) – a [struct`Json`.Node]

  • pretty_print (bool) – whether to pretty print the JSON output

Returns:

a newly allocated string containing the JSON representation of node, or None on error.

Return type:

str

Converts node to a string synchronously using a [class`Json`.Generator].

If pretty_print is True, the output will be formatted with 4-space indentation for readability.

New in version 1.1.

Foundry.json_parser_load_from_file(parser, file)
Parameters:
Returns:

a [class`Dex`.Future] that resolves to a boolean

Return type:

Dex.Future

Loads file into parser and returns a future that resolves when that has completed.

Foundry.json_parser_load_from_stream(parser, stream)
Parameters:
Returns:

a [class`Dex`.Future].

Return type:

Dex.Future

Like Json.Parser.load_from_stream() but asynchronous and returns a [class`Dex`.Future] which can be awaited upon.

Foundry.key_file_new_from_file(file, flags)
Parameters:
Returns:

a [class`Dex`.Future] that resolves to a [struct`GLib`.KeyFile] or rejects with error

Return type:

Dex.Future

Similar to calling GLib.KeyFile.new() followed by a load function. This handles both construction and loading as well as doing parsing off of the main thread.

Foundry.key_file_new_merged(search_dirs, file, flags)
Parameters:
Returns:

a [class`Dex`.Future] that resolves to a [struct`GLib`.KeyFile] or rejects with error.

Return type:

Dex.Future

Foundry.list_model_await(model)
Parameters:

model (Gio.ListModel) –

Return type:

Dex.Future

Returns a future that resolves when the list has completed being populated or rejects with error.

Use Foundry.list_model_set_future() to affect the future that is used here.

If no future has been set, this function returns a future that has already resolved (e.g. True).

Foundry.list_model_set_future(model, future)
Parameters:

Sets the future that can be awaited for completion of populating the list model.

Foundry.map_list_model_new(model, map_func, *user_data)
Parameters:
Return type:

Gio.ListModel

Foundry.mkdir_with_parents(path, mode)
Parameters:
  • path (str) – a path to a directory to create

  • mode (int) – the mode for the directory such as 0750

Returns:

a [class`Dex`.Future] that resolves to 0 if successful, otherwise rejects with error.

Return type:

Dex.Future

Similar to GLib.mkdir_with_parents() but runs on a dedicated thread.

Deprecated since version 1.1.

Foundry.object_serializer_format_parse(string)
Parameters:

string (str) –

Return type:

Foundry.ObjectSerializerFormat

Foundry.path_collapse(path)
Parameters:

path (str) –

Returns:

A new path, possibly collapsed.

Return type:

str

This function will collapse a path that starts with the users home directory into a shorthand notation using ~/ for the home directory.

If the path does not have the home directory as a prefix, it will simply return a copy of path.

Foundry.path_expand(path)
Parameters:

path (str) –

Returns:

A newly allocated string containing the expansion. A copy of the input string upon failure to expand.

Return type:

str

This function will expand various “shell-like” features of the provided path using the POSIX wordexp(3) function. Command substitution will not be enabled, but path features such as ~user will be expanded.

Foundry.pipe(read_fd, write_fd, flags)
Parameters:
  • read_fd (int) –

  • write_fd (int) –

  • flags (int) –

Raises:

GLib.Error

Return type:

bool

Foundry.pty_create_producer(pty_consumer_fd, blocking)
Parameters:
  • pty_consumer_fd (int) –

  • blocking (bool) –

Raises:

GLib.Error

Return type:

int

Foundry.search_path_append(path, append)
Parameters:
  • path (str) –

  • append (str) –

Return type:

str

Foundry.search_path_prepend(path, prepend)
Parameters:
  • path (str) –

  • prepend (str) –

Return type:

str

Foundry.shell_get_default()
Returns:

a shell such as “/bin/sh”

Return type:

str

Gets the user preferred shell on the host.

If the background shell discovery has not yet finished due to slow or misconfigured getent on the host, this will provide a sensible fallback.

Foundry.shell_get_default_path()
Returns:

a string such as “/bin:/usr/bin”

Return type:

str

Gets the default $PATH on the system for the user on the host.

This value is sniffed during startup and will default to SAFE_PATH configured when building Builder until that value has been discovered.

Foundry.shell_supports_dash_c(shell)
Parameters:

shell (str) –

Return type:

bool

Foundry.shell_supports_dash_login(shell)
Parameters:

shell (str) – the name of the shell, such as sh or /bin/sh

Returns:

True if shell likely supports -l.

Return type:

bool

Checks if the shell is known to support login semantics. Originally, this meant --login, but now is meant to mean -l as more shells support -l than --login (notably dash).

Foundry.subprocess_communicate(subprocess, stdin_bytes)
Parameters:
Returns:

a [class`Dex`.Future] that resolves to a string

Return type:

Dex.Future

Like Gio.Subprocess.communicate() but only supports stdout and is returned as a future to GLib.Bytes.

Foundry.subprocess_communicate_utf8(subprocess, stdin_buf)
Parameters:
  • subprocess (Gio.Subprocess) – a #FoundrySubprocess

  • stdin_buf (str) – the standard input buffer

Returns:

a [class`Dex`.Future] that resolves to a string

Return type:

Dex.Future

Like Gio.Subprocess.communicate_utf8() but only supports stdout and is returned as a future to a string.

Foundry.subprocess_wait_check(subprocess, cancellable)
Parameters:
Returns:

a [class`Dex`.Future] that resolves to a boolean

Return type:

Dex.Future

If cancellable is cancelled, then subprocess will be force exited.