You're Invited:Meet the Socket Team at RSAC and BSidesSF 2026, March 23–26.RSVP
Socket
Book a DemoSign in
Socket

abadge

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

abadge - pypi Package Compare versions

Comparing version
0.3.0
to
1.0.0
+33
-10
abadge.egg-info/PKG-INFO
Metadata-Version: 1.0
Name: abadge
Version: 0.3.0
Version: 1.0.0
Summary: Generate badges/shields with pure HTML/CSS.

@@ -90,4 +90,4 @@ Home-page: https://github.com/Gustra/abadge

:``thresholds``:
dict with *value* to ``value_background`` mappings. See `Thresholds`_
below
dict with *label* to *value* to ``value_background`` mappings. See
`Thresholds`_ below

@@ -99,4 +99,10 @@ :``url``: makes the badge link to the given URL

:``value_background``:
background color for the value part (CSS "``background``")
background color for the value part (CSS "``background``"). This is also
the final fallback if the value is neither found in ``thresholds`` nor in
``value_backgrounds``
:``value_backgrounds``:
dict with *value* to ``value_background`` mappings. See `Thresholds`_
below
:``value_text_color``: text color for the value part (CSS "``color``")

@@ -110,9 +116,13 @@

The ``thresholds`` argument is a dict with simple value to background color
mapping::
The ``thresholds`` argument is a dict with label to value to background
color mapping::
build_badge = Badge(thresholds={'SUCCESS': '#0f0',
'FAILURE': '#f00',
'UNSTABLE': '#ff0',
'ABORTED': '#f80',})
build_badge = Badge(thresholds={'build': {'SUCCESS': '#0f0',
'FAILURE': '#f00',
'UNSTABLE': '#ff0',
'ABORTED': '#f80',},
'KPI': {'A': '#0f4',
'B': '#f04',
'C': '#f84',
'D': '#ff4',},)
print(build_badge('build', job.get_status()))

@@ -123,3 +133,16 @@ # Using a non-existing value will use the value_background color

If the background is not found in ``thresholds`` then the value will be looked
up in the ``value_backgrounds`` dict as a fallback::
build_badge = Badge(thresholds={'build': {'SUCCESS': '#0f0',
'FAILURE': '#f00',
'UNSTABLE': '#ff0',
'ABORTED': '#f80',}}
value_backgrounds: {'SUCCESS': '#0f4',
'FAILURE': '#f04',
'UNSTABLE': '#f84',
'ABORTED': '#ff4',},)
print(build_badge('test', job.get_status()))
Platform: UNKNOWN
+35
-16

@@ -7,2 +7,3 @@ """

"""
from copy import deepcopy

@@ -50,3 +51,3 @@ label_css = '''

"""
config = {
default_config = {
'border_radius': '4px',

@@ -60,2 +61,3 @@ 'font_family': 'DejaVu Sans, Verdana, sans',

'link_decoration': 'none',
'link_target': '',
'padding': '4px 8px 4px 8px',

@@ -65,3 +67,4 @@ 'thresholds': {},

'value': '',
'value_background': '#444',
'value_background': '#888',
'value_backgrounds': {},
'value_text_color': 'white',

@@ -90,3 +93,3 @@ 'value_text_shadow': '1px 1px black',

href_template = '<a href="{url}"' \
href_template = '<a href="{url}"{link_target}' \
' style="text-decoration:{link_decoration};">'

@@ -117,2 +120,3 @@

link_decoration -- the CSS "text-decoration" setting for the link
link_target -- set the "target" attribute for the link
padding -- amount of space between the border and the badge

@@ -125,5 +129,8 @@ (CSS "padding")

(CSS "background")
value_backgrounds -- dict with value to color mapping for the value
part (CSS "background"). Overrides ``value_background``
value_text_color -- text color for the value part (CSS "text-color")
value_text_shadow -- text shadow for the value part (CSS "text-shadow")
"""
self.config = deepcopy(self.default_config)
self.config.update(self._parse_args(args, kwargs))

@@ -146,3 +153,3 @@ if len(args) > 0:

for k in kwargs.keys():
if k not in cls.config:
if k not in cls.default_config:
raise TypeError('unknown option {}'.format(k))

@@ -159,5 +166,12 @@ return kwargs

"""
if 'thresholds' in config:
return config['thresholds'].get(config['value'],
config['value_background'])
try:
return config['thresholds'][config['label']][config['value']]
except KeyError:
pass
try:
return config['value_backgrounds'][config['value']]
except KeyError:
pass
return config['value_background']

@@ -170,13 +184,18 @@

"""
config = self.config.copy()
config.update(self._parse_args(args, kwargs))
conf = deepcopy(self.config)
conf.update(self._parse_args(args, kwargs))
if len(args) > 0:
config['label'] = args[0]
conf['label'] = args[0]
if len(args) > 1:
config['value'] = args[1]
config['value_background'] = self._get_value_background(config)
if config['url']:
return self.href_template.format(**config) \
+ self.template.format(**config) + '</a>'
return self.template.format(**config)
conf['value'] = args[1]
conf['value_background'] = self._get_value_background(conf)
if conf['url']:
if conf['link_target']:
target = conf['link_target']
conf['link_target'] = ' target="{}"'.format(target)
if target == '_blank':
conf['link_target'] += ' rel="noopener noreferer"'
return (self.href_template.format(**conf)
+ self.template.format(**conf) + '</a>')
return self.template.format(**conf)

@@ -183,0 +202,0 @@ @classmethod

+33
-10
Metadata-Version: 1.0
Name: abadge
Version: 0.3.0
Version: 1.0.0
Summary: Generate badges/shields with pure HTML/CSS.

@@ -90,4 +90,4 @@ Home-page: https://github.com/Gustra/abadge

:``thresholds``:
dict with *value* to ``value_background`` mappings. See `Thresholds`_
below
dict with *label* to *value* to ``value_background`` mappings. See
`Thresholds`_ below

@@ -99,4 +99,10 @@ :``url``: makes the badge link to the given URL

:``value_background``:
background color for the value part (CSS "``background``")
background color for the value part (CSS "``background``"). This is also
the final fallback if the value is neither found in ``thresholds`` nor in
``value_backgrounds``
:``value_backgrounds``:
dict with *value* to ``value_background`` mappings. See `Thresholds`_
below
:``value_text_color``: text color for the value part (CSS "``color``")

@@ -110,9 +116,13 @@

The ``thresholds`` argument is a dict with simple value to background color
mapping::
The ``thresholds`` argument is a dict with label to value to background
color mapping::
build_badge = Badge(thresholds={'SUCCESS': '#0f0',
'FAILURE': '#f00',
'UNSTABLE': '#ff0',
'ABORTED': '#f80',})
build_badge = Badge(thresholds={'build': {'SUCCESS': '#0f0',
'FAILURE': '#f00',
'UNSTABLE': '#ff0',
'ABORTED': '#f80',},
'KPI': {'A': '#0f4',
'B': '#f04',
'C': '#f84',
'D': '#ff4',},)
print(build_badge('build', job.get_status()))

@@ -123,3 +133,16 @@ # Using a non-existing value will use the value_background color

If the background is not found in ``thresholds`` then the value will be looked
up in the ``value_backgrounds`` dict as a fallback::
build_badge = Badge(thresholds={'build': {'SUCCESS': '#0f0',
'FAILURE': '#f00',
'UNSTABLE': '#ff0',
'ABORTED': '#f80',}}
value_backgrounds: {'SUCCESS': '#0f4',
'FAILURE': '#f04',
'UNSTABLE': '#f84',
'ABORTED': '#ff4',},)
print(build_badge('test', job.get_status()))
Platform: UNKNOWN

@@ -82,4 +82,4 @@ abadge

:``thresholds``:
dict with *value* to ``value_background`` mappings. See `Thresholds`_
below
dict with *label* to *value* to ``value_background`` mappings. See
`Thresholds`_ below

@@ -91,4 +91,10 @@ :``url``: makes the badge link to the given URL

:``value_background``:
background color for the value part (CSS "``background``")
background color for the value part (CSS "``background``"). This is also
the final fallback if the value is neither found in ``thresholds`` nor in
``value_backgrounds``
:``value_backgrounds``:
dict with *value* to ``value_background`` mappings. See `Thresholds`_
below
:``value_text_color``: text color for the value part (CSS "``color``")

@@ -102,9 +108,13 @@

The ``thresholds`` argument is a dict with simple value to background color
mapping::
The ``thresholds`` argument is a dict with label to value to background
color mapping::
build_badge = Badge(thresholds={'SUCCESS': '#0f0',
'FAILURE': '#f00',
'UNSTABLE': '#ff0',
'ABORTED': '#f80',})
build_badge = Badge(thresholds={'build': {'SUCCESS': '#0f0',
'FAILURE': '#f00',
'UNSTABLE': '#ff0',
'ABORTED': '#f80',},
'KPI': {'A': '#0f4',
'B': '#f04',
'C': '#f84',
'D': '#ff4',},)
print(build_badge('build', job.get_status()))

@@ -115,1 +125,14 @@ # Using a non-existing value will use the value_background color

If the background is not found in ``thresholds`` then the value will be looked
up in the ``value_backgrounds`` dict as a fallback::
build_badge = Badge(thresholds={'build': {'SUCCESS': '#0f0',
'FAILURE': '#f00',
'UNSTABLE': '#ff0',
'ABORTED': '#f80',}}
value_backgrounds: {'SUCCESS': '#0f4',
'FAILURE': '#f04',
'UNSTABLE': '#f84',
'ABORTED': '#ff4',},)
print(build_badge('test', job.get_status()))