def assign_int(data, provider, max_tries=3):

    tries = 0

    while tries < max_tries:

        try:

            if provider == 'brooklyn':

                rsp = ArtisinalInts.get_brooklyn_integer()
                id = rsp[0]

                data[u'artisinal:id'] = id
                data[u'artisinal:provider'] = u'http://www.brooklynintegers.com/'
                return id

            elif provider == 'mission':

                rsp = ArtisinalInts.get_mission_integer()
                id = rsp[0]

                data[u'artisinal:id'] = id
                data[u'artisinal:provider'] = u'http://www.missionintegers.com/'
                return id

            else:

                return None

        except Exception, e:
            pass
            
        tries += 1
def get_artisanal_int():

    i = random.randrange(0, 3)

    while True:

        try:
            if i == 0:
                int, ignore = ArtisinalInts.get_mission_integer()
                return int, "http://www.missionintegers.com/"
            elif i == 1:
                int, ignore = ArtisinalInts.get_brooklyn_integer()        
                return int, "http://www.brooklynintegers.com/"
            else:
                int, = ArtisinalInts.get_london_integer()
                return int, "http://www.londonintegers.com/"
        except Exception, e:
            print e
Ejemplo n.º 3
0
def get_artisanal_int():

    i = random.randrange(0, 3)

    while True:

        try:
            if i == 0:
                int, ignore = ArtisinalInts.get_mission_integer()
                return int, "http://www.missionintegers.com/"
            elif i == 1:
                int, ignore = ArtisinalInts.get_brooklyn_integer()
                return int, "http://www.brooklynintegers.com/"
            else:
                int, = ArtisinalInts.get_london_integer()
                return int, "http://www.londonintegers.com/"
        except Exception, e:
            print e
Ejemplo n.º 4
0
import sys
import csv
import json
import ArtisinalInts

input = sys.argv[1]
output = sys.argv[2]

fh = open(input, 'U')
reader = csv.DictReader(fh)

features = []

for row in reader:

    id, ignore = ArtisinalInts.get_brooklyn_integer()

    # sigh...

    pt = row['Shape'].strip()
    pt = pt.lstrip("(")
    pt = pt.rstrip(")")
    lat, lon = map(float, pt.split(","))

    geom = {'type': 'Point', 'coordinates': [lon, lat]}

    props = {
        'name': row['NAME'],
        'line': row['LINE'],
        'nyc:id': row['OBJECTID'],
        'artisanal:id': id,
Ejemplo n.º 5
0
import sys
import csv
import json
import ArtisinalInts

input = sys.argv[1]
output = sys.argv[2]

fh = open(input, 'U')
reader = csv.DictReader(fh)

features = []

for row in reader:

    id, ignore = ArtisinalInts.get_brooklyn_integer()

    # sigh...

    pt = row['Shape'].strip()
    pt = pt.lstrip("(")
    pt = pt.rstrip(")")
    lat, lon = map(float, pt.split(","))

    geom = {
        'type': 'Point',
        'coordinates': [lon, lat]
        }

    props = {
        'name': row['NAME'],