Ejemplo n.º 1
0
def get_data(table_id):
    if not config.get("data_path"):
        return
    for format in ["csv", "html"]:
        data = soap.get_table(table_id, format=format)
        if data:
            fn = os.path.join(config.get("data_path"), "table_%s.%s" % (table_id, format)) 
            out_file = codecs.open(fn, "w", "utf-8")
            out_file.write(data)
            out_file.close()
Ejemplo n.º 2
0
def get_data(table_id):
    if not config.get("data_path"):
        return
    for format in ["csv", "html"]:
        data = soap.get_table(table_id, format=format)
        if data:
            fn = os.path.join(config.get("data_path"),
                              "table_%s.%s" % (table_id, format))
            out_file = codecs.open(fn, "w", "utf-8")
            out_file.write(data)
            out_file.close()
Ejemplo n.º 3
0
def get(table_id):
    db = mongo.get_db()
    table = db.tables.find_one({'code': table_id})
    if (not table) or config.bool('reload'):
        logging.info("Table %s not found, loading from SOAP...", table_id)
        table_data = soap.get_table(table_id)
        if not table_data:
            return None
        get_data(table_id)
        table = {'csvdata': table_data, 'code': table_id}
        table.update(table_to_dict(table_id, table_data))
        db.tables.update({'code': table_id}, table, upsert=True)
    else:
        reparse_table(table_id)
    return table
Ejemplo n.º 4
0
def get(table_id):
    db = mongo.get_db()
    table = db.tables.find_one({'code': table_id})
    if (not table) or config.bool('reload'):
        logging.info("Table %s not found, loading from SOAP...", table_id)
        table_data = soap.get_table(table_id)
        if not table_data: 
            return None
        get_data(table_id)
        table = {'csvdata': table_data, 'code': table_id}
        table.update(table_to_dict(table_id, table_data))
        db.tables.update({'code': table_id}, table, upsert=True)        
    else:
        reparse_table(table_id)
    return table