mirror of
https://github.com/jongracecox/anybadge.git
synced 2026-01-06 12:21:12 +01:00
- Drop support for Python <3.7 - Bump the pre-commit version used in CI - Add type hinting and docstrings - Add mypy to pre-commit config - Fix typing issues - Update colors module - Update colors module to use uppercase hex codes - Add `__lt__` to allow sorting colors by name - Fix `build_examples.py` to work with color Enum - Update example badges in `README.md` - Fix typing issues in server - Update travis links in `README.md` - Fix PyPi deployment bug (#60)
25 lines
523 B
Python
25 lines
523 B
Python
"""Templates package."""
|
|
import pkgutil
|
|
|
|
from anybadge.exceptions import UnknownBadgeTemplate
|
|
|
|
|
|
def get_template(name: str) -> str:
|
|
"""Get a template by name.
|
|
|
|
Examples:
|
|
|
|
>>> get_template('default') # doctest: +ELLIPSIS
|
|
'<?xml version="1.0" encoding="UTF-8...
|
|
|
|
"""
|
|
try:
|
|
data = pkgutil.get_data(__name__, name + ".svg")
|
|
except FileNotFoundError as e:
|
|
raise UnknownBadgeTemplate from e
|
|
|
|
if not data:
|
|
raise UnknownBadgeTemplate
|
|
|
|
return data.decode("utf-8")
|