def return_finaid(income, other): eligible = False if(income): if(isinstance(income, str)): income = income.replace("$", "") income = income.replace(",", "") income = int(income) if(income < 24000): eligible = True if(other): if(("SNAP" in other) or ("reduced-lunch" in other) or ("FPL" in other)): eligible = True colleges = [{}] if(eligible): client = Client('e6e56d2e-b91e-4dc2-aac7-ec6028c378e2') pages = client.list('schools') for page in pages: results = page["results"] for college in results: display = college["value"] colleges.append({ "title":display["title"], "amount":"full"}) return colleges
from porc import Client client = Client('f61515c7-8df9-4003-ab45-2f3e259610ff') import time if __name__ =='__main__': parties = client.list('parties').all() for i in range(0, len(parties)): print time.ctime(int(parties[i]['reftime']/ 1000))
sys.stdout.write("Connecting to " + mongoURI + " with user: "******"\n") client = MongoClient(mongoURI) # Specify the database to use db = client.somedatabase # Authenticate with that database db.authenticate(mongoUser, mongoPass) # Specify the collections to migrate Collections = ['Collection1', 'Collection2', 'Collection3'] for collection in Collections: if DEBUG == 1: sys.stdout.write("Syncing collection: " + collection + "\n") data = oClient.list(collection).all() for record in data: jsonQuery = "{\"_id\":\"" + record['value']['id'] + "\"}" mongoQuery = json.loads(jsonQuery) update = record['value'] update['_id'] = record['value']['id'] update['version'] = bson.int64.Int64(1) if update['created'] is not None: update['created'] = DT.datetime.utcfromtimestamp( update['created'] / 1e3) result = db[collection].update(mongoQuery, update, upsert=True) if DEBUG == 1: if result['updatedExisting']: sys.stdout.write("Updated record for " + record['value']['id'] + "\n") if not result['updatedExisting']:
from porc import Client client = Client('f61515c7-8df9-4003-ab45-2f3e259610ff') import time if __name__ == '__main__': parties = client.list('parties').all() for i in range(0, len(parties)): print time.ctime(int(parties[i]['reftime'] / 1000))