diff options
author | Trevor Bramwell <tbramwell@linuxfoundation.org> | 2017-11-10 15:43:35 -0800 |
---|---|---|
committer | Trevor Bramwell <tbramwell@linuxfoundation.org> | 2017-11-10 15:45:32 -0800 |
commit | f11f26d23dabde24b0bcd67ac81b094aa89eb6c9 (patch) | |
tree | 500546f6f553b049eb9ac146e7c8359d073fbf7a /utils/test/testapi/opnfv_testapi/common/config.py | |
parent | 122cf34bf3e656e1b7fa35e07dd8a71e42ed4d59 (diff) |
Remove 'utils/test' Directory and update INFO
utils/test has been migrated to the releng-testresults repo
Change-Id: If14a30e6abed1424d1e00b0fae048b7d869ec99b
Signed-off-by: Trevor Bramwell <tbramwell@linuxfoundation.org>
Diffstat (limited to 'utils/test/testapi/opnfv_testapi/common/config.py')
-rw-r--r-- | utils/test/testapi/opnfv_testapi/common/config.py | 63 |
1 files changed, 0 insertions, 63 deletions
diff --git a/utils/test/testapi/opnfv_testapi/common/config.py b/utils/test/testapi/opnfv_testapi/common/config.py deleted file mode 100644 index f888b07be..000000000 --- a/utils/test/testapi/opnfv_testapi/common/config.py +++ /dev/null @@ -1,63 +0,0 @@ -############################################################################## -# Copyright (c) 2015 Orange -# guyrodrigue.koffi@orange.com / koffirodrigue@gmail.com -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Apache License, Version 2.0 -# which accompanies this distribution, and is available at -# http://www.apache.org/licenses/LICENSE-2.0 -# feng.xiaowei@zte.com.cn remove prepare_put_request 5-30-2016 -############################################################################## -import ConfigParser -import argparse -import os -import sys - - -class Config(object): - - def __init__(self): - self.config_file = '/etc/opnfv_testapi/config.ini' - self._set_config_file() - self._parse() - self._parse_per_page() - - def _parse(self): - if not os.path.exists(self.config_file): - raise Exception("%s not found" % self.config_file) - - config = ConfigParser.RawConfigParser() - config.read(self.config_file) - self._parse_section(config) - - def _parse_section(self, config): - [self._parse_item(config, section) for section in (config.sections())] - - def _parse_item(self, config, section): - [setattr(self, '{}_{}'.format(section, k), self._parse_value(v)) - for k, v in config.items(section)] - - def _parse_per_page(self): - if not hasattr(self, 'api_results_per_page'): - self.api_results_per_page = 20 - - @staticmethod - def _parse_value(value): - try: - value = int(value) - except Exception: - if str(value).lower() == 'true': - value = True - elif str(value).lower() == 'false': - value = False - return value - - def _set_config_file(self): - parser = argparse.ArgumentParser() - parser.add_argument("-c", "--config-file", dest='config_file', - help="Config file location", metavar="FILE") - args, _ = parser.parse_known_args(sys.argv) - if hasattr(args, 'config_file') and args.config_file: - self.config_file = args.config_file - - -CONF = Config() |