def get_collegeslycees(self): c = self.cached_request(COLLEGESLYCEES_URL, 'collegeslycess.json') for row in c: row = row['fields'] uai = row['identifiant_de_l_etablissement'] if not row.get('nom_etablissement'): self.uai_to_delete.add(uai) continue if any(row.get(t, False) for t in ('ecole_maternelle', 'ecole_primaire')): self.uai_to_delete.add(uai) continue if any(t in row['type_etablissement'] for t in ('orientation', 'primaire', 'maternelle')): self.uai_to_delete.add(uai) continue address = ('adresse_%d' % i for i in (1, 2)) address = ' '.join(row[col] for col in address if col in row).strip() school = School(uai=uai, name=row['nom_etablissement'] or '', address=address, postal_code=row['code_postal'] or '', city=row['nom_commune'] or '', country='France', type=row['type_etablissement'] or '', imported=True, approved=True) if 'position' in row: school.lat = row['position'][0] school.lng = row['position'][1] yield school
def cb(count,ds): school = None try: school = School.objects.get(gsid=ds["universal-id"]) except: school = School() # print "called for num:" + str(count) + "val: " + str(ds) school.name = ds["name"] school.gsid = ds["universal-id"] school.city = ds["city"] if len(ds["zip"]) > 6: ds["zip"] = ds["zip"][:6] school.zip = ds["zip"] school.state = ds["state"] school.lat = ds["lat"] school.lon = ds["lon"] school.gsurl = ds["url"] if len(ds["street"]) > 50: ds["street"] = ds["street"][:49] school.street = ds["street"] if len(ds["level"]) > 20: ds["level"] = ds["level"][:19] school.level = ds["level"] if len(ds["phone"]) > 20: ds["phone"] = ds["phone"][:19] school.phone = ds["phone"] if len(ds["subtype"]) > 50: ds["subtype"] = 'special' school.type = ds["subtype"] if len(ds["district-name"]) > 50: ds["district-name"] = ds["district-name"][:49] school.district_name = ds["district-name"] # try: print school.gsurl school.save()
def cb(count, ds): school = None try: school = School.objects.get(gsid=ds["universal-id"]) except: school = School() # print "called for num:" + str(count) + "val: " + str(ds) school.name = ds["name"] school.gsid = ds["universal-id"] school.city = ds["city"] if len(ds["zip"]) > 6: ds["zip"] = ds["zip"][:6] school.zip = ds["zip"] school.state = ds["state"] school.lat = ds["lat"] school.lon = ds["lon"] school.gsurl = ds["url"] if len(ds["street"]) > 50: ds["street"] = ds["street"][:49] school.street = ds["street"] if len(ds["level"]) > 20: ds["level"] = ds["level"][:19] school.level = ds["level"] if len(ds["phone"]) > 20: ds["phone"] = ds["phone"][:19] school.phone = ds["phone"] if len(ds["subtype"]) > 50: ds["subtype"] = 'special' school.type = ds["subtype"] if len(ds["district-name"]) > 50: ds["district-name"] = ds["district-name"][:49] school.district_name = ds["district-name"] # try: print school.gsurl school.save()
def cb(count,ds): school = School() school.name = ds["name"] school.gsid = ds["universal-id"] school.city = ds["city"] if len(ds["zip"]) > 6: ds["zip"] = ds["zip"][:6] school.zip = ds["zip"] school.state = ds["state"] school.lat = ds["lat"] school.lon = ds["lon"] if len(ds["subtype"]) > 50: ds["subtype"] = 'special' school.type = ds["subtype"] sql = 'insert into schools_school values ("'+ds["universal-id"]+'","'+ ds["name"] + '","' + ds["subtype"] + '","' + ds["city"] + '","' + ds["state"] + '","' + ds["zip"] + '","' + ds["lat"] + '","' + ds["lon"] + '",0);' print sql
def get_superieur(self): c = self.cached_request(SUPERIEUR_URL, 'superieur.json') for row in c: uai = row['code_uai'] if not row['nom']: self.uai_to_delete.add(uai) continue school = School(uai=uai, name=row['nom'], acronym=row['sigle'] or '', academy=row['academie'] or '', address=row['adresse'] or '', postal_code=row['cp'] or '', city=row['commune'] or '', country='France', type=row["type_detablissement"] or '', imported=True, approved=True) try: school.lat = row['latitude_y'] school.lng = row['longitude_x'] except KeyError: pass yield school
def cb(count, ds): school = School() school.name = ds["name"] school.gsid = ds["universal-id"] school.city = ds["city"] if len(ds["zip"]) > 6: ds["zip"] = ds["zip"][:6] school.zip = ds["zip"] school.state = ds["state"] school.lat = ds["lat"] school.lon = ds["lon"] if len(ds["subtype"]) > 50: ds["subtype"] = 'special' school.type = ds["subtype"] sql = 'insert into schools_school values ("' + ds[ "universal-id"] + '","' + ds["name"] + '","' + ds[ "subtype"] + '","' + ds["city"] + '","' + ds["state"] + '","' + ds[ "zip"] + '","' + ds["lat"] + '","' + ds["lon"] + '",0);' print sql