llnl package
Subpackages
- llnl.util package
- Subpackages
- llnl.util.tty package
SuppressOutput
debug()
debug_level()
die()
error()
error_enabled()
get_number()
get_timestamp()
get_yes_or_no()
hline()
info()
is_debug()
is_stacktrace()
is_verbose()
msg()
msg_enabled()
output_filter()
process_stacktrace()
set_debug()
set_error_enabled()
set_msg_enabled()
set_stacktrace()
set_timestamp()
set_verbose()
set_warn_enabled()
show_pid()
terminal_size()
verbose()
warn()
warn_enabled()
- Submodules
- llnl.util.tty.colify module
- llnl.util.tty.color module
- llnl.util.tty.log module
- llnl.util.tty.pty module
- llnl.util.tty package
- Submodules
- llnl.util.argparsewriter module
ArgparseRstWriter
ArgparseRstWriter.begin_command()
ArgparseRstWriter.begin_optionals()
ArgparseRstWriter.begin_positionals()
ArgparseRstWriter.begin_subcommands()
ArgparseRstWriter.description()
ArgparseRstWriter.end_optionals()
ArgparseRstWriter.end_positionals()
ArgparseRstWriter.format()
ArgparseRstWriter.optional()
ArgparseRstWriter.positional()
ArgparseRstWriter.usage()
ArgparseWriter
Command
- llnl.util.filesystem module
BaseDirectoryVisitor
FileFilter
FileList
HeaderList
LibraryList
ancestor()
can_access()
change_sed_delimiter()
chgrp()
chmod_x()
copy()
copy_mode()
copy_tree()
filter_file()
find()
find_all_headers()
find_headers()
find_libraries()
find_system_libraries()
fix_darwin_install_name()
force_remove()
force_symlink()
getuid()
install()
install_tree()
is_exe()
join_path()
keep_modification_time()
last_modification_time_recursive()
library_extensions
mkdirp()
partition_path()
prefixes()
remove_dead_links()
remove_directory_contents()
remove_if_dead_link()
remove_linked_tree()
rename()
set_executable()
set_install_permissions()
touch()
touchp()
traverse_tree()
unset_executable_mode()
visit_directory_tree()
working_dir()
- llnl.util.lang module
Devnull
GroupedExceptionForwarder
GroupedExceptionHandler
HashableMap
ObjectWrapper
RequiredAttributeError
Singleton
TypedMutableSequence
UnhashableArguments
attr_required()
attr_setdefault()
caller_locals()
check_kwargs()
classproperty
decorator_with_or_without_args()
dedupe()
done
elide_list()
ensure_last()
enum()
get_calling_module_name()
has_method()
in_function()
index_by()
key_ordering()
lazy_eq()
lazy_lexicographic_ordering()
lazy_lt()
list_modules()
load_module_from_file()
match_predicate()
memoized()
nullcontext()
pretty_date()
pretty_seconds()
pretty_seconds_formatter()
pretty_string_to_date()
stable_args()
stable_partition()
star()
tuplify()
union_dicts()
uniq()
- llnl.util.link_tree module
- llnl.util.lock module
- llnl.util.multiproc module
- llnl.util.symlink module
- Subpackages
Submodules
llnl.path module
Path primitives that just require Python standard library.
- llnl.path.convert_to_platform_path(path: str) str [source]
Converts the input path to the current platform’s native style.
- llnl.path.convert_to_windows_path(path: str) str [source]
Converts the input path to Windows style.
- llnl.path.format_os_path(path: str, mode: int = 0) str [source]
Formats the input path to use consistent, platform specific separators.
Absolute paths are converted between drive letters and a prepended ‘/’ as per platform requirement.
- Parameters:
path – the path to be normalized, must be a string or expose the replace method.
mode – the path file separator style to normalize the passed path to. Default is unix style, i.e. ‘/’
- llnl.path.path_to_os_path(*parameters: str) List[str] [source]
Takes an arbitrary number of positional parameters, converts each argument of type string to use a normalized filepath separator, and returns a list of all values.
- llnl.path.system_path_filter(_func=None, arg_slice: slice | None = None)[source]
Filters function arguments to account for platform path separators. Optional slicing range can be specified to select specific arguments
This decorator takes all (or a slice) of a method’s positional arguments and normalizes usage of filepath separators on a per platform basis.
Note: **kwargs, urls, and any type that is not a string are ignored so in such cases where path normalization is required, that should be handled by calling path_to_os_path directly as needed.
- Parameters:
arg_slice – a slice object specifying the slice of arguments in the decorated method over which filepath separators are normalized
llnl.string module
String manipulation functions that do not have other dependencies than Python standard library
- llnl.string.comma_and(sequence: List[str]) str [source]
Return a string with all the elements of the input joined by comma, but the last one (which is joined by ‘and’).
- llnl.string.comma_or(sequence: List[str]) str [source]
Return a string with all the elements of the input joined by comma, but the last one (which is joined by ‘or’).
- llnl.string.plural(n: int, singular: str, plural: str | None = None, show_n: bool = True) str [source]
Pluralize <singular> word by adding an s if n != 1.
- Parameters:
n – number of things there are
singular – singular form of word
plural – optional plural form, for when it’s not just singular + ‘s’
show_n – whether to include n in the result string (default True)
- Returns:
“1 thing” if n == 1 or “n things” if n != 1
llnl.url module
URL primitives that just require Python standard library.
- llnl.url.allowed_archive(path_or_url: str) bool [source]
Returns true if the input is a valid archive, False otherwise.
- llnl.url.check_and_remove_ext(path: str, *, extension: str) str [source]
Returns the input path with the extension removed, if the extension is present in path. Otherwise, returns the input unchanged.
- llnl.url.compression_ext_from_compressed_archive(extension: str) str | None [source]
Returns compression extension for a compressed archive
- llnl.url.determine_url_file_extension(path: str) str [source]
This returns the type of archive a URL refers to. This is sometimes confusing because of URLs like:
Where the URL doesn’t actually contain the filename. We need to know what type it is so that we can appropriately name files in mirrors.
- llnl.url.expand_contracted_extension(extension: str) str [source]
Returns the expanded version of a known contracted extension.
This function maps extensions like “.tgz” to “.tar.gz”. On unknown extensions, return the input unmodified.
- llnl.url.expand_contracted_extension_in_path(path_or_url: str, *, extension: str | None = None) str [source]
Returns the input path or URL with any contraction extension expanded.
- Parameters:
path_or_url – path or URL to be expanded
extension – if specified, only attempt to expand that extension
- llnl.url.extension_from_path(path_or_url: str | None) str | None [source]
Tries to match an allowed archive extension to the input. Returns the first match, or None if no match was found.
- Raises:
ValueError – if the input is None
- llnl.url.find_list_urls(url: str) Set[str] [source]
Find good list URLs for the supplied URL.
By default, returns the dirname of the archive path.
Provides special treatment for the following websites, which have a unique list URL different from the dirname of the download URL:
GitHub
https://github.com/<repo>/<name>/releases
GitLab
https://gitlab.*/<repo>/<name>/tags
BitBucket
https://bitbucket.org/<repo>/<name>/downloads/?tab=tags
CRAN
PyPI
https://pypi.org/simple/<name>/
LuaRocks
https://luarocks.org/modules/<repo>/<name>
Note: this function is called by spack versions, spack checksum, and spack create, but not by spack fetch or spack install.
- llnl.url.has_extension(path_or_url: str, ext: str) bool [source]
Returns true if the extension in input is present in path, false otherwise.
- llnl.url.remove_extension(path_or_url: str, *, extension: str) str [source]
Returns the input with the extension removed
- llnl.url.split_url_extension(url: str) Tuple[str, ...] [source]
Some URLs have a query string, e.g.:
https://github.com/losalamos/CLAMR/blob/packages/PowerParser_v2.0.7.tgz?raw=true
http://www.apache.org/dyn/closer.cgi?path=/cassandra/1.2.0/apache-cassandra-1.2.0-rc2-bin.tar.gz
https://gitlab.kitware.com/vtk/vtk/repository/archive.tar.bz2?ref=v7.0.0
In (1), the query string needs to be stripped to get at the extension, but in (2) & (3), the filename is IN a single final query argument.
This strips the URL into three pieces:
prefix
,ext
, andsuffix
. The suffix contains anything that was stripped off the URL to get at the file extension. In (1), it will be'?raw=true'
, but in (2), it will be empty. In (3) the suffix is a parameter that follows after the file extension, e.g.:('https://github.com/losalamos/CLAMR/blob/packages/PowerParser_v2.0.7', '.tgz', '?raw=true')
('http://www.apache.org/dyn/closer.cgi?path=/cassandra/1.2.0/apache-cassandra-1.2.0-rc2-bin', '.tar.gz', None)
('https://gitlab.kitware.com/vtk/vtk/repository/archive', '.tar.bz2', '?ref=v7.0.0')
- llnl.url.split_url_on_sourceforge_suffix(url: str) Tuple[str, ...] [source]
If the input is a sourceforge URL, returns base URL and “/download” suffix. Otherwise, returns the input URL and an empty string.
- llnl.url.strip_compression_extension(path_or_url: str, ext: str | None = None) str [source]
Strips the compression extension from the input, and returns it. For instance, “foo.tgz” becomes “foo.tar”.
If no extension is given, try a default list of extensions.
- Parameters:
path_or_url – input to be stripped
ext – if given, extension to be stripped
- llnl.url.strip_extension(path_or_url: str, *, extension: str | None = None) str [source]
If a path contains the extension in input, returns the path stripped of the extension. Otherwise, returns the input path.
If extension is None, attempts to strip any allowed extension from path.
- llnl.url.strip_query_and_fragment(url: str) Tuple[str, str] [source]
Strips query and fragment from a url, then returns the base url and the suffix.
- Parameters:
url – URL to be stripped
- Raises:
ValueError – when there is any error parsing the URL
- llnl.url.strip_version_suffixes(path_or_url: str) str [source]
Some tarballs contain extraneous information after the version:
bowtie2-2.2.5-source
libevent-2.0.21-stable
cuda_8.0.44_linux.run
These strings are not part of the version number and should be ignored. This function strips those suffixes off and returns the remaining string. The goal is that the version is always the last thing in
path
:bowtie2-2.2.5
libevent-2.0.21
cuda_8.0.44
- Parameters:
path_or_url – The filename or URL for the package
- Returns:
The
path
with any extraneous suffixes removed