The Utils module
The utils module is the summary of all functionality needed by Nester.
We are planning to modularize and clean it up in the future.
This module provides all functions necessary for Nester’s three main utilities:
create
validate
clean
- nester.utils.clean(projectname)
Cleanup the given project.
- Parameters:
projectname – The name of the project
- nester.utils.create_structure(structure, base_path, projectname)
Iterate through the items in the structure and create directories and files based on that structure
- Parameters:
structure (dict) – the directory structure from the template
base_path (Path) – The current directory
projectname (str) – the name of the project
- Returns:
None
- nester.utils.detect_languages()
Look through the templates folder to find which languages we have templates for
- Returns:
List of languages that have template folders
- Return type:
list
- nester.utils.get_project_dir(projectname, should_create)
Get the project root directory. If the name of the current working directory does not match the projectname, a new directory will be created with the given projectname inside which the project is created.
- Parameters:
projectname (str) – the name of the project
should_create (bool) – if directory should be created or not
- Returns:
the path of the project root
- nester.utils.load_json(language, projectname)
Load the template for the project.
- Parameters:
language (str) – the programming language of the project
projectname (str) – the name of the project
- Return structure:
Returns the structure of the given language as a dict
- Return type:
dict
- nester.utils.validate_structure(structure, projectname, base_path)
Iterates through the subdirectories of the current directory and validates if it is a subset of the schema for the given language.
- Parameters:
structure (dict) – The directory structure from the template
base_path (Path) – The current directory
projectname (str) – The name of the project
- Returns:
True or False depending on if the structure corresponds to the schema or not
- Return type:
bool