Example #1
0
def main():
    beers = Beer.all()["beers"]    
    beer = beers[randint(0,len(beers)-1)]

    while 1:
        print "Which beer is this? \"{}\"".format(beer["description"].encode('utf-8'))

        if raw_input('Your guess: ') == beer["name"]:
            print "Correct answer, well done!"
            return
        else:
            print "Wrong answer, correct answer is {}\n".format(beer["name"].encode('utf-8'))
            beer = beers[randint(0,len(beers)-1)]
Example #2
0
def main():
    beers = Beer.all()["beers"]
    beer = beers[randint(0, len(beers) - 1)]

    while 1:
        print "Which beer is this? \"{}\"".format(
            beer["description"].encode('utf-8'))

        if raw_input('Your guess: ') == beer["name"]:
            print "Correct answer, well done!"
            return
        else:
            print "Wrong answer, correct answer is {}\n".format(
                beer["name"].encode('utf-8'))
            beer = beers[randint(0, len(beers) - 1)]
Example #3
0
import solr
from pynt.pynt import Beer

solrConnection = solr.SolrConnection('http://localhost:8983/solr')

response = Beer.all()

total = response.get('total', 0)

print "Found %s beers" % total

beers = response.get('beers', [])

docs = [{
    "id": str(beer['id']),
    "name": beer['name'],
    "description": beer['description'],
    "brewery_id": str(beer['brewery']['id']),
    "brewery_name": beer['brewery']['name']
} for beer in beers]

solrConnection.add_many(docs)
solrConnection.commit()

print "Successfully imported documents"
Example #4
0
import solr
from pynt.pynt import Beer

solrConnection = solr.SolrConnection('http://localhost:8983/solr')

response = Beer.all()

total = response.get('total', 0)

print "Found %s beers" % total

beers = response.get('beers', [])

docs = [{"id":str(beer['id']),
         "name":beer['name'],
         "description":beer['description'],
         "brewery_id":str(beer['brewery']['id']),
         "brewery_name":beer['brewery']['name']
         } for beer in beers]

solrConnection.add_many(docs)
solrConnection.commit()

print "Successfully imported documents"
Example #5
0
File: example.py Project: h0ke/pynt
from pynt.pynt import Settings, Beer

# Setting options
Settings.host           = 'http://api.localhost:3000/v1/'
Settings.public_token   = 'YOUR_PUBLIC_TOKEN'
Settings.private_token  = 'YOUR_PRIVATE_TOKEN'


# Get all beers
print Beer.all()

'''
# Get the beer with id 2
print Beer.get(2)
'''

'''
# Create a new beer
beer_data = {
    "name"        : "Strawberry Harvest",
    "description" : "Strawberry Harvest Lager is a wheat beer ...",
    "abv"         : 4.2
}
print Beer.create(brewery_id = 1, beer = beer_data)
'''

'''
# Delete beer with id 5
print Beer.delete(5)
'''