# Path: orm.py
# def now():
# def set_sqlite_pragma(dbapi_connection, connection_record):
#     def is_blank(self):
#     def save(self):
#     def save(self):
#     def save(self):
# def counter():
# def exithandler():
# class Value(Base):
# class DataSet(Base):
# class Indicator(Base):


import re
import datetime
import requests
import orm
import logging
from orm import session, Value, DataSet, Indicator
        try:
            name, = [x['name'] for x in self.columns if x['fieldName'] == fieldname]
        except Exception:
            print [x['fieldName'] for x in self.columns]
            print "Couldn't find {}".format(fieldname)
            raise
        return name

    @property
    def column_fieldnames(self):
        return [x['fieldName'] for x in self.columns]
 
    @property
    def rows(self):
        return self.jdata['data']

    @property
    def combined(self):
        return [dict(zip(self.column_fieldnames, row)) for row in self.rows]

    def extract(self, fieldname):
        try:
            return [{'region': x['country'], 'value': x[fieldname]} for x in self.combined]
        except Exception:
            return [{'region': x['countries'], 'value': x[fieldname]} for x in self.combined]

    def export(self, meta):
        ind = {'indID': meta['indID'],
               'name': self.name_for_fieldname(meta['fieldname']), 
               'units': meta['unit']}

# Path: orm.py
# def now():
# def set_sqlite_pragma(dbapi_connection, connection_record):
#     def is_blank(self):
#     def save(self):
#     def save(self):
#     def save(self):
# def counter():
# def exithandler():
# class Value(Base):
# class DataSet(Base):
# class Indicator(Base):


# Path: novel_undp.py
import re
import datetime
import requests
import orm
import logging
from orm import session, Value, DataSet, Indicator

        try:
            name, = [x['name'] for x in self.columns if x['fieldName'] == fieldname]
        except Exception:
            print [x['fieldName'] for x in self.columns]
            print "Couldn't find {}".format(fieldname)
            raise
        return name

    @property
    def column_fieldnames(self):
        return [x['fieldName'] for x in self.columns]
 
    @property
    def rows(self):
        return self.jdata['data']

    @property
    def combined(self):
        return [dict(zip(self.column_fieldnames, row)) for row in self.rows]

    def extract(self, fieldname):
        try:
            return [{'region': x['country'], 'value': x[fieldname]} for x in self.combined]
        except Exception:
            return [{'region': x['countries'], 'value': x[fieldname]} for x in self.combined]

    def export(self, meta):
        ind = {'indID': meta['indID'],
               'name': self.name_for_fieldname(meta['fieldname']), 
               'units': meta['unit']}

        Indicator(**ind).save()