Bug 967129 - add support for inline comments
add support for inline comments
Product: Fedora
Classification: Fedora
Component: crudini (Show other bugs)
Unspecified Linux
low Severity medium
: ---
: ---
Assigned To: Jakub Ruzicka
Fedora Extras Quality Assurance
: FutureFeature, ZStream
Depends On:
  Show dependency treegraph
Reported: 2013-05-24 16:41 EDT by Jaroslav Henner
Modified: 2016-04-22 01:04 EDT (History)
5 users (show)

See Also:
Fixed In Version:
Doc Type: Enhancement
Doc Text:
Story Points: ---
Clone Of:
Last Closed:
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Jaroslav Henner 2013-05-24 16:41:11 EDT
Description of problem:

Version-Release number of selected component (if applicable):

How reproducible:

Steps to Reproduce:
1. openstack-config --set /etc/keystone/keystone.conf DEFAULT compute_port "3000 # Evil"
$ /etc/init.d/openstack-keystone restart
Stopping keystone:                                         [FAILED]
Starting keystone:                                         [  OK  ]
$ /etc/init.d/openstack-keystone status
keystone dead but pid file exists

Actual results:
service do not start, nothing in log

Expected results:
service started or error in log

Additional info:
Comment 1 Pádraig Brady 2013-09-02 20:17:36 EDT
The standard python ini parsing libs support inline comments,
but only with ; as the comment delimeter. It seems the standard
windows ini parse doesn't even allow that.
Looking at the example.ini from the crudini project we see

 comment_after1=val ;a comment
 comment_after2=val;not a comment
 comment_after3=val #not a comment

The # is not usable in an inline comment for "backwards compat" reasons according to the python docs. So I would say the particular use case is catered for here by:

 openstack-config --set /etc/keystone/keystone.conf DEFAULT compute_port "3000 ;Evil"

But having a quick look at the code suggests that even ; isn't supported unless at the start of the line, since: https://review.openstack.org/#/c/5375/
It's a pity the existing stdlib parser couldn't be extended somehow to
support MultiStrOpt.

Another option is to add the --comment option to openstack-config (or more likely crudini), that would add the associated option on an adjacent line.
Comment 2 Pádraig Brady 2015-02-03 07:32:38 EST
The hack to set the comment as part of the --set value is not good,
because that would repeat comments for existing values.
I'm not sure it's appropriate at this stage to change the config file format upstream to support inline comments, given how non standard this is
anyway as noted in comment #1

The best option woule be to abstract the file representation,
using a --comment option in crudini, which would update comments,
probably on a separate line.

Note You need to log in before you can comment on or make changes to this bug.