json2graph.modules.input_output

IO functions used in diverse occasions.

Module Contents

Functions

create_directory_if_not_exists(directory_path, ...)

Check if the directory that has the path received as argument exists. If it does, do nothing. If it does not, create it.

safe_load_json_file(json_path)

Safely loads the JSON file inputted by the user as an argument into a dictionary.

safe_write_graph_file(ontouml_graph, output_file_path, ...)

Safely saves the graph into a file in the informed destination with the desired syntax.

Attributes

LOGGER

json2graph.modules.input_output.LOGGER
json2graph.modules.input_output.create_directory_if_not_exists(directory_path, file_description)

Check if the directory that has the path received as argument exists. If it does, do nothing. If it does not, create it.

Parameters:
  • directory_path (str) – Path to the directory to be created (if it does not exist).

  • file_description (str) –

Return type:

None

json2graph.modules.input_output.safe_load_json_file(json_path)

Safely loads the JSON file inputted by the user as an argument into a dictionary.

Parameters:

json_path (str) – Path to the JSON file to be loaded.

Returns:

Dictionary with loaded JSON’s data.

Return type:

dict

json2graph.modules.input_output.safe_write_graph_file(ontouml_graph, output_file_path, syntax)

Safely saves the graph into a file in the informed destination with the desired syntax.

Parameters:
  • ontouml_graph (Graph) – Graph compliant with the OntoUML Vocabulary.

  • output_file_path (str) – Complete path of the output file to be created (including name and extension).

  • syntax (str) – Syntax to be used for saving the ontology file.

Return type:

None