jongracecox / anybadge

A Python project for generating badges for your projects, with a focus on simplicity and flexibility.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Creating multiple badges in a single Python session results in incorrect badge length

jongracecox opened this issue · comments

from anybadge import Badge, version

badges = [
  Badge('version', version),
  Badge('pylint', 1.23, thresholds={
    2:'red', 4: 'orange', 8: 'yellow', 10: 'green'}),
  Badge('awesomeness', '100%'),
  Badge('pylint', 9, thresholds={
    2:'red', 4: 'orange', 8: 'yellow', 10: 'green'})
]

from flask import Flask

app = Flask(__name__, static_folder='.')

@app.route('/')
def root():
    return ' <br> '.join([b.badge_svg_text for b in badges])
    
app.run(host='0.0.0.0', port='3000')

image

I have just re-verified this in a repl:

import anybadge
from flask import Flask

badges = [
  anybadge.Badge('something', value='100',
    value_suffix='%', num_padding_chars=0),
  anybadge.Badge('anybadge', value=anybadge.version),
  anybadge.Badge('coverage', value='1234567890'),
]

app = Flask(__name__, static_folder='.')

@app.route('/')
def root():
    return '<br>'.join(['<pre>' + repr(b) + '</pre>' + b.badge_svg_text for b in badges])

app.run(host='0.0.0.0', port='3000')

image

Release 1.4.0 fixes this issue. Here is the repl rerun with the new version:

image