Functions¶
Details¶
- Foundry.action_mixin_get_enabled(instance, action)¶
- Foundry.action_mixin_set_enabled(instance, action, enabled)¶
- Foundry.dap_protocol_unwrap_error(completed, user_data)¶
- Parameters:
completed (
Dex.Future) –
- Return type:
- Foundry.file_canonicalize(file)¶
- Parameters:
file (
Gio.File) – a [iface`Gio`.File]- Raises:
- Return type:
- Foundry.file_find_in_ancestors(file, name)¶
- Parameters:
- Returns:
a [class`Dex`.Future] that resolves to a [iface`Gio`.File] or rejects with error,
- Return type:
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 descendantsmax_depth (
int) – the max depth to recurse
- Returns:
a [class`Dex`.Future]
- Return type:
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:
- Returns:
a [class`Dex`.Future] that resolves to a [struct`GLib`.PtrArray] of [iface`Gio`.File].
- Return type:
Locates files starting from file matching pattern.
- Foundry.file_is_in(file, toplevel)¶
- Foundry.file_list_children_typed(file, file_type, attributes)¶
- Parameters:
file (
Gio.File) – a [iface`Gio`.File]file_type (
Gio.FileType) –attributes (
str) –
- Returns:
a [class`Dex`.Future] that resolves to a [struct`GLib`.PtrArray] of [iface`Gio`.File] or rejects with error.
- Return type:
- Foundry.file_query_exists_nofollow(file)¶
- Parameters:
file (
Gio.File) – a [iface`Gio`.File]- Returns:
a future that resolves to a boolean
- Return type:
Resolves to true if file exists.
Does not follow symlink.
- Foundry.file_read_link(file)¶
- 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:
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.
- Foundry.file_read_link_recurse(file, max_depth)¶
- Parameters:
- Returns:
a [class`Dex`.Future] that resolves to a [iface`Gio`.File], or rejects with [struct`GLib`.Error]
- Return type:
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.FAILEDand 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:
path (
str) – the path to checktest (
GLib.FileTest) – theGLib.FileTestto check for
- Returns:
a [class`Dex`.Future] that resolves to a boolean of
Trueif the test was met, otherwise resolves toFalse.- Return type:
Similar to
GLib.file_test() but performed on the thread pool and yields a future.
- Foundry.flatten_list_model_new(model)¶
- Parameters:
model (
Gio.ListModelorNone) –- Return type:
- Foundry.fuzzy_match(haystack, casefold_needle)¶
- Parameters:
casefold_needle (
str) – AGLib.utf8_casefold() version of the needle.
- Returns:
Trueif haystack matched casefold_needle, otherwiseFalse.- priority:
An optional location for the score of the match
- Return type:
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.git_initialize(directory, bare)¶
- Parameters:
- Returns:
a [class`Dex`.Future] that resolves to any value if successful or rejects with error.
- Return type:
Initializes a new git repository.
- 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:
- Foundry.init()¶
- Returns:
a
Dex.Promisethat resolves when the library and dynamically loaded data has completed.- Return type:
Initializes libfoundry which is completed once the resulting
Dex.Futurecompletes.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:
Bytes to be deocded into a 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:
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:
- Returns:
a future that resolves to a [struct`GLib`.Bytes] or rejects with error.
- Return type:
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:
- Returns:
a newly allocated string containing the JSON representation of node, or
Noneon error.- Return type:
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:
parser (
Json.Parser) – a [class`Json`.Parser]file (
Gio.File) – a [iface`Gio`.File]
- Returns:
a [class`Dex`.Future] that resolves to a boolean
- Return type:
Loads file into parser and returns a future that resolves when that has completed.
- Foundry.json_parser_load_from_stream(parser, stream)¶
- Parameters:
parser (
Json.Parser) – a [class`Json`.Parser]stream (
Gio.InputStream) – a [class`Gio`.InputStream]
- Returns:
a [class`Dex`.Future].
- Return type:
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:
file (
Gio.File) – a [iface`Gio`.File]flags (
GLib.KeyFileFlags) – flags that may affect loading
- Returns:
a [class`Dex`.Future] that resolves to a [struct`GLib`.KeyFile] or rejects with error
- Return type:
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:
search_dirs (
str) –file (
str) –flags (
GLib.KeyFileFlags) –
- Returns:
a [class`Dex`.Future] that resolves to a [struct`GLib`.KeyFile] or rejects with error.
- Return type:
- Foundry.list_model_await(model)¶
- Parameters:
model (
Gio.ListModel) –- Return type:
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:
model (
Gio.ListModel) –future (
Dex.FutureorNone) – a [class`Dex`.Future] orNone
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:
model (
Gio.ListModelorNone) – a [iface`Gio`.ListModel]map_func (
Foundry.ListModelMapFunc) –
- Return type:
- Foundry.mkdir_with_parents(path, mode)¶
- Parameters:
- Returns:
a [class`Dex`.Future] that resolves to 0 if successful, otherwise rejects with error.
- Return type:
Similar to
GLib.mkdir_with_parents() but runs on a dedicated thread.Deprecated since version 1.1.
- Foundry.path_collapse(path)¶
-
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:
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:
- Raises:
- Return type:
- Foundry.pty_create_producer(pty_consumer_fd, blocking)¶
- Parameters:
- Raises:
- Return type:
- Foundry.search_path_prepend(path, prepend)¶
- Foundry.shell_get_default()¶
- Returns:
a shell such as “/bin/sh”
- Return type:
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:
Gets the default
$PATHon the system for the user on the host.This value is sniffed during startup and will default to
SAFE_PATHconfigured when building Builder until that value has been discovered.
- Foundry.shell_supports_dash_login(shell)¶
- Parameters:
shell (
str) – the name of the shell, such asshor/bin/sh- Returns:
Trueif shell likely supports-l.- Return type:
Checks if the shell is known to support login semantics. Originally, this meant
--login, but now is meant to mean-las more shells support-lthan--login(notably dash).
- Foundry.subprocess_communicate(subprocess, stdin_bytes)¶
- Parameters:
subprocess (
Gio.Subprocess) – a #FoundrySubprocessstdin_bytes (
GLib.BytesorNone) – the standard input buffer
- Returns:
a [class`Dex`.Future] that resolves to a string
- Return type:
Like
Gio.Subprocess.communicate() but only supports stdout and is returned as a future toGLib.Bytes.
- Foundry.subprocess_communicate_utf8(subprocess, stdin_buf)¶
- Parameters:
subprocess (
Gio.Subprocess) – a #FoundrySubprocessstdin_buf (
str) – the standard input buffer
- Returns:
a [class`Dex`.Future] that resolves to a string
- Return type:
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:
subprocess (
Gio.Subprocess) – a [class`Gio`.Subprocess]cancellable (
Dex.Cancellable) – a [class`Dex`.Cancellable]
- Returns:
a [class`Dex`.Future] that resolves to a boolean
- Return type:
If cancellable is cancelled, then subprocess will be force exited.