pixelb / crudini

A utility for manipulating ini files
GNU General Public License v2.0
443 stars 63 forks source link

How do I get the values, for multiline options ? #10

Open aniruddha-a opened 10 years ago

aniruddha-a commented 10 years ago

As in this example:

[service_providers]       
service_provider=LOADBALANCER:Haproxy:neutron.services.loadbalancer.drivers.haproxy.plugin_driver.HaproxyOnHostPluginDriver:default
service_provider=VPN:openswan:neutron.services.vpn.service_drivers.ipsec.IPsecVPNDriver:default

i.e, there can be multiple service_provider params under the section, I want to get them all, from my sh script, and be able to modify either of them.

I tried a crudini --get <file> service_providers service_provider and I got only the last param set! Am I missing any option here, or this is not supported?

pixelb commented 10 years ago

Unfortunately crudini doesn't support that at present. The interface is there now to support it through the --list option, though it will require updating the iniparse project to support that. It's a pity that openstack went with this non standard format rather than for example:

[service_providers]
service_provider=LOADBALANCER:Haproxy:neutron.services.loadbalancer.drivers.haproxy.plugin_driver.HaproxyOnHostPluginDriver:default
                 VPN:openswan:neutron.services.vpn.service_drivers.ipsec.IPsecVPNDriver:default
aniruddha-a commented 10 years ago

Ok, for now I am managing with sed, and for these kind of options, I think I have no other choice, for now.

larsks commented 9 years ago

Is there any chance we can use the oslo.config module to read OpenStack-style config files correctly (specifically, to handle multi-line entries in a mannager identical to OpenStack)?

pixelb commented 9 years ago

BTW the standard list format mentioned in my reply above can be written with crudini --set --list --list-sep=$'\n' ...

For getting and setting the openstack format, it would need a selector in the interface, as currently the last item=val is read/updated, which may be depended on. I suppose this could be done with something like crudini --list --list-sep=REPEAT ... and if 'REPEAT' is specified then until we enhance the parser, have a soft dependency on oslo.config to parse/update/extract_text multistr options.

Hmm, perhaps we might avoid oslo.config and with REPEAT preprocess input to transform repeated items to/from the more standard list format shown in my first reply.

pixelb commented 8 years ago

I see that php supports a similar "array" format like:

[States]
east[] = Michigan
east[] = New York
east[] = Minnesota

I suppose that could be supported also with something like --list-sep=PHP

bramford commented 1 year ago

Unreal Engine's INI files also use this stupid non-standard format. E.g. Config/DefaultInput.ini:

-AxisConfig=(AxisKeyName="MouseX",AxisProperties=(DeadZone=0.f,Exponent=1.f,Sensitivity=0.07f))
-AxisConfig=(AxisKeyName="MouseY",AxisProperties=(DeadZone=0.f,Exponent=1.f,Sensitivity=0.07f))
-AxisConfig=(AxisKeyName="Mouse2D",AxisProperties=(DeadZone=0.f,Exponent=1.f,Sensitivity=0.07f))
+AxisConfig=(AxisKeyName="Mouse2D",AxisProperties=(DeadZone=0.000000,Sensitivity=0.070000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="ValveIndex_Right_Trigger_Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="ValveIndex_Right_Thumbstick_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
pixelb commented 5 months ago

qalculate-gtk.cfg also has repeated keyboard_shortcut= params, that should be treated as a set

pixelb commented 1 month ago

Re the unreal engine format, The leading [-+.!] characters are for unreal engines own set operations on items that are potentially spread over multiple files. Therefore we should not treat those prefixes specially. But we should support --get and --set against the full set, and users can specify the above prefixes and () around values as needed by the unreal config sub format. Now with --get it may be useful to specify the base parameter name which would return all prefixed items. That would probably need a --list-sep=UNREAL to appropriately adjust the config on input and output.