HPS-MC
 
Loading...
Searching...
No Matches
_config.py
Go to the documentation of this file.
1"""! @package _config
2Global config utilities for initialization.
3"""
4
5import configparser
6import logging
7import sys
8import os
9from os.path import expanduser
10
11
13 """! Read global configuration files.
14 @param filename name of json file
15 @return a ConfigParser object with the configuration settings
16 """
17 config = configparser.ConfigParser()
18 config_files = config.read([
19 os.path.join(expanduser("~"), ".hpsmc"),
20 os.path.abspath(".hpsmc")])
21 return config, config_files
22
23
24def convert_config_value(val):
25 """! Convert config value to Python readable value."""
26 if val == 'True' or val == 'true':
27 return True
28 elif val == 'False' or val == 'false':
29 return False
30 try:
31 if val.contains('.'):
32 floatval = float(val)
33 return floatval
34 except BaseException:
35 pass
36 try:
37 intval = int(val)
38 return intval
39 except BaseException:
40 pass
41 return val
_read_global_config()
Read global configuration files.
Definition _config.py:12