HPS-MC
_config.py
Go to the documentation of this file.
1 """! @package _config
2 Global config utilities for initialization.
3 """
4 
5 import configparser
6 import logging
7 import sys
8 import os
9 from 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 
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
def _read_global_config()
Read global configuration files.
Definition: _config.py:12
def convert_config_value(val)
Convert config value to Python readable value.
Definition: _config.py:24