{ "info": { "author": "Gunnar Strand", "author_email": "Gurra.Strand@gmail.com", "bugtrack_url": null, "classifiers": [], "description": "abadge\n======\n\nGenerate status badges/shields of pure HTML+CSS.\n\n.. image:: docs/abadge-discovered.png\n\nOverview\n--------\n\nThe ``Badge`` class in the module is used to generate status badges. It\nsupports various configuration options like font, background etc., and also\nincludes threshold support, which is useful for presenting job status, for\nexample.\n\nUsage\n-----\n\n``Badge`` can be instantiated to generate many badges with the same format::\n\n from abadge import Badge\n\n success_badge = Badge(value_text_color='#11a')\n print(success_badge.to_html('build', 'passed'))\n print(success_badge.to_html('tests', 'ok'))\n\nor for one-shot generation::\n\n print(Badge(label='tests', value='4/8').to_html())\n print(Badge().to_html(label='tests', value='4/8')) # Same thing\n print(Badge.make_badge(tests, '4/8')) # This too\n\nThe arguments to all of the methods are identical. The arguments to the\nconstructor will be stored in the instance as default values which can then\nbe overridden by the arguments to the ``to_html`` method. ``make_badge`` always\nuse the class default configuration (it is a class method).\n\nArguments\n'''''''''\n\nAll three methods support the following arguments:\n\nOptional arguments\n..................\n\n:*label*:\n text for the label (left) part. Can also be given as keyword argument\n ``label=``\n\n:*value*:\n text for the value (right) part. Can also be given as keyword argument\n ``value=``\n\nKeyword arguments\n.................\n\n:``border_radius``:\n how rounded the corners of the badge should be (CSS \"``padding``\")\n\n:``font_family``: font to use in the badge (CSS \"``font-family``\")\n\n:``font_size``: font size to use in the badge (CSS \"``font-size``\")\n\n:``label``: the text in label part of the badge\n\n:``label_background``:\n background color for the label (left) part (CSS \"``background``\")\n\n:``label_text_color``:\n text color for the label (left) part (CSS \"``color``\")\n\n:``label_text_shadow``:\n configuration for the text shadow (CSS \"``text-shadow``\")\n\n:``link_decoration``:\n decoration for the link (CSS \"``text-decoration``\")\n\n:``padding``:\n amount of space between the border and the text (CSS \"``padding``\")\n\n:``thresholds``:\n dict with *label*-specific configuration options, so that multiple labels\n can be handled by the same class instance. See `Thresholds`_ below\n\n:``url``: makes the badge link to the given URL\n\n:``value``: the text in the value part of the badge\n\n:``value_background``:\n background color for the value part (CSS \"``background``\"). This is also\n the final fallback if the value is neither found in ``thresholds`` nor in\n ``value_backgrounds``\n\n:``value_backgrounds``:\n dict with *value* to ``value_background`` mappings. See `Thresholds`_\n below\n\n:``value_text_color``: text color for the value part (CSS \"``color``\")\n\n:``value_text_shadow``:\n configuration for the text shadow (CSS \"``text-shadow``\")\n\nThresholds\n''''''''''\n\nThe ``thresholds`` argument is a dict with label as key and a configuration\ndict as value. The dict supports the following keys:\n\n:``order``:\n May be: ``auto``, ``float``, ``int``, ``str``, or ``strict``, with ``auto``\n being the default if ``order`` does not exist. ``float``, ``int`` and\n ``str`` forces level of that type (see below). ``auto`` uses ordering of\n type *float* or *int* if all *values* in ``colors`` are numbers type, with\n ``float`` taking precedence. If ``auto`` is set and at least one value is a\n string, or if ``strict`` is set, then an exact match is used for\n determining color, ie. no ordering\n\n:``colors``:\n dict with *value* to *color* mapping\n\n:``above``:\n Value is a color. if an ordering is requested, and the given value is above\n the highest value (key) in ``colors``, then this color is used\n\n:``shade``:\n Whether to shade the color depending on distance between the thresholds.\n Each R, G, and B color is calculated based on the fraction of the distance\n of the value between the thresholds\n\nLevels are handled by sorting the keys in the ``colors`` dict and comparing\nthe incoming value to each of the keys, starting with the key with the lowest\nvalue, until the value is lower than or equal to the key::\n\n for k in sorted(thresholds['colors'].keys, key=):\n if value <= k:\n return thresholds['colors'][k]\n return thresholds['above']\n\nExamples\n--------\n\nOne instance can be configure to product different label types::\n\n build_badge = Badge(thresholds={\n 'build': {\n 'colors': {'SUCCESS': '#0f0',\n 'FAILURE': '#f00',\n 'UNSTABLE': '#ff0',\n 'ABORTED': '#f80', }},\n 'KPI': {\n 'order': 'str',\n 'colors': {'A': '#0f4',\n 'B': '#f04',\n 'C': '#f84',\n 'D': '#ff4', }},\n 'passrate': {\n 'colors': {0.3: '#f00',\n 0.6: '#c40',\n 0.8: '#4c0', },\n 'above': '#0f0', }})\n\n print(build_badge.to_html('build', 'UNSTABLE'))\n\n # Using a non-existing value will use the value_background color\n print(build_badge.to_html('build', 'SKIP'))\n print(build_badge.to_html('build', 'HOP', value_background='#ccc'))\n print(build_badge.to_html('passrate', 0.5))\n\n.. image:: docs/example-build.png\n\nIf the color is not found in ``thresholds`` then the value will be looked\nup in the ``value_backgrounds`` dict as a fallback::\n\n build_badge = Badge(thresholds={\n 'build': {\n 'colors': {'SUCCESS': '#0f0',\n 'FAILURE': '#f00',\n 'UNSTABLE': '#ff0',\n 'ABORTED': '#f80', }},\n 'value_backgrounds': {'SUCCESS': '#0f4',\n 'FAILURE': '#f04',\n 'UNSTABLE': '#f84',\n 'ABORTED': '#ff4'}})\n print(build_badge.to_html('test', 'ABORTED'))\n\n.. image:: docs/example-fallback.png\n\nShading does not produce color steps, but a shade between the colors in the\nthreshold. Shading only works for \"float\" and \"int\" types::\n\n build_badge = Badge(thresholds={\n 'speed': {\n 'shade': True,\n 'colors': {0: '#0f0',\n 120: '#f00'}, # speed limit\n 'above': '#f08'}} # too fast!\n )\n print(build_badge.to_html('speed', 97))\n\n # Here is the rainbow\n build_badge = Badge(thresholds={\n 'rainbow': {\n 'shade': True,\n 'colors': {0.0: '#ff0000',\n 1.0: '#ffff00',\n 2.0: '#00ff00',\n 3.0: '#00ffff',\n 4.0: '#0000ff',\n 5.0: '#8000ff'}}})\n\n for c in range(0, 11):\n print(build_badge.to_html('rainbow', c / 2.0))\n\n.. image:: docs/example-shading.png\n\n\n", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/Gustra/abadge", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "abadge", "package_url": "https://pypi.org/project/abadge/", "platform": "", "project_url": "https://pypi.org/project/abadge/", "project_urls": { "Homepage": "https://github.com/Gustra/abadge" }, "release_url": "https://pypi.org/project/abadge/2.1.1/", "requires_dist": null, "requires_python": "", "summary": "Generate badges/shields with pure HTML/CSS.", "version": "2.1.1" }, "last_serial": 4295018, "releases": { "0.2.1": [ { "comment_text": "", "digests": { "md5": "c2d92097cf9fb725d4c308fe8184d36e", "sha256": "f026dfe3ee64efd6c652d3fff87c28f07ce812b9c103af4cd79a9faae73a3047" }, "downloads": -1, "filename": "abadge-0.2.1-py3-none-any.whl", "has_sig": false, "md5_digest": "c2d92097cf9fb725d4c308fe8184d36e", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 3904, "upload_time": "2018-09-11T02:43:49", "url": "https://files.pythonhosted.org/packages/a0/10/81f55fa81f2870e77695be2cee402ee700b55d4cc3ae1365c99b233d6787/abadge-0.2.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "f98601d82032c50fdb8aaa412b47e4b7", "sha256": "fac0086a70041ecf33edf7ec7250081d06bd7ef12a1406680f7b4c55e26b692f" }, "downloads": -1, "filename": "abadge-0.2.1.tar.gz", "has_sig": false, "md5_digest": "f98601d82032c50fdb8aaa412b47e4b7", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3585, "upload_time": "2018-09-11T02:43:50", "url": "https://files.pythonhosted.org/packages/c8/e9/e5a15a22dae64cc81357c151d3d85ccfdc69ce10c0b349cde64f55b2989d/abadge-0.2.1.tar.gz" } ], "0.3.0": [ { "comment_text": "", "digests": { "md5": "da72851e64da4b441fe64fe47a08ee7c", "sha256": "d3210bc801f34231866ea0b203873c85b980a6edb67c8ffd8f8256fed46d7907" }, "downloads": -1, "filename": "abadge-0.3.0-py3-none-any.whl", "has_sig": false, "md5_digest": "da72851e64da4b441fe64fe47a08ee7c", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 4058, "upload_time": "2018-09-12T04:22:52", "url": "https://files.pythonhosted.org/packages/bd/56/30b7c561cc17b91216c22ca88bc3b7fafcef3db92082617a7d7b9f40f205/abadge-0.3.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "3538c3046ba54bfa50de7482b9255bcc", "sha256": "0afc5631385a4ec0ebae7ce4c322f9ba034d8e32eed2d6aab5030713f855bd7b" }, "downloads": -1, "filename": "abadge-0.3.0.tar.gz", "has_sig": false, "md5_digest": "3538c3046ba54bfa50de7482b9255bcc", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3797, "upload_time": "2018-09-12T04:22:53", "url": "https://files.pythonhosted.org/packages/3e/4f/87057a9eaf5465b40a227b15589f0388c62f0871bfcc040a8dbfd98754f2/abadge-0.3.0.tar.gz" } ], "1.0.0": [ { "comment_text": "", "digests": { "md5": "b11713ceb2f8cc024d708bf41f0a84cb", "sha256": "ebe4ae24c0b892dbc0b9ae9815c78f642e625b482aa8f10ff9117e5c182307eb" }, "downloads": -1, "filename": "abadge-1.0.0-py3-none-any.whl", "has_sig": false, "md5_digest": "b11713ceb2f8cc024d708bf41f0a84cb", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 4441, "upload_time": "2018-09-19T04:11:04", "url": "https://files.pythonhosted.org/packages/e6/e1/e56d48c9ba2e9cb6942c19d373613a46dd6c35f22240c221adf564f41da1/abadge-1.0.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "49cf4e543e09e96970c37a1329ec34e0", "sha256": "ba0081aea465e6472878f80b4f4217cbc5214ea059c6095b1beef1d5f63022f3" }, "downloads": -1, "filename": "abadge-1.0.0.tar.gz", "has_sig": false, "md5_digest": "49cf4e543e09e96970c37a1329ec34e0", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4288, "upload_time": "2018-09-19T04:11:06", "url": "https://files.pythonhosted.org/packages/fd/05/b6e6d7ad1cb8ecfbe15604499974959958900064c138373f5bb7d8e7b341/abadge-1.0.0.tar.gz" } ], "2.0.0": [ { "comment_text": "", "digests": { "md5": "2fa9fc142f5982608aa8f97e5404bad2", "sha256": "c237d502a3d5e5e42b99970e206e4a439e18a8076f61060e964ec344ad190c3b" }, "downloads": -1, "filename": "abadge-2.0.0-py3-none-any.whl", "has_sig": false, "md5_digest": "2fa9fc142f5982608aa8f97e5404bad2", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 5381, "upload_time": "2018-09-20T12:36:19", "url": "https://files.pythonhosted.org/packages/54/54/b81c71405b02084328fc0da3c046d095c4c76b4b8d12be280dcc831629f0/abadge-2.0.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "fa8c14c668dcd299ea4a975031d9c0c1", "sha256": "5172d58c3b641e66dc14c728b7830102822e3ee687b2ed121ea7a4adeff9d30c" }, "downloads": -1, "filename": "abadge-2.0.0.tar.gz", "has_sig": false, "md5_digest": "fa8c14c668dcd299ea4a975031d9c0c1", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5376, "upload_time": "2018-09-20T12:36:20", "url": "https://files.pythonhosted.org/packages/ff/92/d7d9ae33f5587171c0b59b868dda93fa3ad052d5dedd1eaabfa4c42f6412/abadge-2.0.0.tar.gz" } ], "2.1.0": [ { "comment_text": "", "digests": { "md5": "51acfecc2d2ecd2e8c9ff18a3dcf31fa", "sha256": "b19999165c14529fd0a4be7c13ea0d07e18cb3b12b996ffb73235f56a897d86a" }, "downloads": -1, "filename": "abadge-2.1.0-py3-none-any.whl", "has_sig": false, "md5_digest": "51acfecc2d2ecd2e8c9ff18a3dcf31fa", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 6219, "upload_time": "2018-09-21T05:14:44", "url": "https://files.pythonhosted.org/packages/65/3e/494a193c2af2e46b332483bb330d4f6fbf054719533e41569b33def965fb/abadge-2.1.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "42a630cce5ec19591dd72f1989a7e361", "sha256": "89bc7a0042a3006c6c2067f00a7a9a09a8a55b62093b09d639216fa72b46db5c" }, "downloads": -1, "filename": "abadge-2.1.0.tar.gz", "has_sig": false, "md5_digest": "42a630cce5ec19591dd72f1989a7e361", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6321, "upload_time": "2018-09-21T05:14:46", "url": "https://files.pythonhosted.org/packages/71/77/30f4e50e0706f0bc97be8e96e119a54ce30d11660d9bfb98f6b78f7563b6/abadge-2.1.0.tar.gz" } ], "2.1.1": [ { "comment_text": "", "digests": { "md5": "81d1d70c470f373ec8de838843fbf084", "sha256": "1482127adc3f8ab03c62fe46328489a2003bc9024f69693920d8933369c1e386" }, "downloads": -1, "filename": "abadge-2.1.1-py3-none-any.whl", "has_sig": false, "md5_digest": "81d1d70c470f373ec8de838843fbf084", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 6220, "upload_time": "2018-09-21T05:20:45", "url": "https://files.pythonhosted.org/packages/4b/35/6c5c206ff2f77c187c3a7d7dbbad7e6df3319a8b1778d441b7fefa0365d0/abadge-2.1.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "e39bf47af2a8c7780ff7d08216fca5cc", "sha256": "f271066641a4851a10a8f270b06b3c01b94faa0f9169713e14c286bff8376985" }, "downloads": -1, "filename": "abadge-2.1.1.tar.gz", "has_sig": false, "md5_digest": "e39bf47af2a8c7780ff7d08216fca5cc", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6326, "upload_time": "2018-09-21T05:20:46", "url": "https://files.pythonhosted.org/packages/b5/fa/dfab2c94864d0f7dda1c741f53192d5e1391665588aaa0515fed02c29c98/abadge-2.1.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "81d1d70c470f373ec8de838843fbf084", "sha256": "1482127adc3f8ab03c62fe46328489a2003bc9024f69693920d8933369c1e386" }, "downloads": -1, "filename": "abadge-2.1.1-py3-none-any.whl", "has_sig": false, "md5_digest": "81d1d70c470f373ec8de838843fbf084", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 6220, "upload_time": "2018-09-21T05:20:45", "url": "https://files.pythonhosted.org/packages/4b/35/6c5c206ff2f77c187c3a7d7dbbad7e6df3319a8b1778d441b7fefa0365d0/abadge-2.1.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "e39bf47af2a8c7780ff7d08216fca5cc", "sha256": "f271066641a4851a10a8f270b06b3c01b94faa0f9169713e14c286bff8376985" }, "downloads": -1, "filename": "abadge-2.1.1.tar.gz", "has_sig": false, "md5_digest": "e39bf47af2a8c7780ff7d08216fca5cc", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6326, "upload_time": "2018-09-21T05:20:46", "url": "https://files.pythonhosted.org/packages/b5/fa/dfab2c94864d0f7dda1c741f53192d5e1391665588aaa0515fed02c29c98/abadge-2.1.1.tar.gz" } ] }