# anybadge
Python project for generating badges for your projects
[![pypi package](https://badge.fury.io/py/anybadge.svg)](https://pypi.org/project/anybadge)
[![build status](https://api.travis-ci.com/jongracecox/anybadge.svg?branch=master)](https://app.travis-ci.com/github/jongracecox/anybadge)
[![downloads](https://img.shields.io/pypi/dm/anybadge.svg)](https://pypistats.org/packages/anybadge)
[![GitHub last commit](https://img.shields.io/github/last-commit/jongracecox/anybadge.svg)](https://github.com/jongracecox/anybadge/commits/master)
[![GitHub](https://img.shields.io/github/license/jongracecox/anybadge.svg)](https://github.com/jongracecox/anybadge/blob/master/LICENSE)
[![GitHub stars](https://img.shields.io/github/stars/jongracecox/anybadge.svg?style=social)](https://github.com/jongracecox/anybadge/stargazers)
[![Snyk health](https://snyk.io/advisor/python/anybadge/badge.svg)](https://snyk.io/advisor/python/anybadge)
[![buymeacoffee](https://camo.githubusercontent.com/c3f856bacd5b09669157ed4774f80fb9d8622dd45ce8fdf2990d3552db99bd27/68747470733a2f2f7777772e6275796d6561636f666665652e636f6d2f6173736574732f696d672f637573746f6d5f696d616765732f6f72616e67655f696d672e706e67)](https://www.buymeacoffee.com/jongracecox)
Supports: Python 3.4-3.9 (2.7 support has been dropped)
## Overview
`anybadge` can be used to add badge generation to your Python projects,
and also provides a command line interface.
This utility can be used to generate .svg badge images, using configurable
thresholds for coloring the badges based on the badge value. Many badge
generation tools just provide the ability to specify the color of badge.
`anybadge` allows you to specify the label, badge value, and color, but
it also allows you to specify a set of thresholds that can be used to
select a color based on the badge value.
`anybadge` may be useful for companies developing internally, or any time
making calls to external badge services is not possible, or undesirable.
In this situation using `anybadge` will be easier than running your own
internal badge service.
The package can be imported into your python code, or run direct from the
command line.
## Demo
You can find a [repl.it demo here](https://repl.it/@JonGrace_Cox/anybadge-demo).
This will allow you to see what the package can do and play with it to test outputs.
## Basic usage
### Command line
As an example, if you want to produce a pylint badge, you may run `anybadge`
from the command line like this:
```bash
anybadge -l pylint -v 2.22 -f pylint.svg 2=red 4=orange 8=yellow 10=green
```
This would result in a badge like this:
![pylint](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/pylint.svg)
In this example the label is set to "pylint", the value "2.22", and an
output file called "pylint.svg". The thresholds are provided in pairs
of `<value>=color` Values can be integer or floats for ranges, and
string values are also supported.
### Python
Here is the same example implemented in Python code:
```python
import anybadge
# Define thresholds: <2=red, <4=orange <8=yellow <10=green
thresholds = {2: 'red',
4: 'orange',
6: 'yellow',
10: 'green'}
badge = anybadge.Badge('pylint', 2.22, thresholds=thresholds)
badge.write_badge('pylint.svg')
```
## Installation
`anybadge` is available in PyPi at https://pypi.python.org/pypi/anybadge
You can install the latest release of `anybadge` using `pip`:
```bash
pip install anybadge
```
This will install the Python package, and also make `anybadge` available
as a command line utility.
## Getting help
To get help from the command line utility, just run:
```bash
anybadge --help
```
## Command line usage
### Output
Running the utility with the `--file` option will result in the .svg image being
written to file. Without the `--file` option the `.svg` file content will be
written to stdout, so can be redirected to a file.
### Thresholds
Some thresholds have been built in to save time. To use these thresholds you
can simply specify the template name instead of threshold value/color pairs.
```bash
anybadge --value=<VALUE> --file=<FILE> <TEMPLATE-NAME>
```
For example:
```bash
anybadge --value=2.22 --file=pylint.svg pylint
```
### Colors
Anybadge comes with some pre-defined colors, which can be referred to by name. It also
supports the use of custom colors by using the hex representation of the color. Both color
types can be used in the `default_color`, `text_color` and `thresholds` attributes. Color names are
taken from the [Mozilla color keywords list](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/color_keywords).
Here is a Python example showing use of a named color and a custom color.
```python
import anybadge
badge = anybadge.Badge(label='custom color', value='teal', default_color='teal', num_padding_chars=1)
badge = anybadge.Badge(label='custom color', value='teal', default_color='#008080', num_padding_chars=1)
```
Available named colors are:
| Color Name | Hex | Example |
| ------------- | ------- | ------- |
| aliceblue | #F0F8FF | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_aliceblue.svg) |
| antiquewhite | #FAEBD7 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_antiquewhite.svg) |
| aqua | #00FFFF | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_aqua.svg) |
| aquamarine | #7FFFD4 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_aquamarine.svg) |
| azure | #F0FFFF | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_azure.svg) |
| beige | #F5F5DC | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_beige.svg) |
| bisque | #FFE4C4 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_bisque.svg) |
| black | #000000 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_black.svg) |
| blanchedalmond | #FFEBCD | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_blanchedalmond.svg)|
| blue | #0000FF | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_blue.svg) |
| blueviolet | #8A2BE2 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_blueviolet.svg) |
| bright_red | #FF0000 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_bright_red.svg) |
| bright_yellow | #FFFF00 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_bright_yellow.svg)|
| brown | #A52A2A | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_brown.svg) |
| burlywood | #DEB887 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_burlywood.svg) |
| cadetblue | #5F9EA0 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_cadetblue.svg) |
| chartreuse | #7FFF00 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_chartreuse.svg) |
| chocolate | #D2691E | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_chocolate.svg) |
| coral | #FF7F50 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_coral.svg) |
| cornflowerblue | #6495ED | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_cornflowerblue.svg)|
| cornsilk | #FFF8DC | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_cornsilk.svg) |
| crimson | #DC143C | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_crimson.svg) |
| darkblue | #00008B | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_darkblue.svg) |
| darkcyan | #008B8B | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_darkcyan.svg) |
| darkgoldenrod | #B8860B | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_darkgoldenrod.svg)|
| darkgray | #A9A9A9 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_darkgray.svg) |
| darkgreen | #006400 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_darkgreen.svg) |
| darkkhaki | #BDB76B | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_darkkhaki.svg) |
| darkmagenta | #8B008B | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_darkmagenta.svg) |
| darkolivegreen | #556B2F | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_darkolivegreen.svg)|
| darkorange | #FF8C00 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_darkorange.svg) |
| darkorchid | #9932CC | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_darkorchid.svg) |
| darkred | #8B0000 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_darkred.svg) |
| darksalmon | #E9967A | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_darksalmon.svg) |
| darkseagreen | #8FBC8F | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_darkseagreen.svg) |
| darkslateblue | #483D8B | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_darkslateblue.svg)|
| darkslategray | #2F4F4F | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_darkslategray.svg)|
| darkturquoise | #00CED1 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_darkturquoise.svg)|
| darkviolet | #9400D3 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_darkviolet.svg) |
| deeppink | #FF1493 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_deeppink.svg) |
| deepskyblue | #00BFFF | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_deepskyblue.svg) |
| dimgray | #696969 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_dimgray.svg) |
| dodgerblue | #1E90FF | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_dodgerblue.svg) |
| firebrick | #B22222 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_firebrick.svg) |
| floralwhite | #FFFAF0 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_floralwhite.svg) |
| forestgreen | #228B22 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_forestgreen.svg) |
| fuchsia | #FF00FF | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_fuchsia.svg) |
| gainsboro | #DCDCDC | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_gainsboro.svg) |
| ghostwhite | #F8F8FF | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_ghostwhite.svg) |
| gold | #FFD700 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_gold.svg) |
| goldenrod | #DAA520 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_goldenrod.svg) |
| gray | #808080 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_gray.svg) |
| green | #4C1 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_green.svg) |
| greenyellow | #ADFF2F | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_greenyellow.svg) |
| green_2 | #008000 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_green_2.svg) |
| honeydew | #F0FFF0 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_honeydew.svg) |
| hotpink | #FF69B4 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_hotpink.svg) |
| indianred | #CD5C5C | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_indianred.svg) |
| indigo | #4B0082 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_indigo.svg) |
| ivory | #FFFFF0 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_ivory.svg) |
| khaki | #F0E68C | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_khaki.svg) |
| lavender | #E6E6FA | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_lavender.svg) |
| lavenderblush | #FFF0F5 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_lavenderblush.svg)|
| lawngreen | #7CFC00 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_lawngreen.svg) |
| lemonchiffon | #FFFACD | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_lemonchiffon.svg) |
| lightblue | #ADD8E6 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_lightblue.svg) |
| lightcoral | #F08080 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_lightcoral.svg) |
| lightcyan | #E0FFFF | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_lightcyan.svg) |
| lightgoldenrodyellow | #FAFAD2 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_lightgoldenrodyellow.svg)|
| lightgray | #D3D3D3 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_lightgray.svg) |
| lightgreen | #90EE90 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_lightgreen.svg) |
| lightpink | #FFB6C1 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_lightpink.svg) |
| lightsalmon | #FFA07A | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_lightsalmon.svg) |
| lightseagreen | #20B2AA | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_lightseagreen.svg)|
| lightskyblue | #87CEFA | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_lightskyblue.svg) |
| lightslategray | #778899 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_lightslategray.svg)|
| lightsteelblue | #B0C4DE | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_lightsteelblue.svg)|
| lightyellow | #FFFFE0 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_lightyellow.svg) |
| light_grey | #9F9F9F | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_light_grey.svg) |
| lime | #00FF00 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_lime.svg) |
| limegreen | #32CD32 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_limegreen.svg) |
| linen | #FAF0E6 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_linen.svg) |
| maroon | #800000 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_maroon.svg) |
| mediumaquamarine | #66CDAA | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_mediumaquamarine.svg)|
| mediumblue | #0000CD | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_mediumblue.svg) |
| mediumorchid | #BA55D3 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_mediumorchid.svg) |
| mediumpurple | #9370DB | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_mediumpurple.svg) |
| mediumseagreen | #3CB371 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_mediumseagreen.svg)|
| mediumslateblue | #7B68EE | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_mediumslateblue.svg)|
| mediumspringgreen | #00FA9A | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_mediumspringgreen.svg)|
| mediumturquoise | #48D1CC | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_mediumturquoise.svg)|
| mediumvioletred | #C71585 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_mediumvioletred.svg)|
| midnightblue | #191970 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_midnightblue.svg) |
| mintcream | #F5FFFA | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_mintcream.svg) |
| mistyrose | #FFE4E1 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_mistyrose.svg) |
| moccasin | #FFE4B5 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_moccasin.svg) |
| navajowhite | #FFDEAD | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_navajowhite.svg) |
| navy | #000080 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_navy.svg) |
| oldlace | #FDF5E6 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_oldlace.svg) |
| olive | #808000 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_olive.svg) |
| olivedrab | #6B8E23 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_olivedrab.svg) |
| orange | #FE7D37 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_orange.svg) |
| orangered | #FF4500 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_orangered.svg) |
| orange_2 | #FFA500 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_orange_2.svg) |
| orchid | #DA70D6 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_orchid.svg) |
| palegoldenrod | #EEE8AA | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_palegoldenrod.svg)|
| palegreen | #98FB98 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_palegreen.svg) |
| paleturquoise | #AFEEEE | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_paleturquoise.svg)|
| palevioletred | #DB7093 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_palevioletred.svg)|
| papayawhip | #FFEFD5 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_papayawhip.svg) |
| peachpuff | #FFDAB9 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_peachpuff.svg) |
| peru | #CD853F | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_peru.svg) |
| pink | #FFC0CB | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_pink.svg) |
| plum | #DDA0DD | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_plum.svg) |
| powderblue | #B0E0E6 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_powderblue.svg) |
| purple | #800080 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_purple.svg) |
| rebeccapurple | #663399 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_rebeccapurple.svg)|
| red | #E05D44 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_red.svg) |
| rosybrown | #BC8F8F | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_rosybrown.svg) |
| royalblue | #4169E1 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_royalblue.svg) |
| saddlebrown | #8B4513 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_saddlebrown.svg) |
| salmon | #FA8072 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_salmon.svg) |
| sandybrown | #F4A460 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_sandybrown.svg) |
| seagreen | #2E8B57 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_seagreen.svg) |
| seashell | #FFF5EE | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_seashell.svg) |
| sienna | #A0522D | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_sienna.svg) |
| silver | #C0C0C0 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_silver.svg) |
| skyblue | #87CEEB | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_skyblue.svg) |
| slateblue | #6A5ACD | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_slateblue.svg) |
| slategray | #708090 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_slategray.svg) |
| snow | #FFFAFA | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_snow.svg) |
| springgreen | #00FF7F | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_springgreen.svg) |
| steelblue | #4682B4 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_steelblue.svg) |
| tan | #D2B48C | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_tan.svg) |
| teal | #008080 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_teal.svg) |
| thistle | #D8BFD8 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_thistle.svg) |
| tomato | #FF6347 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_tomato.svg) |
| turquoise | #40E0D0 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_turquoise.svg) |
| violet | #EE82EE | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_violet.svg) |
| wheat | #F5DEB3 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_wheat.svg) |
| white | #FFFFFF | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_white.svg) |
| whitesmoke | #F5F5F5 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_whitesmoke.svg) |
| yellow | #DFB317 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_yellow.svg) |
| yellowgreen | #9ACD32 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_yellowgreen.svg) |
| yellow_green | #A4A61D | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_yellow_green.svg) |
### Emojis
It is possible to use emoji characters in badge labels and values. Here are some examples:
![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/pipeline_frown.svg)
![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/pipeline_smile.svg)
![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/documentation_link.svg)
![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/pypi_link.svg)
These files were created by using the **actual** emoji character in the label/value text. For example:
```python
badge = anybadge.Badge(label="Pipeline status", value="😄")
```
There are some caveats worth mentioning:
- The "look" of the emoji is determined by the client (Emoji characters are placed as-is into the SVG file, and are
rendered client-side)
- Rendering may fail in some viewers and developer IDEs (for example, PyCharm does not render emojis in the svg viewer)
- Emojis can have different widths, so the layout may be affected. You can use `num_label_padding_chars` and
`num_value_padding_chars` to fix (see below)
Here are some examples to show how to use padding to fix layout:
| Badge | Code |
| ----- |----------------------------------------------------------------------|
| ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/pipeline_smile.svg) | `anybadge.Badge("Pipeline status", "😄")` |
| ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/pipeline_smile_padding.svg) | `anybadge.Badge("Pipeline status", "😄", num_value_padding_chars=1)` |
### Semantic version support
Anybadge supports semantic versions for value and threshold keys. This supports color-coded
badges based on version numbering. Here are some examples:
```python
badge = Badge(
label='Version',
value='3.0.0',
thresholds={'3.0.0': 'red', '3.2.0': 'orange', '999.0.0': 'green'},
semver=True
)
```
In the above example the thresholds equate to the following:
* If value is < 3.0.0 then badge will be red.
* If value is < 3.2.0 then badge will be orange.
* If value is < 999.0.0 then badge will be green.
Each threshold entry is used to define the upper bounds of the threshold. If you don't know the
upper bound for your version number threshold you will need to provide an extreme upper bound -
in this example it is `999.0.0`.
### Examples
#### Pylint using template
```bash
anybadge --value=2.22 --file=pylint.svg pylint
```
![pylint](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/pylint.svg)
#### Pylint using arguments
```bash
anybadge -l pylint -v 2.22 -f pylint.svg 2=red 4=orange 8=yellow 10=green
```
![pylint](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/pylint.svg)
#### Coverage using template
```bash
anybadge --value=65 --file=coverage.svg coverage
```
![coverage](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/coverage.svg)
#### Pipeline, using labeled colors
```bash
anybadge --label=pipeline --value=passing --file=pipeline.svg passing=green failing=red
```
![pipeline](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/pipeline.svg)
#### Badge with fixed color
```bash
anybadge --label=awesomeness --value="110%" --file=awesomeness.svg --color='#97CA00'
```
![awesomeness](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/awesomeness.svg)
#### GitLab Scoped style badge
```bash
anybadge --style=gitlab-scoped --label=Project --value=Archimedes --file=gitlab_scoped.svg --color='#c1115d'
```
![gitlab_scoped](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/gitlab_scoped.svg)
#### Thresholds based on semantic versions
```bash
anybadge --label=Version --value=2.4.5 --file=version.svg 1.0.0=red 2.4.6=orange 2.9.1=yellow 999.0.0=green
```
#### Importing in your own app
```python
from anybadge import Badge
test1 = Badge(
label,
value,
font_name='DejaVu Sans,Verdana,Geneva,sans-serif',
font_size=11,
num_padding_chars=0.5,
template='<?xml version="1.0" encoding="UTF-8"?>\n<svg xmlns="http://www.w3.org/2000/svg" width="{{ badge width }}" height="20">\n <linearGradient id="b" x2="0" y2="100%">\n <stop offset="0" stop-color="#bbb" stop-opacity=".1"/>\n <stop offset="1" stop-opacity=".1"/>\n </linearGradient>\n <mask id="a">\n <rect width="{{ badge width }}" height="20" rx="3" fill="#fff"/>\n </mask>\n <g mask="url(#a)">\n <path fill="#555" d="M0 0h{{ color split x }}v20H0z"/>\n <path fill="{{ color }}" d="M{{ color split x }} 0h{{ value width }}v20H{{ color split x }}z"/>\n <path fill="url(#b)" d="M0 0h{{ badge width }}v20H0z"/>\n </g>\n <g fill="{{ label text color }}" text-anchor="middle" font-family="{{ font name }}" font-size="{{ font size }}">\n <text x="{{ label anchor shadow }}" y="15" fill="#010101" fill-opacity=".3">{{ label }}</text>\n <text x="{{ label anchor }}" y="14">{{ label }}</text>\n </g>\n <g fill="{{ value text color }}" text-anchor="middle" font-family="{{ font name }}" font-size="{{ font size }}">\n <text x="{{ value anchor shadow }}" y="15" fill="#010101" fill-opacity=".3">{{ value }}</text>\n <text x="{{ value anchor }}" y="14">{{ value }}</text>\n </g>\n</svg>',
value_prefix='',
value_suffix='',
thresholds=None,
default_color='#4c1',
use_max_when_value_exceeds=True,
value_format=None,
text_color='#fff'
)
test1.write_badge('test1.svg')
```
### Command-line options
The command line options can be viewed using `anybadge --help`.
Examples
--------
Here are some usage specific command line examples that may save time on defining
thresholds.
Pylint::
```
anybadge.py --value=2.22 --file=pylint.svg pylint
anybadge.py --label=pylint --value=2.22 --file=pylint.svg 2=red 4=orange 8=yellow 10=green
```
Coverage::
```
anybadge.py --value=65 --file=coverage.svg coverage
anybadge.py --label=coverage --value=65 --suffix='%%' --file=coverage.svg 50=red 60=orange 80=yellow 100=green
```
CI Pipeline::
```
anybadge.py --label=pipeline --value=passing --file=pipeline.svg passing=green failing=red
```
Python usage
============
For Python API details you can use the inbuilt documentation:
```python
from anybadge import badge
help(badge)
```
Raw data
{
"_id": null,
"home_page": "https://github.com/jongracecox/anybadge",
"name": "anybadge",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": "",
"keywords": "",
"author": "Jon Grace-Cox",
"author_email": "jongracecox@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/a3/f2/9f55245d6f456b661b38650767410f3b51d66a8530f0e0a43909bd475165/anybadge-1.14.0.tar.gz",
"platform": null,
"description": "# anybadge\n\nPython project for generating badges for your projects\n\n[![pypi package](https://badge.fury.io/py/anybadge.svg)](https://pypi.org/project/anybadge)\n[![build status](https://api.travis-ci.com/jongracecox/anybadge.svg?branch=master)](https://app.travis-ci.com/github/jongracecox/anybadge)\n[![downloads](https://img.shields.io/pypi/dm/anybadge.svg)](https://pypistats.org/packages/anybadge)\n[![GitHub last commit](https://img.shields.io/github/last-commit/jongracecox/anybadge.svg)](https://github.com/jongracecox/anybadge/commits/master)\n[![GitHub](https://img.shields.io/github/license/jongracecox/anybadge.svg)](https://github.com/jongracecox/anybadge/blob/master/LICENSE)\n[![GitHub stars](https://img.shields.io/github/stars/jongracecox/anybadge.svg?style=social)](https://github.com/jongracecox/anybadge/stargazers)\n[![Snyk health](https://snyk.io/advisor/python/anybadge/badge.svg)](https://snyk.io/advisor/python/anybadge)\n\n[![buymeacoffee](https://camo.githubusercontent.com/c3f856bacd5b09669157ed4774f80fb9d8622dd45ce8fdf2990d3552db99bd27/68747470733a2f2f7777772e6275796d6561636f666665652e636f6d2f6173736574732f696d672f637573746f6d5f696d616765732f6f72616e67655f696d672e706e67)](https://www.buymeacoffee.com/jongracecox)\n\nSupports: Python 3.4-3.9 (2.7 support has been dropped)\n\n## Overview\n\n`anybadge` can be used to add badge generation to your Python projects,\nand also provides a command line interface.\n\nThis utility can be used to generate .svg badge images, using configurable\nthresholds for coloring the badges based on the badge value. Many badge\ngeneration tools just provide the ability to specify the color of badge.\n`anybadge` allows you to specify the label, badge value, and color, but\nit also allows you to specify a set of thresholds that can be used to\nselect a color based on the badge value.\n\n`anybadge` may be useful for companies developing internally, or any time\nmaking calls to external badge services is not possible, or undesirable.\nIn this situation using `anybadge` will be easier than running your own\ninternal badge service.\n\nThe package can be imported into your python code, or run direct from the\ncommand line.\n\n## Demo\n\nYou can find a [repl.it demo here](https://repl.it/@JonGrace_Cox/anybadge-demo).\nThis will allow you to see what the package can do and play with it to test outputs.\n\n## Basic usage\n\n### Command line\n\nAs an example, if you want to produce a pylint badge, you may run `anybadge`\nfrom the command line like this:\n\n```bash\nanybadge -l pylint -v 2.22 -f pylint.svg 2=red 4=orange 8=yellow 10=green\n```\n\nThis would result in a badge like this:\n\n![pylint](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/pylint.svg)\n\nIn this example the label is set to \"pylint\", the value \"2.22\", and an\noutput file called \"pylint.svg\". The thresholds are provided in pairs\nof `<value>=color` Values can be integer or floats for ranges, and\nstring values are also supported.\n\n### Python\n\nHere is the same example implemented in Python code:\n\n```python\nimport anybadge\n\n# Define thresholds: <2=red, <4=orange <8=yellow <10=green\nthresholds = {2: 'red',\n 4: 'orange',\n 6: 'yellow',\n 10: 'green'}\n\nbadge = anybadge.Badge('pylint', 2.22, thresholds=thresholds)\n\nbadge.write_badge('pylint.svg')\n```\n\n## Installation\n\n`anybadge` is available in PyPi at https://pypi.python.org/pypi/anybadge\n\nYou can install the latest release of `anybadge` using `pip`:\n\n```bash\npip install anybadge\n```\n\nThis will install the Python package, and also make `anybadge` available\nas a command line utility.\n\n## Getting help\n\nTo get help from the command line utility, just run:\n\n```bash\nanybadge --help\n```\n\n## Command line usage\n\n### Output\n\nRunning the utility with the `--file` option will result in the .svg image being\nwritten to file. Without the `--file` option the `.svg` file content will be\nwritten to stdout, so can be redirected to a file.\n\n### Thresholds\n\nSome thresholds have been built in to save time. To use these thresholds you\ncan simply specify the template name instead of threshold value/color pairs.\n\n```bash\nanybadge --value=<VALUE> --file=<FILE> <TEMPLATE-NAME>\n```\n\nFor example:\n\n```bash\nanybadge --value=2.22 --file=pylint.svg pylint\n```\n\n### Colors\n\nAnybadge comes with some pre-defined colors, which can be referred to by name. It also\nsupports the use of custom colors by using the hex representation of the color. Both color\ntypes can be used in the `default_color`, `text_color` and `thresholds` attributes. Color names are\ntaken from the [Mozilla color keywords list](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/color_keywords).\n\nHere is a Python example showing use of a named color and a custom color.\n\n```python\nimport anybadge\n\nbadge = anybadge.Badge(label='custom color', value='teal', default_color='teal', num_padding_chars=1)\nbadge = anybadge.Badge(label='custom color', value='teal', default_color='#008080', num_padding_chars=1)\n```\n\nAvailable named colors are:\n\n| Color Name | Hex | Example |\n| ------------- | ------- | ------- |\n| aliceblue | #F0F8FF | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_aliceblue.svg) |\n| antiquewhite | #FAEBD7 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_antiquewhite.svg) |\n| aqua | #00FFFF | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_aqua.svg) |\n| aquamarine | #7FFFD4 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_aquamarine.svg) |\n| azure | #F0FFFF | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_azure.svg) |\n| beige | #F5F5DC | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_beige.svg) |\n| bisque | #FFE4C4 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_bisque.svg) |\n| black | #000000 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_black.svg) |\n| blanchedalmond | #FFEBCD | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_blanchedalmond.svg)|\n| blue | #0000FF | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_blue.svg) |\n| blueviolet | #8A2BE2 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_blueviolet.svg) |\n| bright_red | #FF0000 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_bright_red.svg) |\n| bright_yellow | #FFFF00 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_bright_yellow.svg)|\n| brown | #A52A2A | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_brown.svg) |\n| burlywood | #DEB887 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_burlywood.svg) |\n| cadetblue | #5F9EA0 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_cadetblue.svg) |\n| chartreuse | #7FFF00 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_chartreuse.svg) |\n| chocolate | #D2691E | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_chocolate.svg) |\n| coral | #FF7F50 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_coral.svg) |\n| cornflowerblue | #6495ED | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_cornflowerblue.svg)|\n| cornsilk | #FFF8DC | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_cornsilk.svg) |\n| crimson | #DC143C | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_crimson.svg) |\n| darkblue | #00008B | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_darkblue.svg) |\n| darkcyan | #008B8B | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_darkcyan.svg) |\n| darkgoldenrod | #B8860B | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_darkgoldenrod.svg)|\n| darkgray | #A9A9A9 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_darkgray.svg) |\n| darkgreen | #006400 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_darkgreen.svg) |\n| darkkhaki | #BDB76B | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_darkkhaki.svg) |\n| darkmagenta | #8B008B | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_darkmagenta.svg) |\n| darkolivegreen | #556B2F | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_darkolivegreen.svg)|\n| darkorange | #FF8C00 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_darkorange.svg) |\n| darkorchid | #9932CC | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_darkorchid.svg) |\n| darkred | #8B0000 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_darkred.svg) |\n| darksalmon | #E9967A | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_darksalmon.svg) |\n| darkseagreen | #8FBC8F | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_darkseagreen.svg) |\n| darkslateblue | #483D8B | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_darkslateblue.svg)|\n| darkslategray | #2F4F4F | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_darkslategray.svg)|\n| darkturquoise | #00CED1 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_darkturquoise.svg)|\n| darkviolet | #9400D3 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_darkviolet.svg) |\n| deeppink | #FF1493 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_deeppink.svg) |\n| deepskyblue | #00BFFF | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_deepskyblue.svg) |\n| dimgray | #696969 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_dimgray.svg) |\n| dodgerblue | #1E90FF | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_dodgerblue.svg) |\n| firebrick | #B22222 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_firebrick.svg) |\n| floralwhite | #FFFAF0 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_floralwhite.svg) |\n| forestgreen | #228B22 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_forestgreen.svg) |\n| fuchsia | #FF00FF | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_fuchsia.svg) |\n| gainsboro | #DCDCDC | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_gainsboro.svg) |\n| ghostwhite | #F8F8FF | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_ghostwhite.svg) |\n| gold | #FFD700 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_gold.svg) |\n| goldenrod | #DAA520 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_goldenrod.svg) |\n| gray | #808080 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_gray.svg) |\n| green | #4C1 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_green.svg) |\n| greenyellow | #ADFF2F | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_greenyellow.svg) |\n| green_2 | #008000 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_green_2.svg) |\n| honeydew | #F0FFF0 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_honeydew.svg) |\n| hotpink | #FF69B4 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_hotpink.svg) |\n| indianred | #CD5C5C | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_indianred.svg) |\n| indigo | #4B0082 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_indigo.svg) |\n| ivory | #FFFFF0 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_ivory.svg) |\n| khaki | #F0E68C | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_khaki.svg) |\n| lavender | #E6E6FA | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_lavender.svg) |\n| lavenderblush | #FFF0F5 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_lavenderblush.svg)|\n| lawngreen | #7CFC00 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_lawngreen.svg) |\n| lemonchiffon | #FFFACD | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_lemonchiffon.svg) |\n| lightblue | #ADD8E6 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_lightblue.svg) |\n| lightcoral | #F08080 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_lightcoral.svg) |\n| lightcyan | #E0FFFF | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_lightcyan.svg) |\n| lightgoldenrodyellow | #FAFAD2 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_lightgoldenrodyellow.svg)|\n| lightgray | #D3D3D3 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_lightgray.svg) |\n| lightgreen | #90EE90 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_lightgreen.svg) |\n| lightpink | #FFB6C1 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_lightpink.svg) |\n| lightsalmon | #FFA07A | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_lightsalmon.svg) |\n| lightseagreen | #20B2AA | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_lightseagreen.svg)|\n| lightskyblue | #87CEFA | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_lightskyblue.svg) |\n| lightslategray | #778899 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_lightslategray.svg)|\n| lightsteelblue | #B0C4DE | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_lightsteelblue.svg)|\n| lightyellow | #FFFFE0 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_lightyellow.svg) |\n| light_grey | #9F9F9F | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_light_grey.svg) |\n| lime | #00FF00 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_lime.svg) |\n| limegreen | #32CD32 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_limegreen.svg) |\n| linen | #FAF0E6 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_linen.svg) |\n| maroon | #800000 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_maroon.svg) |\n| mediumaquamarine | #66CDAA | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_mediumaquamarine.svg)|\n| mediumblue | #0000CD | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_mediumblue.svg) |\n| mediumorchid | #BA55D3 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_mediumorchid.svg) |\n| mediumpurple | #9370DB | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_mediumpurple.svg) |\n| mediumseagreen | #3CB371 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_mediumseagreen.svg)|\n| mediumslateblue | #7B68EE | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_mediumslateblue.svg)|\n| mediumspringgreen | #00FA9A | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_mediumspringgreen.svg)|\n| mediumturquoise | #48D1CC | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_mediumturquoise.svg)|\n| mediumvioletred | #C71585 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_mediumvioletred.svg)|\n| midnightblue | #191970 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_midnightblue.svg) |\n| mintcream | #F5FFFA | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_mintcream.svg) |\n| mistyrose | #FFE4E1 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_mistyrose.svg) |\n| moccasin | #FFE4B5 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_moccasin.svg) |\n| navajowhite | #FFDEAD | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_navajowhite.svg) |\n| navy | #000080 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_navy.svg) |\n| oldlace | #FDF5E6 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_oldlace.svg) |\n| olive | #808000 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_olive.svg) |\n| olivedrab | #6B8E23 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_olivedrab.svg) |\n| orange | #FE7D37 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_orange.svg) |\n| orangered | #FF4500 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_orangered.svg) |\n| orange_2 | #FFA500 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_orange_2.svg) |\n| orchid | #DA70D6 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_orchid.svg) |\n| palegoldenrod | #EEE8AA | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_palegoldenrod.svg)|\n| palegreen | #98FB98 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_palegreen.svg) |\n| paleturquoise | #AFEEEE | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_paleturquoise.svg)|\n| palevioletred | #DB7093 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_palevioletred.svg)|\n| papayawhip | #FFEFD5 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_papayawhip.svg) |\n| peachpuff | #FFDAB9 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_peachpuff.svg) |\n| peru | #CD853F | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_peru.svg) |\n| pink | #FFC0CB | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_pink.svg) |\n| plum | #DDA0DD | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_plum.svg) |\n| powderblue | #B0E0E6 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_powderblue.svg) |\n| purple | #800080 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_purple.svg) |\n| rebeccapurple | #663399 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_rebeccapurple.svg)|\n| red | #E05D44 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_red.svg) |\n| rosybrown | #BC8F8F | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_rosybrown.svg) |\n| royalblue | #4169E1 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_royalblue.svg) |\n| saddlebrown | #8B4513 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_saddlebrown.svg) |\n| salmon | #FA8072 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_salmon.svg) |\n| sandybrown | #F4A460 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_sandybrown.svg) |\n| seagreen | #2E8B57 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_seagreen.svg) |\n| seashell | #FFF5EE | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_seashell.svg) |\n| sienna | #A0522D | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_sienna.svg) |\n| silver | #C0C0C0 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_silver.svg) |\n| skyblue | #87CEEB | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_skyblue.svg) |\n| slateblue | #6A5ACD | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_slateblue.svg) |\n| slategray | #708090 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_slategray.svg) |\n| snow | #FFFAFA | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_snow.svg) |\n| springgreen | #00FF7F | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_springgreen.svg) |\n| steelblue | #4682B4 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_steelblue.svg) |\n| tan | #D2B48C | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_tan.svg) |\n| teal | #008080 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_teal.svg) |\n| thistle | #D8BFD8 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_thistle.svg) |\n| tomato | #FF6347 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_tomato.svg) |\n| turquoise | #40E0D0 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_turquoise.svg) |\n| violet | #EE82EE | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_violet.svg) |\n| wheat | #F5DEB3 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_wheat.svg) |\n| white | #FFFFFF | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_white.svg) |\n| whitesmoke | #F5F5F5 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_whitesmoke.svg) |\n| yellow | #DFB317 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_yellow.svg) |\n| yellowgreen | #9ACD32 | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_yellowgreen.svg) |\n| yellow_green | #A4A61D | ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/color_yellow_green.svg) |\n\n### Emojis\n\nIt is possible to use emoji characters in badge labels and values. Here are some examples:\n\n![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/pipeline_frown.svg)\n![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/pipeline_smile.svg)\n![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/documentation_link.svg)\n![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/pypi_link.svg)\n\nThese files were created by using the **actual** emoji character in the label/value text. For example:\n\n```python\nbadge = anybadge.Badge(label=\"Pipeline status\", value=\"\ud83d\ude04\")\n```\n\nThere are some caveats worth mentioning:\n- The \"look\" of the emoji is determined by the client (Emoji characters are placed as-is into the SVG file, and are\n rendered client-side)\n- Rendering may fail in some viewers and developer IDEs (for example, PyCharm does not render emojis in the svg viewer)\n- Emojis can have different widths, so the layout may be affected. You can use `num_label_padding_chars` and\n `num_value_padding_chars` to fix (see below)\n\nHere are some examples to show how to use padding to fix layout:\n\n| Badge | Code |\n| ----- |----------------------------------------------------------------------|\n| ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/pipeline_smile.svg) | `anybadge.Badge(\"Pipeline status\", \"\ud83d\ude04\")` |\n| ![](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/pipeline_smile_padding.svg) | `anybadge.Badge(\"Pipeline status\", \"\ud83d\ude04\", num_value_padding_chars=1)` |\n\n### Semantic version support\n\nAnybadge supports semantic versions for value and threshold keys. This supports color-coded\nbadges based on version numbering. Here are some examples:\n\n```python\nbadge = Badge(\n label='Version',\n value='3.0.0',\n thresholds={'3.0.0': 'red', '3.2.0': 'orange', '999.0.0': 'green'},\n semver=True\n)\n```\n\nIn the above example the thresholds equate to the following:\n\n* If value is < 3.0.0 then badge will be red.\n* If value is < 3.2.0 then badge will be orange.\n* If value is < 999.0.0 then badge will be green.\n\nEach threshold entry is used to define the upper bounds of the threshold. If you don't know the\nupper bound for your version number threshold you will need to provide an extreme upper bound -\nin this example it is `999.0.0`.\n\n### Examples\n\n#### Pylint using template\n```bash\nanybadge --value=2.22 --file=pylint.svg pylint\n```\n![pylint](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/pylint.svg)\n\n#### Pylint using arguments\n```bash\nanybadge -l pylint -v 2.22 -f pylint.svg 2=red 4=orange 8=yellow 10=green\n```\n![pylint](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/pylint.svg)\n\n#### Coverage using template\n```bash\nanybadge --value=65 --file=coverage.svg coverage\n```\n![coverage](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/coverage.svg)\n\n#### Pipeline, using labeled colors\n```bash\nanybadge --label=pipeline --value=passing --file=pipeline.svg passing=green failing=red\n```\n![pipeline](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/pipeline.svg)\n\n#### Badge with fixed color\n```bash\nanybadge --label=awesomeness --value=\"110%\" --file=awesomeness.svg --color='#97CA00'\n```\n![awesomeness](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/awesomeness.svg)\n\n#### GitLab Scoped style badge\n```bash\nanybadge --style=gitlab-scoped --label=Project --value=Archimedes --file=gitlab_scoped.svg --color='#c1115d'\n```\n![gitlab_scoped](https://cdn.rawgit.com/jongracecox/anybadge/master/examples/gitlab_scoped.svg)\n\n#### Thresholds based on semantic versions\n```bash\nanybadge --label=Version --value=2.4.5 --file=version.svg 1.0.0=red 2.4.6=orange 2.9.1=yellow 999.0.0=green\n```\n\n#### Importing in your own app\n```python\nfrom anybadge import Badge\n\ntest1 = Badge(\n label,\n value,\n font_name='DejaVu Sans,Verdana,Geneva,sans-serif',\n font_size=11,\n num_padding_chars=0.5,\n template='<?xml version=\"1.0\" encoding=\"UTF-8\"?>\\n<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"{{ badge width }}\" height=\"20\">\\n <linearGradient id=\"b\" x2=\"0\" y2=\"100%\">\\n <stop offset=\"0\" stop-color=\"#bbb\" stop-opacity=\".1\"/>\\n <stop offset=\"1\" stop-opacity=\".1\"/>\\n </linearGradient>\\n <mask id=\"a\">\\n <rect width=\"{{ badge width }}\" height=\"20\" rx=\"3\" fill=\"#fff\"/>\\n </mask>\\n <g mask=\"url(#a)\">\\n <path fill=\"#555\" d=\"M0 0h{{ color split x }}v20H0z\"/>\\n <path fill=\"{{ color }}\" d=\"M{{ color split x }} 0h{{ value width }}v20H{{ color split x }}z\"/>\\n <path fill=\"url(#b)\" d=\"M0 0h{{ badge width }}v20H0z\"/>\\n </g>\\n <g fill=\"{{ label text color }}\" text-anchor=\"middle\" font-family=\"{{ font name }}\" font-size=\"{{ font size }}\">\\n <text x=\"{{ label anchor shadow }}\" y=\"15\" fill=\"#010101\" fill-opacity=\".3\">{{ label }}</text>\\n <text x=\"{{ label anchor }}\" y=\"14\">{{ label }}</text>\\n </g>\\n <g fill=\"{{ value text color }}\" text-anchor=\"middle\" font-family=\"{{ font name }}\" font-size=\"{{ font size }}\">\\n <text x=\"{{ value anchor shadow }}\" y=\"15\" fill=\"#010101\" fill-opacity=\".3\">{{ value }}</text>\\n <text x=\"{{ value anchor }}\" y=\"14\">{{ value }}</text>\\n </g>\\n</svg>',\n value_prefix='',\n value_suffix='',\n thresholds=None,\n default_color='#4c1',\n use_max_when_value_exceeds=True,\n value_format=None,\n text_color='#fff'\n)\n\ntest1.write_badge('test1.svg')\n```\n\n### Command-line options\n\nThe command line options can be viewed using `anybadge --help`.\n\nExamples\n--------\n\nHere are some usage specific command line examples that may save time on defining\nthresholds.\n\nPylint::\n\n```\nanybadge.py --value=2.22 --file=pylint.svg pylint\nanybadge.py --label=pylint --value=2.22 --file=pylint.svg 2=red 4=orange 8=yellow 10=green\n```\n\nCoverage::\n\n```\nanybadge.py --value=65 --file=coverage.svg coverage\nanybadge.py --label=coverage --value=65 --suffix='%%' --file=coverage.svg 50=red 60=orange 80=yellow 100=green\n```\n\nCI Pipeline::\n\n```\nanybadge.py --label=pipeline --value=passing --file=pipeline.svg passing=green failing=red\n```\n\nPython usage\n============\n\nFor Python API details you can use the inbuilt documentation:\n\n```python\nfrom anybadge import badge\nhelp(badge)\n```\n",
"bugtrack_url": null,
"license": "",
"summary": "Simple, flexible badge generator for project badges.",
"version": "1.14.0",
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"md5": "8c7cb73d5c07ca0389088caf550f24d1",
"sha256": "8711a7f7f45317c62a460f14084f005ba665cbebdf2a94e7df53bc3ab35df4c9"
},
"downloads": -1,
"filename": "anybadge-1.14.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "8c7cb73d5c07ca0389088caf550f24d1",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 27258,
"upload_time": "2022-08-24T22:43:34",
"upload_time_iso_8601": "2022-08-24T22:43:34.358189Z",
"url": "https://files.pythonhosted.org/packages/f7/44/71df611ee7e19c852caa829bac653662dafec909dbe3e1b99b5ad419cefc/anybadge-1.14.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"md5": "528f54374bebbbac96fc13042be870e7",
"sha256": "47f06e0a6320d3e5eac55c712dc0bab71b9ed85353c591d448653c5a0740783f"
},
"downloads": -1,
"filename": "anybadge-1.14.0.tar.gz",
"has_sig": false,
"md5_digest": "528f54374bebbbac96fc13042be870e7",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 29606,
"upload_time": "2022-08-24T22:43:36",
"upload_time_iso_8601": "2022-08-24T22:43:36.187484Z",
"url": "https://files.pythonhosted.org/packages/a3/f2/9f55245d6f456b661b38650767410f3b51d66a8530f0e0a43909bd475165/anybadge-1.14.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2022-08-24 22:43:36",
"github": true,
"gitlab": false,
"bitbucket": false,
"github_user": "jongracecox",
"github_project": "anybadge",
"travis_ci": true,
"coveralls": false,
"github_actions": false,
"lcname": "anybadge"
}