예제 #1
0
def update_account(name):
    account = Account(name).export(load_extras=False)
    prepare_account(account)

    # TODO Parse coordinates
    # parse_location(account)

    AccountModel.objects(name=name).update(**account, upsert=True)
예제 #2
0
def parse_location(account):
    location = account['profile'].get('location')

    if AccountModel.objects(
            name=account['name'],
            profile__location=location).first() or location is None:
        # Nothing to update
        return

    geolocator = Nominatim(user_agent="dtrip")
    location = geolocator.geocode(location)
    print(location.latitude, location.longitude)