common/utils.py
def color_lookup(arg, colors):
    """Find a color based on a string."""
    # random color
    if arg == "":
        return random.choice(colors)

    # Index lookup
    if arg.isdigit():
        try:
            return colors[int(arg)-1]
        except IndexError:
            pass

    # Name lookup
    for color in colors:
        if color["name"].lower() == arg.lower():
            return color
Find a color based on a string.
Find a color based on a string.
Find a color based on a string .
def color_lookup(arg, colors):
    if arg == "":
        return random.choice(colors)
    if arg.isdigit():
        try:
            return colors[int(arg)-1]
        except IndexError:
            pass
    for color in colors:
        if color["name"].lower() == arg.lower():
            return color
def color_lookup ( arg , colors ) : if arg == "" : return random . choice ( colors ) if arg . isdigit ( ) : try : return colors [ int ( arg ) - 1 ] except IndexError : pass for color in colors : if color [ "name" ] . lower ( ) == arg . lower ( ) : return color
Find a color based on a string.
Find a color based on a string .
"""Find a color based on a string.""" # random color # Index lookup # Name lookup
arg
colors