@views.route('/select-geography/', methods=['GET', 'POST'])
def select_geo():
    if not session.get('file'):
        return redirect(url_for('views.index'))
    context = {}
    if request.method == 'POST':
        inp = StringIO(session['file'])
        reader = UnicodeCSVReader(inp)
        header = reader.next()
        fields = {}
        valid = True
        geotype_val = None
        if not request.form:
            valid = False
            context['errors'] = ['Select a field that contains a geography type']
        else:
            geotypes = []
            indexes = []
            for k,v in request.form.items():
                if k.startswith("geotype"):
                    geotypes.append(v)
                    indexes.append(k.split('_')[1])
            if 2 > len(indexes):
                valid = False
                context['errors'] = ['We can only merge geographic information from 2 columns']
            else:
                fields_key = ';'.join([header[int(i)] for i in indexes])
                geotype_val = ';'.join([g for g in geotypes])
                if not check_combos(geotype_val):
                    valid = False
                    types = [t.title() for t in geotype_val.split(';')]
                    context['errors'] = ['The geographic combination of {0} and {1} does not work'.format(*types)]
                else:
                    fields[fields_key] = {
                        'geo_type': geotype_val,
                        'column_index': ';'.join(indexes)
                    }

            # found_geo_type = get_geo_types(geo_type)[0]['info']
            # sample_list = session['sample_data'][index][2]
            # valid, message = found_geo_type.validate(sample_list)
            # context['errors'] = [message]
        if valid:
            try:
                geo_type = SENSICAL_TYPES[geotype_val]
            except KeyError:
                geo_type = geotype_val
            mancer_data, errors = get_data_sources(geo_type=geo_type)
            session['fields'] = fields
            session['mancer_data'] = mancer_data
            for error in errors:
                flash(error)
            return redirect(url_for('views.select_tables'))
    return render_template('select_geo.html', **context)
dataset/ETHPy150Open associatedpress/geomancer/geomancer/views.py/select_geo/swapped operands of `>`