uesgraphs.utilities

Utilies: Collection of all utility functions that are useful in several classes.

Functions

default_json_path()

Creates default output file UESgraphOutput in the user dictionary.

get_attribute_case_insensitive(row, ...)

Retrieve an attribute value from a dictionary, handling case insensitivity.

make_workspace([name_workspace])

Creates a local workspace with given name

name_uesgraph([name_workspace])

Gives the uesgraph a name

set_up_file_logger(name[, log_dir, level])

Set up a full file+console logger for major functions.

set_up_terminal_logger(name[, level])

Set up a simple console-only logger for small functions.

uesgraphs.utilities.default_json_path()[source]

Creates default output file UESgraphOutput in the user dictionary.

Paramters

UESgraph_defaul_pathstr

Path, where uesgraph files will be saved.

returns:

path – Path, where to save uesgraph files

rtype:

str

uesgraphs.utilities.make_workspace(name_workspace=None)[source]

Creates a local workspace with given name

If no name is given, the general workspace directory will be used

Parameters:

name_workspace (str) – Name of the local workspace to be created

Returns:

workspace – Full path to the new workspace

Return type:

str

uesgraphs.utilities.name_uesgraph(name_workspace=None)[source]

Gives the uesgraph a name

Parameters:

name_workspace (str) – Name of the workspace of the current uesgraph

Returns:

name_uesgraph – Name of the uesgraph according to its workspace

Return type:

str

uesgraphs.utilities.set_up_terminal_logger(name: str, level: int = 20) Logger[source]

Set up a simple console-only logger for small functions.

Parameters:
  • name – Logger name

  • level – Logging level (default: INFO)

Returns:

Configured console logger

uesgraphs.utilities.set_up_file_logger(name: str, log_dir: str | None = None, level: int = 40) Logger[source]

Set up a full file+console logger for major functions.

Parameters:
  • name – Logger name

  • log_dir – Directory for log files (default: temp directory)

  • level – Logging level (default: ERROR)

Returns:

Configured file+console logger

uesgraphs.utilities.get_attribute_case_insensitive(row, attribute_name)[source]

Retrieve an attribute value from a dictionary, handling case insensitivity.

This function tries to access the attribute with the original name first, then attempts to access it with different capitalizations if the original attempt fails.

Parameters:
  • row (dict) – The dictionary containing the data

  • attribute_name (str) – The base name of the attribute to retrieve

Returns:

The value associated with the attribute, or None if not found