chromatictools.badges module¶
Generate badge URLs from reports
Example:
python -m coverage run --source <module> -m unittest
python -m coverage json
python -m chromatictools.badges coverage
- class chromatictools.badges.CoverageBadge(filename: str, label: str = 'coverage', hue_gamma: float = 6, **kwargs)¶
Bases:
chromatictools.badges.HuePercentBadgeCoverage badge utility class
- Parameters
filename (str) – Coverage report JSON file
label (str) – Badge label. Default is
"coverage"hue_gamma (float) – Gamma exponent for hue scale correction. Default is
6kwargs – Keyword arguments for
HuePercentBadge
- property percent: Union[str, float]¶
Coverage percentage if found in file, else
"N/A"
- property report: dict¶
Coverage report dictionary
- class chromatictools.badges.HuePercentBadge(filename: str, label: str, hue_0: float = 0, hue_100: float = 130, hue_gamma: float = 1, saturation: float = 1, value: float = 0.85, fmt: str = 'https://img.shields.io/badge/{label}-{message}-{color}')¶
Bases:
objectBadge URL generator class based on mapping percentage to hue
- Parameters
filename (str) – File to read for informtion
label (str) – Badge label
hue_0 (float) – Hue at 0 percent. Default is 0 (red)
hue_100 (float) – Hue at 100 percent. Default is 130 (green)
hue_gamma (float) – Gamma exponent for hue scale correction
saturation (float) – Color saturation
value (float) – Color value
fmt (str) – URL format string with placeholders for
label,messageandcolor
- property color: str¶
Hexadecimal color string for the badge
- property hue: float¶
Color hue for the badge
- property message: str¶
Badge message
- property percent: Union[str, float]¶
Percentage score
- property url: str¶
Badge URL string
- class chromatictools.badges.PylintBadge(filename: str, label: str = 'pylint', **kwargs)¶
Bases:
chromatictools.badges.HuePercentBadgePylint badge utility class
- Parameters
filename (str) – Text file output of pylint
label (str) – Badge label. Default is
"pylint"kwargs – Keyword arguments for
HuePercentBadge
- property message: str¶
Badge Message
- property percent: Union[str, float]¶
Pylint rating (out of 100) if found in file, else
"N/A"
- property report: str¶
Pylint report text file
- chromatictools.badges.main(*argv)¶
CLI launcher function
- Parameters
argv – Command-line arguments
- Returns
Exit code
- Return type
int