The tech_review.py module#

Summary#

Filenames

Enum of files to check.

Directories

Enum of directories to check.

check_dirs_exist

Check folders exist in the root of the git repository.

check_config_file

Check naming convention, version, author, and maintainer information.

check_pyproject_toml

Check pyproject.toml file for correct naming convention, version, author, and maintainer.

check_auth_maint

Check if the author and maintainer names and emails are the same.

check_setup_py

Check setup.py file for correct naming convention, version, author, and maintainer.

download_license_json

Download the licenses.json file and restructure it to only include the license ID and name.

restructure_json

Remove extra information from licenses.json file.

check_file_exists

Check files exist. If they do not exist, create them using jinja templates.

generate_file_from_jinja

Generate file using jinja templates.

write_content

Write generated content from jinja template to a file.

check_file_content

Check the file content of the LICENSE and CONTRIBUTORS.md files.

main

Check files for technical review.

HOOK_PATH

Location of the pre-commit hook on your system.

LICENSES_JSON

JSON file containing licenses information.

DEFAULT_AUTHOR_MAINT_NAME

Default name of project authors and maintainers.

DEFAULT_AUTHOR_MAINT_EMAIL

Default email of project authors and maintainers.

DEFAULT_START_YEAR

Default start year of the repository.

DEFAULT_LICENSE

Default license of the repository

JSON_URL

URL to retrieve list of license IDs and names.

Description#

Module for checking if a repository is compliant with required files in the technical review.

Module detail#

tech_review.check_dirs_exist(repo_path: str, is_compliant: bool, directories: list) bool#

Check folders exist in the root of the git repository.

Parameters:
repo_path: str

Path of the repository being checked.

is_compliant: bool

True if the repository is compliant. False if the repository is not compliant.

directories: list

List of directories to check if they exist in the repository.

Returns:
bool

True if all directories exist. False if a directory did not exist and was created.

tech_review.check_config_file(repo_path: str, author_maint_name: str, author_maint_email: str, is_compliant: bool, non_compliant_name: bool) bool#

Check naming convention, version, author, and maintainer information.

Parameters:
repo_path: str

Path of the repository being checked.

author_maint_name: str

Project author and maintainer’s name.

author_maint_email: str

Project author and maintainer’s email.

is_compliant: bool

True if the repository is compliant. False if the repository is not compliant.

non_compliant_name: bool

True if the repository’s name is not in the form ansys-- and it is permitted. False if the repository’s name is in the form ansys--.

Returns:
bool

True if all files exist and contain the correct content. False if a file was created or did not contain the correct content.

tech_review.check_pyproject_toml(repo_path: str, author_maint_name: str, author_maint_email: str, is_compliant: bool, non_compliant_name: bool) tuple#

Check pyproject.toml file for correct naming convention, version, author, and maintainer.

Parameters:
repo_path: str

Path of the repository being checked.

author_maint_name: str

Project author and maintainer’s name.

author_maint_email: str

Project author and maintainer’s email.

is_compliant: bool

True if the repository is compliant. False if the repository is not compliant.

non_compliant_name: bool

True if the repository’s name is not in the form ansys-- and it is permitted. False if the repository’s name is in the form ansys--.

Returns:
bool

True if the pyproject.toml file’s information was correct. False if the pyproject.toml file had missing or incorrect information.

str

Name of the project from the pyproject.toml file.

tech_review.check_auth_maint(project_value: str, arg_value: str, err_string: str, is_compliant: bool)#

Check if the author and maintainer names and emails are the same.

Parameters:
project_value: str

The author or maintainer’s name or email retrieved from the pyproject.toml file.

arg_value: str

The author or maintainer’s name or email retrieved from the argument passed into the hook.

err_str: str

The message that is printed when an author or maintainer’s name or email is incorrect.

is_compliant: bool

True if the repository is compliant. False if the repository is not compliant.

Returns:
bool

True if the author and maintainer’s name and email are correct. False if the author or maintainer’s name or email is incorrect.

