Issue 27 in iniparse: get_sections and get_options methods for INIConfig and INISection

4 views
Skip to first unread message

inip...@googlecode.com

unread,
Jan 19, 2011, 2:04:38 PM1/19/11
to iniparse...@googlegroups.com
Status: New
Owner: ----
Labels: Type-Defect Priority-Medium

New issue 27 by jphthier...@gmail.com: get_sections and get_options methods
for INIConfig and INISection
http://code.google.com/p/iniparse/issues/detail?id=27

Hi,

I am starting playing with iniparse and love to access sections and options
through an object-oriented notation. I may have missed something in the
documentation but... 2 methods would make my life easier (reading config
files and feed argparse arguments):

INIConfig.get_sections to list available sections: I am currently using the
private _sections attribute. It could be as easy as

def get_sections(self):
return self._sections.keys()

INISection.get_options to list avalaible options

Valuable or not?

Jean-Philippe

inip...@googlecode.com

unread,
Jun 4, 2011, 6:49:26 AM6/4/11
to iniparse...@googlegroups.com

Comment #1 on issue 27 by chris.morganiser: get_sections and get_options
methods for INIConfig and INISection
http://code.google.com/p/iniparse/issues/detail?id=27

INIConfig and INISection both have iterator support which does what you are
wanting here. A thing to remember is that the iterator support is over the
section/key name, not the section/value. It could be nice if INIConfig had
(iter)?(items|sections|values) methods and INISection (iter)?(items|keys|
values) methods, like dict, but that would then reserve some names meaning
that if you had an INI section or key called "values" (quite plausible) you
couldn't do ini.values to get it but would rather need to do ini['values'].
At present there are no properties without leading underscores, meaning
that there are no clashes unless your INI file includes underscores.

Anyway, in summary:

Instead of INIConfig.get_sections, use list(INIConfig).
Instead of INISection.get_options, use list(INISection).

(Or iterate over them.)

Reply all
Reply to author
Forward
0 new messages