extract_source_code Module#

extract_source_code.py

This module provides utilities for cleaning up project directories by removing unwanted files and directories, and clearing Jupyter Notebook outputs.

utils.extract_source_code.clean_directory(target_dir: str) None[source]#

Walks the directory to clean files, remove folders, and clear notebooks.

Parameters:

target_dir (str) – The root directory to start cleaning from.

utils.extract_source_code.clear_jupyter_outputs(file_path: str) None[source]#

Parses a Jupyter Notebook as JSON and clears cell outputs/execution counts.

Parameters:

file_path (str) – The path to the Jupyter Notebook file.

utils.extract_source_code.contains_template_html(dir_path: str) bool[source]#

Checks if a directory recursively contains any ‘template.html’ file.

Parameters:

dir_path (str) – The path to the directory to check.

Returns:

True if a matching template file is found, False otherwise.

Return type:

bool

utils.extract_source_code.should_delete_dir(name: str, path: str) bool[source]#

Encapsulates the logic for directory deletion criteria.

Parameters:
  • name (str) – The name of the directory.

  • path (str) – The full path to the directory.

Returns:

True if the directory should be deleted, False otherwise.

Return type:

bool