[Solved] [Python] Update property in a configuration file
Posted: Mon Sep 24, 2012 10:02 am
Hello,
I would like to update a configuration file in the registry.
Here is the configuration file I would like to update:
What I want to update is the URL of the dictionaries files in the property "Locations", a string list, in the node "HunSpellDic_fr-multidict".
Here is the code:
Here I just try to update with what I read in the property "Locations", but I get the error message :
In Python, result is a tuple of strings. I tried to pass it as a list, and it said that list object has no attribute getTypes.
How can I update a property of strings-list ?
I would like to update a configuration file in the registry.
Here is the configuration file I would like to update:
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<oor:component-data xmlns:oor="http://openoffice.org/2001/registry" xmlns:xs="http://www.w3.org/2001/XMLSchema" oor:name="Linguistic" oor:package="org.openoffice.Office">
<node oor:name="ServiceManager">
<node oor:name="Dictionaries">
<node oor:name="HunSpellDic_fr-multidict" oor:op="fuse">
<prop oor:name="Locations" oor:type="oor:string-list">
<value>vnd.sun.star.expand:$UNO_USER_PACKAGES_CACHE/uno_packages/lu68yh0.tmp_/multi-fr.oxt/dictionaries/fr-reforme1990.aff vnd.sun.star.expand:$UNO_USER_PACKAGES_CACHE/uno_packages/lu68yh0.tmp_/multi-fr.oxt/dictionaries/fr-reforme1990.dic</value>
</prop>
<prop oor:name="Format" oor:type="xs:string">
<value>DICT_SPELL</value>
</prop>
<prop oor:name="Locales" oor:type="oor:string-list">
<value>fr-FR fr-BE fr-CA fr-CH fr-LU fr-MC</value>
</prop>
</node>
[...]
</node>
</node>
</oor:component-data>
Here is the code:
Code: Select all
xSettings = getConfigSetting("/org.openoffice.Office.Linguistic/ServiceManager/Dictionaries/HunSpellDic_fr-multidict", True)
result = xSettings.getByName("Locations")
xSettings.replaceByName("Locations", result)
xSettings.commitChanges()
def getConfigSetting (sNodeConfig, bForUpdate):
if bForUpdate:
sService = "com.sun.star.configuration.ConfigurationUpdateAccess"
else:
sService = "com.sun.star.configuration.ConfigurationAccess"
xConfigProvider = createUnoService("com.sun.star.configuration.ConfigurationProvider")
xPropertyValue = PropertyValue()
xPropertyValue.Name = "nodepath"
xPropertyValue.Value = sNodeConfig
xSettings = xConfigProvider.createInstanceWithArguments(sService, (xPropertyValue,))
return xSettings
def createUnoService (serviceName):
sm = uno.getComponentContext().ServiceManager
return sm.createInstanceWithContext(serviceName, uno.getComponentContext())
Code: Select all
com.sun.star.lang.IllegalArgumentException configmgr inappropriate property value
How can I update a property of strings-list ?