gwkokab.analysis.utils.common¶

Functions¶

expand_arguments(→ List[str])

Extend the argument with a number of strings.

read_json(→ Dict)

Read json file and return.

write_json(→ None)

Write a dictionary to a json file.

Module Contents¶

gwkokab.analysis.utils.common.expand_arguments(arg: str, n: int) List[str]¶

Extend the argument with a number of strings.

>>> expand_arguments("physics", 3)
["physics_0", "physics_1", "physics_2"]
Parameters:
  • arg (str) – argument to extend

  • n (int) – number of strings to extend

Returns:

list of extended arguments

Return type:

List[str]

gwkokab.analysis.utils.common.read_json(json_file: str) Dict¶

Read json file and return.

Parameters:

json_file (str) – path of the json file

Returns:

json file content as dict

Return type:

dict

Raises:

ValueError – If the file is not found or if the file is not a valid json file

gwkokab.analysis.utils.common.write_json(json_file: str, content: Dict) None¶

Write a dictionary to a json file.

Parameters:
  • json_file (str) – path of the json file

  • content (dict) – content to write to the json file

Raises:

ValueError – If the file is not writable or if the content is not a valid json serializable object