tech_review.check_setup_py(author_maint_name: str, author_maint_email: str, is_compliant: bool) tuple#

Check setup.py file for correct naming convention, version, author, and maintainer.

Parameters:
author_maint_name: str

Project author and maintainer’s name.

author_maint_email: str

Project author and maintainer’s email.

is_compliant: bool

True if the repository is compliant. False if the repository is not compliant.

Returns:
bool

True if the repository is compliant. False if the repository is not compliant.

str

An empty string since the setup.py check is not implemented.

tech_review.download_license_json(url: str, json_file: str) bool#

Download the licenses.json file and restructure it to only include the license ID and name.

Parameters:
url: str

The URL to the licenses.json file that is downloaded.

json_file: str

The path of the json_file to be written to and updated.

Returns:
bool

True if the license file was downloaded and updated. False if there was an issue downloading the license file.

tech_review.restructure_json(file: str)#

Remove extra information from licenses.json file.

Parameters:
file: str

The path of the json_file to be updated.

tech_review.check_file_exists(repo_path: str, files: list, project_name: str, start_year: str, is_compliant: bool, license: str, repository_url: str, product: str, config_file: str, doc_repo_name: str) bool#

Check files exist. If they do not exist, create them using jinja templates.

Parameters:
repo_path: str

Path of the repository being checked.

files: list

List of files to check if they exist and their content.

project_name: str

The name of the project.

start_year: str

The start year of the repository.

is_compliant: bool

True if the repository is compliant. False if the repository is not compliant.

license: str

The license the repository uses.

repository_url: str

The URL of the repository.

product: str

The Ansys product the repository is based on.

config_file: str

If the project’s config file is “setuptools” or “pyproject”.

doc_repo_name: str

The name of the repository to use in documentation.

Returns:
bool

True if the files exist and content was correct. False if a file was created and/or its content was incorrect.

tech_review.generate_file_from_jinja(file: str, project_name: str, year_str: str, repo_url: str, product: str, config_file: str, doc_repo_name: str) str#

Generate file using jinja templates.

Parameters:
file: str

The file that the template is being created for.

project_name: str

The name of the project.

year_str: str

The start year of the repository.

repo_url: str

The URL of the repository.

product: str

The Ansys product the repository is based on.

config_file: str

If the project’s config file is “setuptools” or “pyproject”.

doc_repo_name: str

The name of the repository to use in documentation.

Returns:
str

Content of the template that was generated.

tech_review.write_content(message: str, file_path: str, file_content: str)#

Write generated content from jinja template to a file.

Parameters:
message: str

The message that details which file is being created.

file_path: str

The path of the file to write the content to.

file_content: str

The file content that was generated from the jinja templates.

tech_review.check_file_content(file: str, generated_content: str, is_compliant: bool, license: str) bool#

Check the file content of the LICENSE and CONTRIBUTORS.md files.

Parameters:
file: str

The file that the template is being created for.

generated_content: str

Content of the template that was generated.

is_compliant: bool

True if the repository is compliant. False if the repository is not compliant.

license: str

The license the repository uses.

Returns:
bool

True if LICENSE and CONTRIBUTORS.md files had the correct content. False if LICENSE and CONTRIBUTORS.md files had the incorrect content.

tech_review.main()#

Check files for technical review.

tech_review.HOOK_PATH#

Location of the pre-commit hook on your system.

tech_review.LICENSES_JSON#

JSON file containing licenses information.

tech_review.DEFAULT_AUTHOR_MAINT_NAME = 'ANSYS, Inc.'#

Default name of project authors and maintainers.

tech_review.DEFAULT_AUTHOR_MAINT_EMAIL = 'pyansys.core@ansys.com'#

Default email of project authors and maintainers.

tech_review.DEFAULT_START_YEAR#

Default start year of the repository.

tech_review.DEFAULT_LICENSE = 'MIT'#

Default license of the repository

tech_review.JSON_URL = 'https://raw.githubusercontent.com/spdx/license-list-data/main/json/licenses.json'#

URL to retrieve list of license IDs and names.