Skip to content

Instantly share code, notes, and snippets.

@ZenithClown
Last active July 15, 2022 08:50
Show Gist options
  • Save ZenithClown/fa7b04f14df848be79203e1bdad1a51d to your computer and use it in GitHub Desktop.
Save ZenithClown/fa7b04f14df848be79203e1bdad1a51d to your computer and use it in GitHub Desktop.
A Python Function to Generate Badge Link for Shields.IO

Badges Generator

Generate Profile/Repository badges using Shields.IO

Shields.IO provides great APIs for adding badges to your profile/repository. You can also use the GUI to generate simple icons/badges. This python file provides a function to generate ready-to-use links that can be added whereever required. Check the function defination for understanding different parameters or check the website for more information.

# -*- encoding: utf-8 -*-
__version__ = open("VERSION").read().strip() # get version from file
links = lambda message, label = "", logo = "", color = "", style = "flat" : f"https://img.shields.io/static/v1?label={label}&message={message}&color={color.replace('#', '')}&style={style}&logo={logo}"
if __name__ == "__main__":
get_user_input = lambda var : input(f"Enter `{var}`: ").strip()
# get required inputs from user
# save them to list and then call `links` function
inputs = []
for var in ["message", "logo", "color"]:
inputs.append(get_user_input(var))
print(links(message = inputs[0], logo = inputs[1], color = inputs[2]))
v0.0.1-alpha
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment