def resolve_environment(name):
    if name is None:
        return None
    try:
        eid = int(name)
    except __HOLE__:
        try:
            env = dbsession.query(models.Environment).filter(models.Environment.name==name).one()
        except NoResultFound:
            return None
    else:
        try:
            env = dbsession.query(models.Environment).get(eid)
        except NoResultFound:
            return None
    return env
dataset/ETHPy150Open kdart/pycopia/storage/pycopia/db/webhelpers.py/resolve_environment