app package

Submodules

app.parser module

class app.parser.Parser(content)[source]

Bases: object

get_compound_indicators()[source]
Returns:list of compound indicators found in the XML file.
get_dataset()[source]
Returns:dataset data found in the XML file.
get_datasource()[source]
Returns:datasource data found in the XML file.
get_indicator_groups()[source]
Returns:list of indicator groups found in the XML file.
get_license()[source]
Returns:license data of the XML file.
get_observations()[source]
Returns:list of observations found in the XML files. Every observation comes with its ref_time, value and computation. Each observation has the fields ‘region_code’ (UN_code) and ‘country_code’ (ISO3) of the region they reffer to.
get_organization()[source]
Returns:organization data found in the XML file. The organization ID is constructed with the domain name in the organization_url, for example www.observatoire-foncier.com will result in the ID ‘observatoire-foncier’.
get_simple_indicators()[source]
Returns:list of simple indicators found in the XML file.
get_slices()[source]
Returns:list of slices found in the XML files. Each slice has the fields ‘region_code’ (UN_code) and ‘country_code’ (ISO3) of the region they reffer to.
get_user()[source]
Returns:user data found in the XML file (whithout user_ip)

app.rdf_feeder module

app.rdf_feeder.feed_rdf()[source]

app.rdf_service module

class app.rdf_service.ReceiverRDFService(content)[source]

Bases: object

Service that gets the xml input from the html request, generates RDF triples and store them in Virtuoso triple store

run_service(graph, host, api, graph_uri, user_ip)[source]

Run the ReceiverRDFService

Parameters:
  • graph – RDF graph.
  • graph_uri – RDF graph URI to be stored in the triple store.
  • host – Triple store host.
  • api – Triple store authentication api.
  • user_ip – IP from the invoker client.
Returns:

RDF graph.

app.sql_service module

class app.sql_service.DBHelper[source]

Bases: object

Helper for querying the relational database.

static check_datasource(session, datasource_id)[source]

Find a DataSource in the DB. Returns None if not found.

static check_indicator_starred(session, indicator_id)[source]

Check if an Indicator is starred

static check_organization(session, organization_url)[source]
static check_user(session, user_id)[source]

Check if a user exists in the database using its ID

static find_compound_indicator(session, ind_id)[source]

Get a compound indicator by its ID

static find_country_id(session, country_code)[source]

Get the Country ID using its ISO3

static find_indicators(session, ids)[source]

Get all indicators in a list of IDs

static find_observations(session, ids)[source]

Get all observations in a list of IDs

static find_region_id(session, reg_code)[source]

Get the Region ID using its UN_CODE

class app.sql_service.ReceiverSQLService(content)[source]

Bases: object

Service that gets the xml input from the html request, generates SQL output and stores it into the configured relational database.

store_data(user_ip)[source]

Stores the data in the XML into the relational database. :param user_ip: The IP of the user that calls the service. :raises: The exception that made the data storing fail. If an exception

occurs, nothing will be stored into the database.

app.views module

class app.views.Receiver[source]

Bases: flask_restful.Resource

endpoint = 'receiver'
mediatypes(resource_cls)
methods = ['POST']
static post()[source]

Parse an XML and store the model mapping into the database.

Receives an xml=... with the XML content to parse Returns a 200 response if everything went right or 400 if there is not any content to parse.

Module contents

Table Of Contents

This Page