save_json (method)

create_folder(logger, save_path)[source]

Create the folder: “YYYY_mm_dd HH_MM_SS save_path”

fix_file_name(save_path, obj, is_folder, logger)[source]

Check save_path and modify it according to is_folder

Parameters
  • save_path (str) – File/Folder path

  • obj – Pyleecan object to save

  • is_folder (bool) – object is saved if folder mode (splitting Materials, Machine, Simulation in different files)

is_json_serializable(obj)[source]
has_as_dict(obj)[source]

Check if object has ‘as_dict’ method.

build_data(obj)[source]

Build a json serializable data structure of lists, dicts and pyleecan objects. Data that can not be serialized will be set to None. Tuples will also be None.

Parameters

obj – An object to serialize

Returns

A serializable data structure

Return type

data

save_split_obj(classes_tuple, obj, folder_path, logger)[source]

Scan the object attribute and save the object in a dedicated file

Parameters
  • classes_tuple (tuple) – tuple containing the classe names to save separately

  • obj (dict) – object dictionnary to save

  • folder_path (str) – directory to save all the files

  • logger (logging.Logger) – logger to display information

Returns

name – name of the file containing the object

Return type

str

save_separated_obj(classes_tuple, obj_dict, folder_path, logger)[source]

Save classes_tuple objects contained in obj_dict in separated files and modify obj_dict

Parameters
  • classes_tuple (tuple) – tuple containing the classe names to save separately

  • obj_dict (dict) – object dictionnary to save

  • folder_path (str) – directory to save all the files

  • logger (logging.Logger) – logger to display information

Returns

obj_dict – object dictionnary to save

Return type

dict

save_json(obj, save_path='', is_folder=False)[source]

Save the object to the save_path

Parameters
  • self – A pyleecan object

  • save_path (str) – path to the folder to save the object

  • is_folder (bool) – to split the object in different files: separate simulation machine and materials