def get(code): db = mongo.get_db() variable = db.variables.find_one({'code': code}) if (not variable) or config.bool('reload'): logging.info("Variable %s not found, loading from SOAP...", code) variable = soap.get_variable(code) if not variable: return None for link in variable.get('links', []): if u"Tabellen mit Vorkommen des Merkmals" in link.get('titel'): variable['tables'] = [t for t in load_variable_tables(link.get('href'))] variable['__ts'] = datetime.utcnow() db.variables.update({'code': code}, variable, upsert=True) return variable
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
def get(code): db = mongo.get_db() variable = db.variables.find_one({'code': code}) if (not variable) or config.bool('reload'): logging.info("Variable %s not found, loading from SOAP...", code) variable = soap.get_variable(code) if not variable: return None for link in variable.get('links', []): if u"Tabellen mit Vorkommen des Merkmals" in link.get('titel'): variable['tables'] = [ t for t in load_variable_tables(link.get('href')) ] variable['__ts'] = datetime.utcnow() db.variables.update({'code': code}, variable, upsert=True) return variable
def get(stat_id, include_tables=True): db = mongo.get_db() statistic = db.statistics.find_one({'code': stat_id}) if (not statistic) or config.bool('reload'): logging.info("Statistic %s not found, loading from SOAP...", stat_id) statistic = soap.get_statistic(stat_id) if not statistic: return None tables = [] for table in soap.find_tables_by_statistic(stat_id): tables.append(table) statistic['tables'] = tables statistic['description'] = load_description(stat_id) statistic['variables'] = [v for v in load_variables(stat_id)] statistic['__ts'] = datetime.utcnow() db.statistics.update({'code': stat_id}, statistic, upsert=True) import table for _table in statistic['tables']: table.get(_table.get('code')) return statistic
def load_cached(**kwargs): if config.bool('cache'): kwargs['section'] = config.section() data = get_db().loadcache.find_one(kwargs) if data: return data.get('__data', {})
def load_cached(**kwargs): if config.bool("cache"): kwargs["section"] = config.section() data = get_db().loadcache.find_one(kwargs) if data: return data.get("__data", {})