checkpoint package¶
Subpackages¶
Submodules¶
checkpoint.crypt module¶
- class checkpoint.crypt.Crypt(key, key_path='/home/runner/work/checkpoint/checkpoint', iterations=1)[source]¶
Bases:
object
Class to perform cryptographical operations
checkpoint.io module¶
- class checkpoint.io.IO(path=None, mode='a', ignore_dirs=None, lazy=True)[source]¶
Bases:
object
Class to perform Input/Output opreations.
Provides methods to perform various IO operations in the target directory.
- path¶
Path to the target directory
- Type:
str
- mode¶
Mode of operations, valid values are a: IO has all permissions (R/W/X/A) m: IO has moderate permissions (R/W/A) s: IO has limited permissions (R/A)
- Type:
str
- delete_dir(dir_name)[source]¶
Delete a sub directory in the root directory.
- Parameters:
dir_name (str) – Name of the sub directory
- get_file_extension(file_path)[source]¶
Get the extension from the file.
- Parameters:
file_path (str) – Path to the file
- make_dir(dir_name)[source]¶
Make a sub directory in the root directory.
- Parameters:
dir_name (str) – Name of the sub directory
- property mode¶
- property mode_mapping¶
- open(file, mode)[source]¶
Open a file in a given mode.
- Parameters:
file (str) – Name of the file
mode (str) – Mode of operation
- property path¶
- read(file, mode='r')[source]¶
Read the content of a file
- Parameters:
file (str) – Name of the file
mode (str, optional) – Mode of operation
checkpoint.readers module¶
Module that provides readers for different file extensions.
- class checkpoint.readers.ByteReader[source]¶
Bases:
Reader
Class to read byte files or files that can’t be decoded by utf-8 encoder
- class checkpoint.readers.Reader(valid_extensions=None)[source]¶
Bases:
object
Umbrella for all reader classes.
checkpoint.sequences module¶
- class checkpoint.sequences.CLISequence(sequence_name='CLI_Sequence', order_dict=None, arg_parser=None, args=None, terminal_log=False, env='UI')[source]¶
Bases:
Sequence
Sequence for the CLI environment.
- class checkpoint.sequences.CheckpointSequence(sequence_name, order_dict, root_dir, ignore_dirs, terminal_log=False, env='UI')[source]¶
Bases:
Sequence
Sequence to perform checkpoint operations.
- class checkpoint.sequences.IOSequence(sequence_name='IO_Sequence', order_dict=None, root_dir=None, ignore_dirs=None, num_cores=None, terminal_log=False, env='UI')[source]¶
Bases:
Sequence
Class to represent a sequence of IO operations.
- seq_encrypt_files(contents)[source]¶
Encrypt the read files.
- Parameters:
contents (dict) – Dictionary of file paths and their content.
- Returns:
Dictionary of file paths and their encrypted content.
- Return type:
dict
- seq_group_files(directory2files)[source]¶
Group files in the same directory.
- Parameters:
directory2files (dict) – Dictionary of directory names and their files.
- seq_map_readers(extensions_dict)[source]¶
Map the extensions to their respective Readers.
- Parameters:
extensions_dict (dict) – Dictionary of extensions and their files.
- Returns:
Dictionary of extensions and their Readers.
- Return type:
dict
- class checkpoint.sequences.Sequence(sequence_name, order_dict=None, terminal_log=False, env='UI')[source]¶
Bases:
object
Class to represent a sequence of operations.
- add_sequence_function(func, order=0)[source]¶
Add a member function to the sequence.
- Parameters:
func (method) – Function that is to be added to the sequence.
order (int, optional) – The order of the function in the sequence
- add_sub_sequence(sequence, order=0)[source]¶
Add a sub sequence to the current sequence.
- sequence: :class: Sequence
The sub sequence that is to be added
- order: int, optional
The order of the sub sequence in the sequence
- execute_sequence(execution_policy='decreasing_order', pass_args=False)[source]¶
Execute all functions in the current sequence.
- Parameters:
execution_policy (str) – The policy to be followed while executing the functions. Possible values are ‘increasing_order’ or ‘decreasing_order’.
pass_args (bool) – If True, the arguments of the executed function will be passed to the next function.
- property name¶
- property sequence_functions¶
checkpoint.utils module¶
Module that provides utility functions/classes.
- class checkpoint.utils.LogColors[source]¶
Bases:
object
Provides colors for terminal logs.
- BLUE = '[blue]'¶
- BOLD = '[bold]'¶
- CYAN = '[cyan]'¶
- ENDC = '[/]'¶
- ERROR = '[red]'¶
- HEADER = '[underline][bold]'¶
- SUCCESS = '[green]'¶
- UNDERLINE = '[underline]'¶
- WARNING = '[yellow]'¶
- class checkpoint.utils.Logger(file_path='logs.log', log_mode='t')[source]¶
Bases:
object
Provides logging utility functions.
- log(msg, colors=None, as_obj=False, timestamp=False, log_caller=False, log_type='INFO')[source]¶
Log a message.
- Parameters:
msg (str) – Message to log.
colors (list) – List of colors to use for the message.
as_obj (bool) – If True, the message will be logged as an object.
timestamp (bool) – If True, the current time will be added to the message.
log_caller (bool) – If True, the current function name will be added to the message.
log_type (str) – Type of log, can take values INFO, WARNING, ERROR, SUCCESS, etc.
- property log_mode¶