dtoolcore.utils¶
Utility functions for dtoolcore.
-
dtoolcore.utils.
base64_to_hex
(input_string)[source]¶ Retun the hex encoded version of the base64 encoded input string.
-
dtoolcore.utils.
cross_platform_getuser
(is_windows, no_username_in_env)[source]¶ Return the username or “unknown”.
The function returns “unknown” if the platform is windows and the username environment variable is not set.
-
dtoolcore.utils.
generous_parse_uri
(uri)[source]¶ Return a urlparse.ParseResult object with the results of parsing the given URI. This has the same properties as the result of parse_uri.
When passed a relative path, it determines the absolute path, sets the scheme to file, the netloc to localhost and returns a parse of the result.
-
dtoolcore.utils.
get_config_value
(key, config_path=None, default=None)[source]¶ Get a configuration value.
Preference: 1. From environment 2. From JSON configuration file supplied in
config_path
argument 3. The default supplied to the functionParameters: - key – name of lookup value
- config_path – path to JSON configuration file
- default – default fall back value
Returns: value associated with the key
-
dtoolcore.utils.
get_config_value_from_file
(key, config_path=None, default=None)[source]¶ Return value if key exists in file.
Return default if key not in config.
-
dtoolcore.utils.
handle_to_osrelpath
(handle, is_windows=False)[source]¶ Return OS specific relpath from handle.
-
dtoolcore.utils.
mkdir_parents
(path)[source]¶ Create the given directory path. This includes all necessary parent directories. Does not raise an error if the directory already exists. :param path: path to create
-
dtoolcore.utils.
name_is_valid
(name)[source]¶ Return True if the dataset name is valid.
The name can only be 80 characters long. Valid characters: Alpha numeric characters [0-9a-zA-Z] Valid special characters: - _ .
-
dtoolcore.utils.
relpath_to_handle
(relpath, is_windows=False)[source]¶ Return handle from relpath.
Handles are Unix style relpaths. Converts Windows relpath to Unix style relpath. Strips “./” prefix.
-
dtoolcore.utils.
sanitise_uri
(uri)[source]¶ Return fully qualified uri from the input, which might be a relpath.
-
dtoolcore.utils.
sha1_hexdigest
(input_string)[source]¶ Return hex digest of the sha1sum of the input_string.