bin/badge-create.py
def create(image_src_dir, badge_dst_dir, kind, username, email):
    """Create JSON and PNG for a new badge."""

    # Paths
    image_src_path, image_dst_path, json_dst_path = \
        make_paths(image_src_dir, badge_dst_dir, kind, username)

    # When is the badge being created?
    when = datetime.date.today().isoformat()

    # Hide the email address
    hashedemail = hash_email_address(email, badge.SALT)

    # Consistent slug combining kind and username.
    slug = "{0}/{1}".format(kind, username)

    # Cache a few values.
    name = kind
    description = badge.BADGE_DESCRIPTIONS[kind][1]
    criteria = "/badges/index.html#{0}.html".format(kind)
    assertion_url = "/badges/{0}.json".format(slug)
    image_url = "/badges/{0}.png".format(slug)

    new_badge = {
        "uid":hashedemail,
        "issuedOn":when,
        "image":badge.set_image_url(name),
        "recipient":{
            "identity":hashedemail,
            "type":"email",
            "hashed":True,
            "salt":badge.SALT},
        "badge":badge.set_badge_url(name),
        "verify":{
            "type":"hosted",
            "url":badge.set_verify_url(name, username)}}

    # Create and save the JSON assertion.
    with open(json_dst_path, "w") as writer:
        json.dump(new_badge, writer, indent=True, sort_keys=True)

    badgebakery.bake_badge("img/badges/{0}.png".format(kind),
            "{0}.png".format(username),
            slug)
Create JSON and PNG for a new badge.
Create JSON and PNG for a new badge.
Create JSON and PNG for a new badge .
def create(image_src_dir, badge_dst_dir, kind, username, email):
    image_src_path, image_dst_path, json_dst_path = \
        make_paths(image_src_dir, badge_dst_dir, kind, username)
    when = datetime.date.today().isoformat()
    hashedemail = hash_email_address(email, badge.SALT)
    slug = "{0}/{1}".format(kind, username)
    name = kind
    description = badge.BADGE_DESCRIPTIONS[kind][1]
    criteria = "/badges/index.html#{0}.html".format(kind)
    assertion_url = "/badges/{0}.json".format(slug)
    image_url = "/badges/{0}.png".format(slug)
    new_badge = {
        "uid":hashedemail,
        "issuedOn":when,
        "image":badge.set_image_url(name),
        "recipient":{
            "identity":hashedemail,
            "type":"email",
            "hashed":True,
            "salt":badge.SALT},
        "badge":badge.set_badge_url(name),
        "verify":{
            "type":"hosted",
            "url":badge.set_verify_url(name, username)}}
    with open(json_dst_path, "w") as writer:
        json.dump(new_badge, writer, indent=True, sort_keys=True)
    badgebakery.bake_badge("img/badges/{0}.png".format(kind),
            "{0}.png".format(username),
            slug)
def create ( image_src_dir , badge_dst_dir , kind , username , email ) : image_src_path , image_dst_path , json_dst_path = make_paths ( image_src_dir , badge_dst_dir , kind , username ) when = datetime . date . today ( ) . isoformat ( ) hashedemail = hash_email_address ( email , badge . SALT ) slug = "{0}/{1}" . format ( kind , username ) name = kind description = badge . BADGE_DESCRIPTIONS [ kind ] [ 1 ] criteria = "/badges/index.html#{0}.html" . format ( kind ) assertion_url = "/badges/{0}.json" . format ( slug ) image_url = "/badges/{0}.png" . format ( slug ) new_badge = { "uid" : hashedemail , "issuedOn" : when , "image" : badge . set_image_url ( name ) , "recipient" : { "identity" : hashedemail , "type" : "email" , "hashed" : True , "salt" : badge . SALT } , "badge" : badge . set_badge_url ( name ) , "verify" : { "type" : "hosted" , "url" : badge . set_verify_url ( name , username ) } } with open ( json_dst_path , "w" ) as writer : json . dump ( new_badge , writer , indent = True , sort_keys = True ) badgebakery . bake_badge ( "img/badges/{0}.png" . format ( kind ) , "{0}.png" . format ( username ) , slug )
Create JSON and PNG for a new badge.
Create JSON and PNG for a new badge .
"""Create JSON and PNG for a new badge.""" # Paths # When is the badge being created? # Hide the email address # Consistent slug combining kind and username. # Cache a few values. # Create and save the JSON assertion.
image_src_dir
badge_dst_dir
kind
username
email