|
From: David H. <neg...@gm...> - 2011-02-24 14:28:52
|
Ha! Good catch.
Yeah, he's ending up with a cfg that has the following:
>>> cfg.filename
'c:\temp\\config.ini'
>>> cfg.dict()
{}
>>>
Thus... an empty data set because it never opened any existing file for parsing.
And as soon as he fixes that, he'll get the following:
configobj.configobj.DuplicateError: Duplicate keyword name at line 3.
cheers,
-hoss
On Thu, Feb 24, 2011 at 08:53, Michael Foord <fuz...@vo...> wrote:
> On 24/02/2011 13:50, Anton Hughes wrote:
>
> Hi
> Im trying to use ConfigObj but am getting the following error. And I have
> know idea what I am doing wrong. Anyone can help?
>
> from configobj import ConfigObj
> config = ConfigObj('c:\temp\config.ini')
>
> This line probably doesn't do what you expect. In Python the backslash is an
> escape character in strings and "\t" is a tab. Try this instead:
>
> config = ConfigObj(r'c:\temp\config.ini')
>
> The "r" makes the string raw so that backslashes are literals rather than
> escape characters.
>
> All the best,
>
> Michael Foord
>
> config["som_somserver"]
> Traceback (most recent call last):
> File "<console>", line 1, in <module>
> File "build\bdist.win32\egg\configobj.py", line 567, in __getitem__
> val = dict.__getitem__(self, key)
> KeyError: 'som_somserver'
>
>
> Here is a copy of my config file:
> soc_source = soc_source
> retail_price = $400
> soc_source = 1
> soc_theme = 2
> soc_target = 3
> soc_folder_exist = 4
> soc_folder_temp_exist = 5
> soc_folder_backup_exist = 6
> som_somserver = 1
> som_filename=2
> som_sourcefile = 3
> som_targetfile = 4
> som_fileexist = 5
> som_file_temp_exist=6
> som_file_backup_exist=7
> Thanks
>
> ------------------------------------------------------------------------------
> Free Software Download: Index, Search & Analyze Logs and other IT data in
> Real-Time with Splunk. Collect, index and harness all the fast moving IT
> data
> generated by your applications, servers and devices whether physical,
> virtual
> or in the cloud. Deliver compliance at lower cost and gain new business
> insights. http://p.sf.net/sfu/splunk-dev2dev
>
> _______________________________________________
> Configobj-develop mailing list
> Con...@li...
> https://lists.sourceforge.net/lists/listinfo/configobj-develop
>
>
> --
> http://www.voidspace.org.uk/
>
> May you do good and not evil
> May you find forgiveness for yourself and forgive others
> May you share freely, never taking more than you give.
> -- the sqlite blessing http://www.sqlite.org/different.html
>
> ------------------------------------------------------------------------------
> Free Software Download: Index, Search & Analyze Logs and other IT data in
> Real-Time with Splunk. Collect, index and harness all the fast moving IT
> data
> generated by your applications, servers and devices whether physical,
> virtual
> or in the cloud. Deliver compliance at lower cost and gain new business
> insights. http://p.sf.net/sfu/splunk-dev2dev
> _______________________________________________
> Configobj-develop mailing list
> Con...@li...
> https://lists.sourceforge.net/lists/listinfo/configobj-develop
>
>
|