soton_corenlppy.config_helper module

Config file helper functions to parse python INI files from disk and SQL database

soton_corenlppy.config_helper.read_config(filename, logger=None)[source]

read config file using ConfigParser.ConfigParser(). this helper function processes lists, tuples and dictionary serializations using ast.literal_eval() to return python objects not str

Parameters
Returns

parsed config file in a dict structure e.g. { ‘database_name’ : ‘mydatabase’, ‘list_names’ : [‘name1’,’name2’] }

Return type

dict

soton_corenlppy.config_helper.read_config_from_SQL(database_handler, query, timeout_statement=60, timeout_overall=180, logger=None)[source]

read config from a SQL query (SQL query should return a JSON config string for subsequent parsing)

Parameters
  • database_handler (SqlHandler.SqlHandler) – database handler object for SQL query

  • query (tuple) – SQL query tuple to execute to get config JSON object e.g. ( “SELECT json_config FROM … WHERE assessment_id = %s”, (‘ny_floods’,) )

  • timeout_statement (int) – number of seconds to allow each SQL statement

  • timeout_overall (int) – number of seconds total to allow each SQL statement (including retries)

  • logger (logging.Logger) – logger object

Returns

parsed config file in a dict structure e.g. { ‘database_name’ : ‘mydatabase’, ‘list_names’ : [‘name1’,’name2’] }

Return type

dict