I have the following file and I would like to replace #sys.path.insert(0, os.path.abspath('.')) with sys.path.extend(['path1', 'path2'])
import sys
import os
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#sys.path.insert(0, os.path.abspath('.'))
# -- General configuration ------------------------------------------------
However, the following code does not change the line.
with open(os.path.join(conf_py_path, "conf.py"), 'r+') as cnfpy:
for line in cnfpy:
line.replace("#sys.path.insert(0, os.path.abspath('.')))",
"sys.path.extend(%s)\n" %src_paths)
cnfpy.write(line)
How is it possible to replace the line?