graphai.core.utils.text.io module
- graphai.core.utils.text.io.log(msg, debug=True, color=None, indent=0)
Prints msg only if debug evaluates to True.
- class graphai.core.utils.text.io.Colors
Bases:
object
- pref = '\x1b['
- reset = '\x1b[0m'
- codes = {'black': '30m', 'blue': '34m', 'cyan': '36m', 'green': '32m', 'magenta': '35m', 'red': '31m', 'white': '37m', 'yellow': '33m'}
- graphai.core.utils.text.io.cprint(text, color='white', is_bold=False)
Print in a given color.
- Parameters:
text (str) – Text to print.
color (str) – Color to print in.
is_bold (bool) – Should print in bold case.
- graphai.core.utils.text.io.pprint(t, indent=0, inline=False, only_first=False)
Pretty print dictionary.
- Parameters:
t (dict) – Dictionary to print.
indent (int) – Number of spaces preceding every line.
inline (bool) – Skip preceding spaces for the first line.
only_first (bool) – If True, prints only an ellipsis to avoid big blocks.
- graphai.core.utils.text.io.read_json(filename)
Reads json file.
- Parameters:
filename (str) – Name of the file to be read.
- Returns:
Dictionary with the contents of the json file.
- Return type:
dict
- graphai.core.utils.text.io.save_json(data, filename)
Saves a dictionary as a json file.
- Parameters:
data (dict) – Dictionary to save.
filename (str) – Name of the file to be read.
- graphai.core.utils.text.io.mkdir(dirname)
Creates the given directory if it does not exist.