Ejemplo n.º 1
0
def get(id_name):
    """
        Gets a game by the given filter (either name or ID. Name preferred.) 
    """
    
    game = Game.get_by(name=str(id_name).decode("utf-8"))
    if type(game) != Game:
        game = Game.get_by(id=id_name)
        if type(game) != Game:
            raise gjms.core.exceptions.NonExistentGame("Game does not exist.")
        else:
            return game
    else:
        return game
Ejemplo n.º 2
0
def get(id_name):
    """
        Gets a game by the given filter (either name or ID. Name preferred.) 
    """

    game = Game.get_by(name=str(id_name).decode("utf-8"))
    if type(game) != Game:
        game = Game.get_by(id=id_name)
        if type(game) != Game:
            raise gjms.core.exceptions.NonExistentGame("Game does not exist.")
        else:
            return game
    else:
        return game
Ejemplo n.º 3
0
def by_slug(slug):
    """
        Get a game by its slug.
    """

    game = Game.get_by(slug=slug)
    if type(game) != Game:
        raise gjms.core.exceptions.NonExistentGame("Game with this slug does not exist.")
    else:
        return game
Ejemplo n.º 4
0
def add(name, description, image):
    """ 

        Preferred way to add a game. 

        Fixes up the image link, if http:// is missing, so you don't 
        accidentally link internally.

    """

    if not "http://" in image:
        image_fixed = "http://" + image
    else:
        image_fixed = image

    if gjms.util.url.validate(image_fixed):
        game = Game(name=name, description=description, image=image_fixed)
        return game
    else:
        raise gjms.core.exceptions.InvalidURL("URL not valid.")