├── tests
├── __init__.py
└── template.svg
├── anybadge
├── server
│ ├── __init__.py
│ ├── __main__.py
│ └── config.py
├── exceptions.py
├── __main__.py
├── __init__.py
├── config.py
├── templates
│ ├── __init__.py
│ ├── gitlab_scoped.svg
│ └── default.svg
└── styles.py
├── docker
└── test
│ ├── requirements.txt
│ ├── run_docker_tests.sh
│ ├── Dockerfile
│ ├── helpers.sh
│ └── run_pypi_tests.sh
├── measurements.png
├── anybadge_server.py
├── CHANGELOG.md
├── tox.ini
├── AUTHORS.rst
├── Dockerfile
├── TODO.md
├── tasks
├── housekeeping.py
├── __init__.py
├── server.py
└── package.py
├── .pre-commit-config.yaml
├── .github
├── ISSUE_TEMPLATE
│ ├── feature_request.md
│ └── bug_report.md
└── workflows
│ ├── tox.yaml
│ └── pr_check.yaml
├── examples
├── gitlab_scoped.svg
├── pylint.svg
├── coverage.svg
├── pipeline.svg
├── awesomeness.svg
├── pypi_link.svg
├── color_aqua.svg
├── value_only.svg
├── color_azure.svg
├── color_beige.svg
├── color_black.svg
├── color_blue.svg
├── color_brown.svg
├── color_coral.svg
├── color_gold.svg
├── color_gray.svg
├── color_green.svg
├── color_ivory.svg
├── color_khaki.svg
├── color_lime.svg
├── color_linen.svg
├── color_navy.svg
├── color_peru.svg
├── color_pink.svg
├── color_plum.svg
├── color_red.svg
├── color_snow.svg
├── color_tan.svg
├── color_teal.svg
├── label_only.svg
├── color_bisque.svg
├── color_indigo.svg
├── color_maroon.svg
├── color_olive.svg
├── color_orange.svg
├── color_orchid.svg
├── color_purple.svg
├── color_salmon.svg
├── color_sienna.svg
├── color_silver.svg
├── color_tomato.svg
├── color_violet.svg
├── color_wheat.svg
├── color_white.svg
├── color_yellow.svg
├── color_crimson.svg
├── color_darkred.svg
├── color_dimgray.svg
├── color_fuchsia.svg
├── color_green_2.svg
├── color_hotpink.svg
├── color_oldlace.svg
├── color_skyblue.svg
├── color_thistle.svg
├── color_aliceblue.svg
├── color_brightred.svg
├── color_burlywood.svg
├── color_cadetblue.svg
├── color_chocolate.svg
├── color_cornsilk.svg
├── color_darkblue.svg
├── color_darkcyan.svg
├── color_darkgray.svg
├── color_darkgreen.svg
├── color_darkkhaki.svg
├── color_deeppink.svg
├── color_firebrick.svg
├── color_gainsboro.svg
├── color_goldenrod.svg
├── color_honeydew.svg
├── color_indianred.svg
├── color_lavender.svg
├── color_lawngreen.svg
├── color_lightblue.svg
├── color_lightcyan.svg
├── color_lightgray.svg
├── color_lightgrey.svg
├── color_lightpink.svg
├── color_limegreen.svg
├── color_mintcream.svg
├── color_mistyrose.svg
├── color_moccasin.svg
├── color_orange_2.svg
├── color_seagreen.svg
├── color_seashell.svg
├── color_aquamarine.svg
├── color_blueviolet.svg
├── color_bright_red.svg
├── color_chartreuse.svg
├── color_darkorange.svg
├── color_darkorchid.svg
├── color_darksalmon.svg
├── color_darkviolet.svg
├── color_dodgerblue.svg
├── color_ghostwhite.svg
├── color_light_grey.svg
├── color_lightcoral.svg
├── color_lightgreen.svg
├── color_mediumblue.svg
├── color_olivedrab.svg
├── color_orangered.svg
├── color_palegreen.svg
├── color_papayawhip.svg
├── color_peachpuff.svg
├── color_powderblue.svg
├── color_rosybrown.svg
├── color_royalblue.svg
├── color_sandybrown.svg
├── color_slateblue.svg
├── color_slategray.svg
├── color_steelblue.svg
├── color_turquoise.svg
├── color_whitesmoke.svg
├── documentation_link.svg
├── color_antiquewhite.svg
├── color_brightyellow.svg
├── color_darkmagenta.svg
├── color_darkseagreen.svg
├── color_deepskyblue.svg
├── color_floralwhite.svg
├── color_forestgreen.svg
├── color_greenyellow.svg
├── color_lemonchiffon.svg
├── color_lightsalmon.svg
├── color_lightskyblue.svg
├── color_lightyellow.svg
├── color_mediumorchid.svg
├── color_mediumpurple.svg
├── color_midnightblue.svg
├── color_navajowhite.svg
├── color_saddlebrown.svg
├── color_springgreen.svg
├── color_yellowgreen.svg
├── pipeline_frown.svg
├── pipeline_smile.svg
├── color_blanchedalmond.svg
├── color_bright_yellow.svg
├── color_cornflowerblue.svg
├── color_darkgoldenrod.svg
├── color_darkslateblue.svg
├── color_darkslategray.svg
├── color_darkturquoise.svg
├── color_lavenderblush.svg
├── color_lightseagreen.svg
├── color_lightslategray.svg
├── color_lightsteelblue.svg
├── color_palegoldenrod.svg
├── color_paleturquoise.svg
├── color_palevioletred.svg
├── color_rebeccapurple.svg
├── color_yellow_green.svg
├── pipeline_smile_padding.svg
├── color_darkolivegreen.svg
├── color_mediumseagreen.svg
├── color_mediumslateblue.svg
├── color_mediumturquoise.svg
├── color_mediumvioletred.svg
├── color_mediumaquamarine.svg
├── color_mediumspringgreen.svg
└── color_lightgoldenrodyellow.svg
├── LICENSE
└── setup.py
/tests/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/anybadge/server/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/docker/test/requirements.txt:
--------------------------------------------------------------------------------
1 | packaging
2 | pytest
3 | pytest-cov
4 | requests
5 |
--------------------------------------------------------------------------------
/measurements.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jongracecox/anybadge/HEAD/measurements.png
--------------------------------------------------------------------------------
/anybadge/exceptions.py:
--------------------------------------------------------------------------------
1 | class UnknownBadgeTemplate(Exception):
2 | """The badge template is unknown."""
3 |
--------------------------------------------------------------------------------
/anybadge_server.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | if __name__ == "__main__":
3 | from anybadge.server.cli import main
4 | import sys
5 |
6 | print(sys.argv)
7 | main()
8 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # 0.2.0
2 | - Removed bright green color (including pylint and coverage defaults) (#7)
3 | - Add ability to choose text color (#6)
4 |
5 | # 0.1.0
6 | - Initial release.
7 |
--------------------------------------------------------------------------------
/tox.ini:
--------------------------------------------------------------------------------
1 | [tox]
2 | envlist = py37, py38, py39, py310, py311, py312, py313
3 |
4 | [testenv]
5 | deps =
6 | pytest
7 | -rbuild-requirements.txt
8 | commands =
9 | pytest --doctest-modules anybadge tests
10 |
--------------------------------------------------------------------------------
/anybadge/__main__.py:
--------------------------------------------------------------------------------
1 | from .cli import main
2 |
3 | if __name__ == "__main__":
4 | # ensure that `anybadge` shows in usage (not __main__.py)
5 | import sys
6 |
7 | sys.argv[0] = "anybadge"
8 |
9 | main()
10 |
--------------------------------------------------------------------------------
/anybadge/server/__main__.py:
--------------------------------------------------------------------------------
1 | from .cli import main
2 |
3 | if __name__ == "__main__":
4 | # ensure that `anybadge-server` shows in usage (not `__main__.py`)
5 | import sys
6 |
7 | sys.argv[0] = "anybadge-server"
8 |
9 | main()
10 |
--------------------------------------------------------------------------------
/docker/test/run_docker_tests.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | echo "Running tests..."
4 | mkdir tmp && cd tmp
5 | mkdir tests
6 | pip install /app/dist/anybadge*.whl
7 | pytest --doctest-modules --cov=anybadge --cov-report html:htmlcov /app/anybadge /app/tests
8 |
--------------------------------------------------------------------------------
/anybadge/server/config.py:
--------------------------------------------------------------------------------
1 | import logging
2 |
3 |
4 | DEFAULT_SERVER_PORT: int = 8000
5 | DEFAULT_SERVER_LISTEN_ADDRESS: str = "localhost"
6 | DEFAULT_LOGGING_LEVEL = logging.INFO
7 |
8 | SERVER_PORT: int = DEFAULT_SERVER_PORT
9 | SERVER_LISTEN_ADDRESS: str = DEFAULT_SERVER_LISTEN_ADDRESS
10 |
--------------------------------------------------------------------------------
/docker/test/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM python:3.10.0
2 |
3 | WORKDIR /work
4 |
5 | RUN apt update && pip install -U pip
6 | COPY requirements.txt ./
7 | RUN pip install -r ./requirements.txt
8 | COPY run_docker_tests.sh ./
9 | COPY run_pypi_tests.sh ./
10 | COPY helpers.sh ./
11 | COPY shell_tests.sh ./
12 |
--------------------------------------------------------------------------------
/anybadge/__init__.py:
--------------------------------------------------------------------------------
1 | import re
2 | from .badge import Badge
3 | from .colors import Color
4 | from .styles import Style
5 |
6 | # Package information
7 | version = __version__ = "0.0.0"
8 | __version_info__ = tuple(re.split("[.-]", __version__))
9 | __title__ = "anybadge"
10 | __summary__ = "A simple, flexible badge generator."
11 | __uri__ = "https://github.com/jongracecox/anybadge"
12 |
--------------------------------------------------------------------------------
/AUTHORS.rst:
--------------------------------------------------------------------------------
1 | #######
2 | AUTHORS
3 | #######
4 |
5 | - Jon Grace-Cox <30441316+jongracecox@users.noreply.github.com>
6 | - run ``git log --format='%aN' | sort -u`` to see all contributors, or::
7 |
8 | git log --format='%aN <%aE>' |
9 | awk '{arr[$0]++} END{for (i in arr){print arr[i], i;}}' |
10 | sort -rn | cut -d\ -f2-
11 |
12 | to sort them by the numbers of commits.
13 |
--------------------------------------------------------------------------------
/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM python:3-alpine
2 |
3 | WORKDIR /app
4 |
5 | RUN apk update
6 |
7 | RUN pip install -U pip && pip install packaging
8 |
9 | COPY anybadge/ /app/anybadge/
10 | COPY anybadge_server.py /app/.
11 |
12 | ENTRYPOINT ["./anybadge_server.py"]
13 |
14 | # Example command to run Docker container
15 | # docker run -it --rm -p8000:8000 -e ANYBADGE_LISTEN_ADDRESS="" -e ANYBADGE_LOG_LEVEL=DEBUG labmonkey/anybadge:1.0
16 |
--------------------------------------------------------------------------------
/docker/test/helpers.sh:
--------------------------------------------------------------------------------
1 | error() {
2 | echo "==============================================================================="
3 | echo " An error was encountered."
4 | echo "==============================================================================="
5 | }
6 |
7 | check_rc() {
8 | if [[ $? -ne 0 ]]; then
9 | error
10 | exit 1
11 | fi
12 | }
13 |
14 | export TEST_FILES="${PROJECT_DIR:-}/test_files"
15 |
--------------------------------------------------------------------------------
/TODO.md:
--------------------------------------------------------------------------------
1 | # To do list
2 |
3 | * [x] Add `serve` functionality, which starts up a web server to serve results.
4 | * [ ] Incorporate server into main anybadge module (allowing `anybadge serve`)
5 | * [ ] Allow thresholds dictionary to be passed through URL
6 | * [x] Create a Docker image to run server
7 | * [ ] Add CI test for Docker image
8 | * [ ] Add CI to push server to Docker hub
9 | * [ ] Support common badge server URL structure
10 | * [ ] Documentation for all docker bits
11 |
--------------------------------------------------------------------------------
/docker/test/run_pypi_tests.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | source "${SOURCE_DIR:-.}/helpers.sh" || { echo "Failed to load helpers." ; exit 1 ; }
4 |
5 | if [[ -z ${VERSION} ]] || [[ ${VERSION} = latest ]]; then
6 | version_str=""
7 | else
8 | version_str="==$VERSION"
9 | fi
10 |
11 | echo -n "Installing anybadge${version_str}... "
12 | pip install "anybadge${version_str}" > "${TEST_FILES}/pip_install.log" 2>&1
13 | check_rc
14 | echo "OK"
15 |
16 | "${SOURCE_DIR:-.}/shell_tests.sh"
17 |
--------------------------------------------------------------------------------
/tasks/housekeeping.py:
--------------------------------------------------------------------------------
1 | import glob
2 | import subprocess
3 | from invoke import task
4 |
5 |
6 | def delete_files(files: str):
7 | for file in glob.glob(files):
8 | print(f" Deleting {file}")
9 | subprocess.run(["rm", "-rf", file])
10 |
11 |
12 | @task
13 | def clean(c):
14 | """Clean up the project area."""
15 | print("Cleaning the project directory...")
16 | delete_files("dist/*")
17 | delete_files("tests/test_*.svg")
18 | delete_files("test_files/*")
19 |
--------------------------------------------------------------------------------
/.pre-commit-config.yaml:
--------------------------------------------------------------------------------
1 | repos:
2 | - repo: https://github.com/pre-commit/pre-commit-hooks
3 | rev: v5.0.0
4 | hooks:
5 | - id: trailing-whitespace
6 | - id: end-of-file-fixer
7 | - id: check-case-conflict
8 | - id: check-yaml
9 | - id: requirements-txt-fixer
10 | - id: mixed-line-ending
11 | - id: no-commit-to-branch
12 | args: [--branch, master]
13 | - repo: https://github.com/psf/black
14 | rev: 24.10.0
15 | hooks:
16 | - id: black
17 | - repo: https://github.com/pre-commit/mirrors-mypy
18 | rev: v1.14.0
19 | hooks:
20 | - id: mypy
21 | additional_dependencies: [types-requests]
22 |
--------------------------------------------------------------------------------
/anybadge/config.py:
--------------------------------------------------------------------------------
1 | # Set some defaults
2 | from typing import Dict
3 |
4 | DEFAULT_FONT: str = "DejaVu Sans,Verdana,Geneva,sans-serif"
5 | DEFAULT_FONT_SIZE: int = 11
6 | NUM_PADDING_CHARS: float = 0.5
7 | DEFAULT_COLOR: str = "#4c1"
8 | DEFAULT_TEXT_COLOR: str = "#fff"
9 | MASK_ID_PREFIX: str = "anybadge_"
10 |
11 | # Dictionary for looking up approx pixel widths of
12 | # supported fonts and font sizes.
13 | FONT_WIDTHS: Dict[str, Dict[int, int]] = {
14 | "DejaVu Sans,Verdana,Geneva,sans-serif": {
15 | 10: 9,
16 | 11: 10,
17 | 12: 11,
18 | },
19 | "Arial, Helvetica, sans-serif": {
20 | 11: 8,
21 | },
22 | }
23 |
--------------------------------------------------------------------------------
/anybadge/templates/__init__.py:
--------------------------------------------------------------------------------
1 | """Templates package."""
2 |
3 | import pkgutil
4 |
5 | from anybadge.exceptions import UnknownBadgeTemplate
6 |
7 |
8 | def get_template(name: str) -> str:
9 | """Get a template by name.
10 |
11 | Examples:
12 |
13 | >>> get_template('default') # doctest: +ELLIPSIS
14 | ' bool:
20 | """Test whether a style exists."""
21 | try:
22 | _ = cls[name]
23 | return True
24 | except KeyError:
25 | return False
26 |
--------------------------------------------------------------------------------
/tasks/package.py:
--------------------------------------------------------------------------------
1 | import subprocess
2 | from pathlib import Path
3 |
4 | from invoke import task
5 |
6 | PROJECT_DIR = Path(__file__).parent.parent
7 |
8 |
9 | def run_build():
10 | subprocess.run(["python", "setup.py", "bdist_wheel"])
11 |
12 |
13 | @task
14 | def build(c):
15 | """Build the package and write wheel to 'dist/' directory."""
16 | print("Building package...")
17 | run_build()
18 |
19 |
20 | @task
21 | def install(c):
22 | """Install the locally built version from 'dist/'."""
23 | print("Installing package...")
24 | file_list = list((Path(PROJECT_DIR) / Path("dist")).glob("anybadge-*.whl"))
25 | if len(file_list) > 1:
26 | print("Not sure which dist package to install. Clean dist directory first.")
27 | return
28 | dist_file = file_list[0]
29 | print(f"Installing: {dist_file}")
30 | subprocess.run(["pip", "install", "--force-reinstall", dist_file])
31 |
--------------------------------------------------------------------------------
/examples/gitlab_scoped.svg:
--------------------------------------------------------------------------------
1 |
2 |
23 |
--------------------------------------------------------------------------------
/.github/workflows/tox.yaml:
--------------------------------------------------------------------------------
1 | name: Run Tox Tests
2 |
3 | on:
4 | push:
5 | branches:
6 | - master
7 | paths:
8 | - 'anybadge/**'
9 | - 'tests/**'
10 | - '.github/workflows/tox.yaml'
11 | - 'tox.ini'
12 | pull_request:
13 | branches:
14 | - master
15 | paths:
16 | - 'anybadge/**'
17 | - 'tests/**'
18 | - '.github/workflows/tox.yaml'
19 | - 'tox.ini'
20 |
21 | jobs:
22 | test:
23 | name: Test with Tox
24 | runs-on: ubuntu-latest
25 |
26 | strategy:
27 | matrix:
28 | python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
29 |
30 | steps:
31 | - name: Checkout code
32 | uses: actions/checkout@v3
33 |
34 | - name: Set up Python
35 | uses: actions/setup-python@v4
36 | with:
37 | python-version: ${{ matrix.python-version }}
38 |
39 | - name: Install tox
40 | run: |
41 | python -m pip install --upgrade pip
42 | pip install tox
43 |
44 | - name: Run Tox
45 | run: tox -e py${{ matrix.python-version }}
46 |
--------------------------------------------------------------------------------
/examples/pylint.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/coverage.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/pipeline.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/awesomeness.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/pypi_link.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_aqua.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/value_only.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2017 jongracecox
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/examples/color_azure.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_beige.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_black.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_blue.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_brown.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_coral.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_gold.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_gray.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_green.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_ivory.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_khaki.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_lime.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_linen.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_navy.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_peru.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_pink.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_plum.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_red.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_snow.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_tan.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_teal.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/label_only.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_bisque.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_indigo.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_maroon.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_olive.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_orange.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_orchid.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_purple.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_salmon.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_sienna.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_silver.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_tomato.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_violet.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_wheat.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_white.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_yellow.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_crimson.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_darkred.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_dimgray.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_fuchsia.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_green_2.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_hotpink.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_oldlace.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_skyblue.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_thistle.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_aliceblue.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_brightred.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_burlywood.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_cadetblue.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_chocolate.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_cornsilk.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_darkblue.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_darkcyan.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_darkgray.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_darkgreen.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_darkkhaki.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_deeppink.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_firebrick.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_gainsboro.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_goldenrod.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_honeydew.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_indianred.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_lavender.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_lawngreen.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_lightblue.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_lightcyan.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_lightgray.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_lightgrey.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_lightpink.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_limegreen.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_mintcream.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_mistyrose.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_moccasin.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_orange_2.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_seagreen.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_seashell.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_aquamarine.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_blueviolet.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_bright_red.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_chartreuse.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_darkorange.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_darkorchid.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_darksalmon.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_darkviolet.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_dodgerblue.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_ghostwhite.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_light_grey.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_lightcoral.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_lightgreen.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_mediumblue.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_olivedrab.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_orangered.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_palegreen.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_papayawhip.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_peachpuff.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_powderblue.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_rosybrown.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_royalblue.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_sandybrown.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_slateblue.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_slategray.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_steelblue.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_turquoise.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_whitesmoke.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/documentation_link.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_antiquewhite.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_brightyellow.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_darkmagenta.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_darkseagreen.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_deepskyblue.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_floralwhite.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_forestgreen.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_greenyellow.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_lemonchiffon.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_lightsalmon.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_lightskyblue.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_lightyellow.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_mediumorchid.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_mediumpurple.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_midnightblue.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_navajowhite.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_saddlebrown.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_springgreen.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_yellowgreen.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/pipeline_frown.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/pipeline_smile.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_blanchedalmond.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_bright_yellow.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_cornflowerblue.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_darkgoldenrod.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_darkslateblue.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_darkslategray.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_darkturquoise.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_lavenderblush.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_lightseagreen.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_lightslategray.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_lightsteelblue.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_palegoldenrod.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_paleturquoise.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_palevioletred.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_rebeccapurple.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_yellow_green.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/pipeline_smile_padding.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_darkolivegreen.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_mediumseagreen.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_mediumslateblue.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_mediumturquoise.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_mediumvioletred.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_mediumaquamarine.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_mediumspringgreen.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/examples/color_lightgoldenrodyellow.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/anybadge/templates/gitlab_scoped.svg:
--------------------------------------------------------------------------------
1 |
2 |
23 |
--------------------------------------------------------------------------------
/tests/template.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/anybadge/templates/default.svg:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/.github/workflows/pr_check.yaml:
--------------------------------------------------------------------------------
1 | ---
2 |
3 | name: PR Check
4 |
5 | on:
6 | pull_request:
7 | branches:
8 | - master
9 | push:
10 | branches:
11 | - master
12 |
13 | jobs:
14 | pre-commit:
15 | runs-on: ubuntu-latest
16 |
17 | steps:
18 | - uses: actions/checkout@v3
19 |
20 | - name: Set up Python
21 | uses: actions/setup-python@v4
22 | with:
23 | python-version: '3.12'
24 |
25 | - name: Install dependencies
26 | run: |
27 | python -m pip install --upgrade pip setuptools wheel
28 | pip install -r build-requirements.txt
29 | pip install pre-commit
30 |
31 | - name: Run pre-commit
32 | run: SKIP=no-commit-to-branch pre-commit run --all-files
33 |
34 | python-tests:
35 | needs: pre-commit
36 | runs-on: ubuntu-latest
37 |
38 | steps:
39 | - name: Checkout code
40 | uses: actions/checkout@v3
41 | with:
42 | fetch-depth: 0 # Fetch the entire history including tags
43 |
44 | - name: Set up Python
45 | uses: actions/setup-python@v4
46 | with:
47 | python-version: '3.12'
48 |
49 | - name: Install dependencies
50 | run: |
51 | python -m pip install --upgrade pip setuptools wheel
52 | pip install -r build-requirements.txt
53 |
54 | - name: Build package
55 | run: python setup.py bdist_wheel
56 |
57 | - name: Install package
58 | run: pip install dist/*.whl
59 |
60 | - name: Run tests
61 | run: pytest --doctest-modules --cov=anybadge --cov-report term --cov-report xml:coverage.xml --cov-report html:htmlcov anybadge tests
62 |
63 | - name: CLI tests
64 | run: docker/test/shell_tests.sh
65 |
--------------------------------------------------------------------------------
/setup.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python
2 | import os
3 | import re
4 | import subprocess
5 | from setuptools import setup
6 |
7 | with open("README.md", encoding="utf-8") as f:
8 | long_description = f.read()
9 |
10 |
11 | def get_version():
12 | """Get the version from git tags.
13 |
14 | Version is determined by the latest git tag, and will be the tag name without the leading 'v'.
15 |
16 | Returns:
17 | str: The version number.
18 | """
19 | try:
20 | # Get the latest git tag
21 | version = subprocess.check_output(
22 | ["git", "describe", "--tags", "--abbrev=0"], encoding="utf-8"
23 | ).strip()
24 | version = re.sub("^v", "", version)
25 | return version
26 |
27 | except subprocess.CalledProcessError:
28 | return "0.0.0"
29 |
30 |
31 | setup(
32 | name="anybadge",
33 | description="Simple, flexible badge generator for project badges.",
34 | long_description=long_description,
35 | long_description_content_type="text/markdown",
36 | version=get_version(),
37 | author="Jon Grace-Cox",
38 | author_email="30441316+jongracecox@users.noreply.github.com",
39 | packages=["anybadge", "anybadge.templates", "anybadge.server"],
40 | py_modules=["anybadge_server"],
41 | setup_requires=["setuptools", "wheel"],
42 | tests_require=[],
43 | install_requires=["packaging"],
44 | package_data={"anybadge": ["templates/*.svg"]},
45 | options={"bdist_wheel": {"universal": False}},
46 | python_requires=">=3.7",
47 | url="https://github.com/jongracecox/anybadge",
48 | entry_points={
49 | "console_scripts": [
50 | "anybadge=anybadge.cli:main",
51 | "anybadge-server=anybadge.server.cli:main",
52 | ],
53 | },
54 | classifiers=["License :: OSI Approved :: MIT License"],
55 | )
56 |
--------------------------------------------------------------------------------