Closely integrated with setuptools is the pkg_resources module which helps with data discovery in a distribution. We should use it to retrieve our ini file config parser. I would like to add a module called "config.py" into amonpy/tools. Here are the contents
import pkg_resources
from ConfigParser import ConfigParser as CP
AMON_CONFIG = CP();
with open(pkg_resources.resource_filename("amonpy", "amon_replace.ini")) as f:
AMON_CONFIG.readfp(f)
Then any code can access the config parser already initialized by simply doing:
Closely integrated with setuptools is the pkg_resources module which helps with data discovery in a distribution. We should use it to retrieve our ini file config parser. I would like to add a module called "config.py" into amonpy/tools. Here are the contents
Then any code can access the config parser already initialized by simply doing:
from amonpy.tools.config import AMON_CONFIG
You then have access to the ConfigParser, e.g.,