StackOverflow,
Below is the first few lines of my script:
from ConfigParser import SafeConfigParser
from docopt import docopt
import core as scrappy
ARGS = docopt(__doc__, version=scrappy.__version__)
if not ARGS['PATH']:
ARGS['PATH'] = './'
# load config file
CFG = SafeConfigParser()
if not CFG.read(ARGS['--cfg']): # call to CFG.read also loads file if it exists
raise IOError('Configuration file not found.')
The configuration file I'm trying to read is in the same directory as the above script. By default, docopt sets the path to this file to ./file.conf
(I have tested this with file.conf
with identical results).
The last line of the script is always called, suggesting that the file can't be found. I confirmed this by printing the output of os.getcwd
, which revealed that the script's execution directory is whichever directory the terminal was pointing to.
What gives?
What can I do to point to the configuration file?