Source code for kuha_osmh_repo_handler.configure

#!/usr/bin/env python3
# Author(s): Toni Sissala
# Copyright 2020 Finnish Social Science Data Archive FSD / University of Tampere
# Licensed under the EUPL. See LICENSE.txt for full license.
"""Configure OSMH Repo Handler
import os
from kuha_common import cli_setup

[docs]def configure(): """Get settings for application configuration. Declares application spesific configuration options and some common options declared in :mod:`kuha_common.cli_setup` Configure application with arguments specified in configuration file, environment variables and command line arguments. :note: Calling this function multiple times will not initiate new settings to be parsed, but will return previously parsed settings instead. :returns: settings :rtype: :obj:`argparse.Namespace` """ if cli_setup.settings.is_settings_loaded(): return cli_setup.get_settings() cli_setup.load(os.path.dirname(os.path.realpath(__file__)), description='Run Kuha OSMH Repo Handler.', config_file='kuha_osmh_repo_handler.ini') cli_setup.add('--port', help='Server port', default=6002, env_var='KUHA_ORH_PORT', type=int) cli_setup.add('--osmh-repo-handler-api-version', help='OSMH Repo Handler API version', default='v0', env_var='KUHA_OSMH_API_VERSION', type=str) cli_setup.add('--query-limit', help=('Configure the limit of records per query when ' 'fetching multiple records from Document Store. ' 'Experimental feature. Set 0 to disable.'), default=0, env_var='KUHA_OSMH_QUERY_LIMIT', type=int) cli_setup.add('--stream-response', help='Use streaming for responses to ListRecordHeaders requests.', default=False, action='store_true', env_var='KUHA_OSMH_STREAM_RESPONSE') cli_setup.add_print_configuration(cli_setup.settings.parser) return cli_setup.setup( cli_setup.MOD_DS_CLIENT, cli_setup.MOD_DS_QUERY, cli_setup.MOD_LOGGING )