Anybadge

1.16.0 · active · verified Sat Apr 11

Anybadge is a Python library and command-line tool designed for simple and flexible generation of SVG badges for your projects. It allows users to define custom labels, values, and configurable thresholds to color badges dynamically. The library is actively maintained, with its current version being 1.16.0, and receives regular updates.

Warnings

Install

Imports

Quickstart

This example demonstrates how to create a PyLint score badge using thresholds to determine its color and then save it as an SVG file. Values can be integers, floats, or strings, and custom colors (hex codes or named colors) are supported.

import anybadge

# Define thresholds for coloring the badge based on value
# <2=red, <4=orange, <6=yellow, <10=green
thresholds = {2: 'red', 4: 'orange', 6: 'yellow', 10: 'green'}

# Create a badge instance
badge = anybadge.Badge(
    label='pylint',
    value=2.22,
    thresholds=thresholds
)

# Write the badge to an SVG file
badge.write_badge('pylint.svg')

print('pylint.svg generated.')

view raw JSON →