Modules Documentation

CLI

Main Package File, parses CLI arguments and calls functions

badges_gitlab.cli.main() None

Main Function for calling arg parser and executing functions

badges_gitlab.cli.parse_args(args)

Create arguments and parse them returning already parsed arguments

Badges API

This VI uses the Gitlab API Functions to create json files for badges

badges_gitlab.badges_api.create_api_badges(directory_path: Any, private_token: str) None

Authenticates to API and call the json creation functions

badges_gitlab.badges_api.general_data(project_ref: Any, directory_path: Any) None

Retrieves General Data

badges_gitlab.badges_api.issues(project_ref: Any, directory_path: Any) None

Retrieves issues count data

badges_gitlab.badges_api.releases_commits(project_ref: Any, directory_path: Any) None

Retrieves Releases, Tags and Commits related data

badges_gitlab.badges_api.validate_path(directory_path: Any) None

Validates destination path, if not found, creates it

Badges JSON

This modules has functions to manipulate and generate standardized json files

badges_gitlab.badges_json.json_badge(directory_path, filename: str, json_string: dict) None

Write to JSON file to disk to the specified directory

badges_gitlab.badges_json.print_json(label: str, message: str, color: str) dict

Returns a JSON (Dict) in the format used by shields.io to create badges

badges_gitlab.badges_json.validate_json_path(directory_path: Any) None

Validate Path

Badges Static

This module handles generation of static badges read from pyproject.toml or from command line parameters

badges_gitlab.badges_static.convert_list_json_badge(badges_list: list) list

Converts the list of badges list to json format to be printed in the json file

badges_gitlab.badges_static.download_badges(directory: str, badges_urls: list)

Get the badges from websites and save it locally. Now this was written specifically for shields.io but it must be studied to use other websites.

badges_gitlab.badges_static.extract_svg_title(xml_svg) str

Get the raw SVG (XML), convert to dict and retrieve the title

badges_gitlab.badges_static.print_static_badges(directory: str, badges_list: list)

Call functions to perform actions in order to write a file with json badge information

badges_gitlab.badges_static.to_snake_case(value) str

Convert the label from a badge to snake case

Badges SVG

Creates standardized badges files using anybadge package

badges_gitlab.badges_svg.print_badges(directory_path: Any) None

Iterates within the directory finding json files and then use anybadge pkg to generate them

badges_gitlab.badges_svg.replace_space(string: str) str

Replaces any spaces to make it easier to use later as url in badges linking

badges_gitlab.badges_svg.validate_json_path(directory_path: Any) bool

Validates path to check if there is any json files there or the if the directory is valid

Badges Test

Generate Tests Badges related by parsing JUnit XML files

badges_gitlab.badges_test.create_badges_test(json_directory, file_path: str) str

This function parses a JUnit XML file to extract general information about the unit tests.

badges_gitlab.badges_test.create_test_json_badges(json_directory, test_results: list) str

This function returns parses a list with the test summary to json format. The list order must be: total tests, total failures, total errors, total_skipped, total_time

badges_gitlab.badges_test.tests_statistics(stats_tests_dict: dict, testsuite) dict
This function returns the Test Statistics Dictionary with added

values from the testsuite.

Args:

stats_tests_dict (dict): dictionary with listed tests testsuite ([junitparser.junitparser.TestSuite]): a testsuite xml node needed for filling the stats tests dicitionary

Returns:

dict: returns the stats_tests_dict with the new values.

Read pyproject.toml

Read pyproject.toml and import the parameters to be used in the function

badges_gitlab.read_pyproject.load_pyproject(file_path: str) dict

Load the tool.badges_gitlab section from the toml file. Most of the cases it is pyproject.toml because it is hardcoded into main function

badges_gitlab.read_pyproject.pyproject_config(file_path: str) dict

Check if the file exists then return the dictionary if it exists with the configuration for the badges_gitlab tool

badges_gitlab.read_pyproject.pyproject_exists(file_path: str) bool

Verify if the file exists, used internally.