Package: pybadges-trend
pybadges-trendpybadges-trend is a fork of thepybadgeslibrary by Brian Quinlan.
Changes from this fork have beenput forward to be merged into the upstream
library. However, since there
wasn't a response from Brian, and I wanted to use this version, I'm releasing
it separately on PyPI. If these changes are merged upstream, at some point, I
shall archive this fork.pybadges is a Python library and command line tool that allows you to create
Github-style badges as SVG images. For example:In addition to what pybadges allows, pybadges-trend also supports embedding an
optional image (110 x 14) in between the left and right text. Here's an example:The aesthetics of the generated badges matches the visual design found in thisspecification.The implementation of the library was heavily influenced byShields.ioand the JavaScriptgh-badgeslibrary.Getting StartedInstallingpybadges can be installed usingpip:pipinstallpybadgesTo test that installation was successful, try:python-mpybadges--left-text=build--right-text=failure--right-color='#c00'--browserYou will see a badge like this in your browser:Usagepybadges can be used both from the command line and as a Python library.The command line interface is a great way to experiment with the API before
writing Python code.You could also look at theexample server.Command line usageComplete documentation of pybadges command arguments can be found using the--helpflag:python-mpybadges--helpBut the following usage demonstrates every interesting option:python-mpybadges\--left-text=complete\--right-text=example\--left-color=green\--right-color='#fb3'\--left-link=http://www.complete.com/\--right-link=http://www.example.com\--logo='data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAIAAAACCAIAAAD91JpzAAAAD0lEQVQI12P4zwAD/xkYAA/+Af8iHnLUAAAAAElFTkSuQmCC'\--embed-logo\--whole-title="Badge Title"\--left-title="Left Title"\--right-title="Right Title"\--browserA note about--logoand--embed-logoNote that the--logooption can include a regular URL:python-mpybadges\--left-text="python"\--right-text="3.2, 3.3, 3.4, 3.5, 3.6"\--whole-link="https://www.python.org/"\--browser\--logo='https://dev.w3.org/SVG/tools/svgweb/samples/svg-files/python.svg'If the--logooption is set, the--embed-logooption can also be set.
The--embed-logooption causes the content of the URL provided in--logoto be embedded in the badge rather than be referenced through a link.The advantage of using this option is an extra HTTP request will not be required
to render the badge and that some browsers will not load image references at all.You can see the difference in your browser:A note about--(whole|left|right)-titleThetitleelement is usually displayed as apop-up by browsersbut is currentlyfiltered by Github.Library usagepybadges is primarily meant to be used as a Python library.frompybadgesimportbadges=badge(left_text='coverage',right_text='23%',right_color='red')# s is a string that contains the badge data as an svg image.print(s[:40])# => <svg height="20" width="191.0" xmlns="htThe keyword arguments tobadge()are identical to the command flags names
described above except with keyword arguments using underscore instead of
hyphen/minus (e.g.--left-text=>left_text=)Server usagepybadges can be used to serve badge images on the web.server-examplecontains an example of serving badge images from aFlask server.Caveatspybadges uses a pre-calculated table of text widths andkerningdistances
(for western glyphs) to determine the size of the badge.
So Eastern European languages may be rendered less well than
Western European ones:and glyphs not present in Deja Vu Sans (the default font) may
be rendered very poorly:pybadges does not have any explicit support for languages that
are written right-to-left (e.g. Arabic, Hebrew) and the displayed
text direction may be incorrect:Developmentgitclonehttps://github.com/google/pybadges.gitcdpybadges
python-mvirtualenvvenvsourcevenv/bin/activate# Installs in edit mode and with development dependencies.pipinstall-e.[dev]noxIf you'd like to contribute your changes back to pybadges, please read thecontributor guide.VersioningWe useSemVerfor versioning.LicenseThis project is licensed under the Apache License - see theLICENSEfile for detailsThis is not an officially supported Google product.