handle_paths#
- mochada_kit.tables.handle_paths(data_path, out_path=None, load_path=None, out_name=None, title=None, theme_name='plasma', copy_theme_to_local=False, scale=None, return_out_base_only=False)#
Handle paths for input and output, collects strings to be written at the top and bottom of the puml code, and supplies the data read from the json/yaml source file as a dict, if required.
- Parameters:
- data_path
STR
orpathlib.Path
Absolute path or path relative to the current working directory pointing to a json or yaml file containing the CHADA data. If data_path points to a json file, the format of the file must be based on mochada_kit/templates/chada_tables_template.json. If data_path points to a yaml file, the format of the file must be based on mochada_kit/templates/chada_tables_template.yaml.
- out_path
STR
,pathlib.Path
orpython:None
,optional
Specifies the folder where the plantuml code file will be saved. This allows the puml code and json/yaml file to be located in different folders, if desired. If None, the puml code is saved in the same folder as the data_path. If not None, if it is a relative path, it is assumed to be relative to data_path. An absolute path can also be supplied. The default is None.
- load_path
STR
,pathlib.Path
orpython:None
,optional
If data_path points to a json file: if load_path = None, the json data will be directly written into the puml code rather than being loaded dynamically. If load_path is not None, load_path is the either the absolute path to the json file containing the data OR the relative path from out_path pointing to the data_path. In this case, the json data will be loaded dynamically and not written into the puml code. If data_path points to a yaml file: load_path has no effect, the data must always be written into the puml code. The default is None.
- out_name
STR
orpython:None
,optional
By default, the puml code output will have the same filename as the json/yaml input. To use a different filename for the output, please specify a string as out_name. The default is None.
- title
STR
,LIST
orpython:None
,optional
Either a string or list of strings defining a title for the plot, or None, in which case, no title will be shown. If a list of strings is supplied, each item in the list will appear in a new row of the title. You can apply CREOLE syntax to the title strings e.g. to change the colour, make a table, make a link etc. All options are here: https://plantuml.com/creole. The default is None.
- theme_name
STR
,optional
The name of one of the bespoke MOCHADA themes in the default folder given by __THEMES_DIR__. Only the part of the name after “MOCHADA-” is needed, i.e. to apply the theme ‘MOCHADA-plasma’, theme_name=’plasma’. The default is ‘plasma’.
- scale
STR
,INT
orFLOAT
,optional
A parameter which helps to scale the diagram for png output. NOT necessary to use this with svg output as these can be scaled to any size later. Docs are here: https://plantuml.com/commons#4252b72e6ebcd4d4.
Common values could be:
1.5 (to set the aspect ratio),
“1/3” (to set the aspect ratio)
“1024 width” (to set the width to 1024 pixels)
“100*200” (to set the output size to 100 by 200 pixels).
- return_out_base_only
BOOL
,optional
If True, return only out_base. This is useful if you just want to construct the full path to the puml code, e.g. if you want to run it and generate a diagram. If False, complete the function and return all returns. The default is False.
- data_path
- Returns:
- t_d
DICT
orpython:None
Either the data for the tables read from file or None.
- out_base
pathlib.Path
Path to the stem of the output puml code file i.e. everything except the file extension.
- top
LIST
List of strings to be written at the top of the puml code.
- bottom
LIST
List of strings to be written at the bottom of the puml code.
- t_d