Is there a way to escape newlines using ConfigParser?
There is this option --addons-path
in config where you can provide multiple paths for addons, but paths are long and there are many of paths so writing everything in one line, looks really bad. So I thought to put addons paths in multiple lines, but ConfigParser does not allow it. I get this error:
Starting odoo-server: Traceback (most recent call last):
File "/home/oerp/openerp80/odoo/openerp-server", line 5, in <module>
openerp.cli.main()
File "/home/oerp/openerp80/odoo/openerp/cli/__init__.py", line 68, in main
o.run(args)
File "/home/oerp/openerp80/odoo/openerp/cli/server.py", line 180, in run
main(args)
File "/home/oerp/openerp80/odoo/openerp/cli/server.py", line 140, in main
openerp.tools.config.parse_config(args)
File "/home/oerp/openerp80/odoo/openerp/tools/config.py", line 358, in parse_config
self._parse_config(args)
File "/home/oerp/openerp80/odoo/openerp/tools/config.py", line 403, in _parse_config
self.load()
File "/home/oerp/openerp80/odoo/openerp/tools/config.py", line 605, in load
p.read([self.rcfile])
File "/usr/lib/python2.7/ConfigParser.py", line 305, in read
self._read(fp, filename)
File "/usr/lib/python2.7/ConfigParser.py", line 546, in _read
raise e
ConfigParser.ParsingError: File contains parsing errors: /etc/odoo-server.conf
[line 3]: '/home/oerp/openerp80/addons,\n'
[line 4]: '/home/oerp/openerp80/community-addons\n'
Is there a way to write paths in multiple lines, but make ConfigParser treat it as one line (ignoring newlines)?
Update
Config file sample (works):
someparam = blabla
; this is part I want to modify
addons_path = /some/dir1,/some/dir2,/some/dir3
; some other params
Config file I want to look like, but it does not work:
someparam = blabla
; this is part I want to modify
addons_path = /some/dir1,
/some/dir2,
/some/dir3
; some other params
P.S. Indentation can be different as long as I could put paths in multiple lines, so it would not just go into one long line.
The answers before were a step in the right direction.
In Odoo 9 it works like this (You need to indent the lines and keep the commas but it's still possible to have multiple paths in one line.):
[options]
addons_path =
/some/dir1,
/some/dir2,/some/dir3,
/some/dir4,
/some/dir5
To achieve this in an older version you can modify the odoo/openerp/tools/config.py
Search this line
os.path.abspath(os.path.expanduser(os.path.expandvars(x)))
and replace it with this
os.path.abspath(os.path.expanduser(os.path.expandvars(x.strip())))