ntt.utils package#

Submodules#

ntt.utils.constants module#

ntt.utils.debug module#

ntt.utils.debug.debug(*args)#

Prints the provided arguments as a space-separated string.

Parameters:

*args – Any number of arguments to be printed.

Returns:

None

Example

>>> debug("Hello", "world", 42)
Hello world 42

ntt.utils.dicts module#

ntt.utils.dicts.get_index(list_dict, key, value)#

Get the index of a dictionary in a list of dictionaries

Parameters:
  • list_dict (_type_) – _description_

  • key (_type_) – _description_

  • value (_type_) – _description_

Returns:

_description_

Return type:

_type_

ntt.utils.dicts.pretty_json(path_json)#

Open the same file for writing, and write the pretty-printed JSON to disk.

Parameters:

path_json (_type_) – _description_

Raises:

FileNotFoundError – _description_

Returns:

_description_

Return type:

_type_

ntt.utils.files module#

ntt.utils.files.copy_file(file_path_in, file_name_in, file_path_out, file_name_out, overwrite=False)#
ntt.utils.files.create_folder(folder_path)#
ntt.utils.files.delete_and_create_folder(path)#
ntt.utils.files.delete_folder(path: str)#

Deletes a folder and all its contents.

Parameters:

path (str) – path to the folder to be deleted

Raises:

Exception – if the path is not a folder

Returns:

path to the deleted folder

Return type:

str

ntt.utils.files.generate_shortcut_url(file_path='file.url', url='https://www.google.com')#
ntt.utils.files.remove_file_if_exists(file_path)#
ntt.utils.files.touch(file_path)#

Create an empty file or update the file’s timestamp.

Parameters:

file_path (str) – Path to the file to touch.

ntt.utils.index module#

ntt.utils.index.generate_index(folder_path, index_filename='index.json', max_depth=None)#

Generates an index JSON file for all folders and files in the given folder.

Parameters:
  • folder_path (str) – Path to the input folder.

  • index_filename (str) – Name of the index JSON file. Default is “index.json”.

  • max_depth (int or None) – Maximum depth of recursion. None for unlimited depth.

Returns:

None

ntt.utils.json_to_text module#

ntt.utils.json_to_text.Recursive_json(data, degre=0, texte_out='')#

Recursively convert a JSON object to a text file.

Parameters:
  • data – The JSON object to convert.

  • degre – The current degree of recursion.

  • texte_out – The text to append to.

Returns:

The text representation of the JSON object.

ntt.utils.json_to_text.recursive_json(data, degre=0, texte_out='')#

Recursively convert a JSON object to a text file.

Parameters:
  • data – The JSON object to convert.

  • degre – The current degree of recursion.

  • texte_out – The text to append to.

Returns:

The text representation of the JSON object.

ntt.utils.random_utils module#

ntt.utils.random_utils.random_translate_direction(nb_direction=4)#

ntt.utils.strings module#

ntt.utils.strings.generate_random_string(length=8)#

generate a string of random characters like yHgFZBrK

ntt.utils.strings.generate_uuid4()#

generate random id like d6799325-ba91-4cee-9ddc-3d12464e6c52

ntt.utils.temporal module#

ntt.utils.temporal.calculate_temporal_accuracy(actual_value, predicted_value)#

temporal accuracy = 1 - (error / actual_value)

ntt.utils.text_to_json module#

ntt.utils.text_to_json.Recursive_liste_json(liste, degre=0)#

Recursively convert a list of strings to a JSON object.

Parameters:
  • liste – The list of strings to convert.

  • degre – The current degree of recursion.

Returns:

The JSON object.

ntt.utils.text_to_json.Texte_to_json(texte)#

Convert a text file to a JSON object.

Parameters:

texte – The text file to convert.

Returns:

The JSON object.

ntt.utils.text_to_json.recursive_liste_json(liste, degre=0)#

Recursively convert a list of strings to a JSON object.

Parameters:
  • liste – The list of strings to convert.

  • degre – The current degree of recursion.

Returns:

The JSON object.

ntt.utils.text_to_json.texte_to_json(texte)#

Convert a text file to a JSON object.

Parameters:

texte – The text file to convert.

Returns:

The JSON object.