Coder Social home page Coder Social logo

iniparse's People

Watchers

 avatar  avatar

iniparse's Issues

Unable to set values in DEFAULT section

Using the INIConfig interface (ini iniparse 0.4), it does not appear to be 
possible to set values in the DEFAULT section.

The naive approach has no effect:

>>> import iniparse
>>> cfg = iniparse.INIConfig()
>>> cfg.DEFAULT.myoption = 'myvalue'
>>> print cfg

>>>

It is not clear from the documentation or examples how to deal with this 
situation.


Original issue reported on code.google.com by [email protected] on 12 Sep 2014 at 1:40

Ability to append items to list in config file


It would be helpful to be able to add items to a list in a configuration
file.  Something like:

optiona += itema, itemb

This would allow optiona to have a default list set by the application and
then to add items to it.  The real world example is yum and the
installonlypkgs option which is pre-populated with a large list of kernel item.

Original issue reported on code.google.com by [email protected] on 15 Apr 2009 at 2:58

Key/value separator should be '=' rather than ' = '

What steps will reproduce the problem?
1. Create a key in the normal way

What is the expected output? What do you see instead?
As this is an INI parser (not a config parser) I expect it to do more or less 
what Windows' kernel32::WritePrivateProfileString writes:

  Key=value

However, due to ini.py, line 108 - OptionLine.__init__, parameter four, 
separator=' = ', it writes it with spaces around the equals sign:

  Key = value

When wanting to edit correctly formatted INI files, this is a problem. If 
editing existing values the lack of whitespace will be preserved, but if new 
values are created they don't match.

What version of the product are you using? On what operating system?
0.4, Python 2.6

Please provide any additional information below.

Another solution would be to handle this sort of thing with some **config on 
the INIConfig or something like that. That'd require a fair bit of work to do 
well, though. And I still think that the default should be '=' rather than ' = 
'.

I'd prefer this to be fixed in iniparse itself so that it behaves like a proper 
INI parser, but if you don't want to do this I can maintain a version of my own 
for my project... with those two characters removed.

Original issue reported on code.google.com by chris.morganiser on 22 Jun 2010 at 1:55

Leading whitespace in front of a value make the parsing fail

What steps will reproduce the problem?
1. Create a ini file value with a leading white space
2. To access the value

The treatment of leading white spaces is not really well defined:

http://en.wikipedia.org/wiki/INI_file#Whitespace

The the doc definitely says that some implementation ignores them. In the case 
of iniparse the name=value pair becomes completely unavailable.

I can't imagine a scenario where this could be desired.

The change might as simple as:

http://code.google.com/p/iniparse/source/browse/trunk/iniparse/ini.py#

line 131 in iniparse/ini.py
-name = m.group('name').rstrip()
+name = m.group('name').strip()

line 135 in iniparse/ini.py
-name = m.group('name').rstrip()
+name = m.group('name').strip()

Cheers,
Batiste

Original issue reported on code.google.com by [email protected] on 13 Jun 2012 at 8:32

circular imports make python3 unhappy


I have been playing around with python3 and iniparse and have build some 
fedora packages, there make a python3 version of iniparse using the 2to3 
tool from python3.
But i run into an issue when importing iniparse

Python 3.1.2 (r312:79147, Apr  1 2010, 03:31:01) 
[GCC 4.4.3 20100226 (Red Hat 4.4.3-8)] on linux2
>>> import iniparse
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.1/site-packages/iniparse/__init__.py", line 6, in 
<module>
    from .ini import INIConfig, tidy, change_comment_syntax
  File "/usr/lib/python3.1/site-packages/iniparse/ini.py", line 48, in 
<module>
    from . import compat
  File "/usr/lib/python3.1/site-packages/iniparse/compat.py", line 27, in 
<module>
    from . import ini
ImportError: cannot import name ini

This is cause by ini.py has a

from . import compat

and compat.py has a 

from . import ini

The compat import in ini.py is only used by the newly added tidy().

One way to solve it is to move the tidy() to a separate .py file, so the 
compat import can be skipped from ini.py.

What do you think ?

Tim








Original issue reported on code.google.com by tim.lauridsen on 5 May 2010 at 9:27

comment/uncomment options.

Tim Lauridsen to iniparse-discuss
Aug 29

In some ini style files, like the attached fedora.repo file
some options (#baseurl=....) is commented out, if i use iniparse to add
a baseurl option, it will be added at the end of the section, because is
new option.
It would be nice if there was a way to comment/uncomment there kind of
options.

#baseurl=xxxxx -> baseurl=yyyy

baseurl=zzzz -> #baseurl=zzzz

And the order will be kept in the file.
The easiest way to implement this is to treat #baseurl=xxxx, as an
options with the name '#baseurl" and the value 'xxxx'
and the add a method to rename an option ini.rename('#baseurl','baseurl').

Tim

Original issue reported on code.google.com by [email protected] on 25 Sep 2007 at 4:15

Inaccurate parsing compared to proper Windows functions

There are a number of issues in parsing which produce inaccurate results when 
compared to normal INI parsing methods (i.e. Windows' *PrivateProfile* 
functions).

Here are a few which I've noticed which are inconsistent with how they "should" 
be parsed for INI files.

Quoted values: if the read value is wrapped in single or double quotes, the 
quotes should be removed, permitting leading and trailing whitespace which 
would otherwise not work. And it is not a "valid string" check, it is purely a 
first and last character check - so Key="Val"ue" should be Val"ue, and 
Key="Value1" "Value2" should be Value1" "Value2.

Comments:
* The semicolon is the only accepted comment character: 
http://msdn.microsoft.com/en-us/library/ms724348%28VS.85%29.aspx, "Comments 
(any line that starts with a semicolon) ..."
* There is no support for inline comments in option lines. I'm not certain 
about section lines though; I didn't test that when I was working directly with 
the PrivateProfile functions, but I expect that they're not allowed.

In short, the only acceptable comment form in INI files is a line starting with 
a semicolon (/^;/, no leading whitespace).

Combining the quotes and comments things, it would simplify parsing immensely 
if you removed support for the inline comments altogether - just 
string.strip(); string[0] == string[-1] and string[0] in ('"', "'") and 
string[1:-1] or string. But I quite understand that you won't want to do it 
that way seeing as people use this for non-INI files with other comment 
characters and inline comments and things like that. A better solution will be 
attributes like "comment_chars = ';'", "inline_comments = False" and 
"unquote_values = True" in your INIDialect you talked of in issue 23.

Examples of erroneous INI parsing:

  [Section]
  A="value"
  B = ' value'
  C=a ;b

+-----+----------+----------+
| Key | Expected | Actual   |
+-----+----------+----------+
|  A  | value    | "value"  |
|  B  |  value   | " value" |
|  C  | a ;b     | a        |
+-----+----------+----------+

Thanks for this library, it's handy in the ways it's better than ConfigParser 
:-)

Original issue reported on code.google.com by chris.morganiser on 23 Jun 2010 at 11:51

AttributeError: 'NoneType' object has no attribute 'extend'

What steps will reproduce the problem?
1. Ubuntu 8.04.2
2. Python 2.5.2
3. iniparse-0.3.0
4. videocache-1.9.tar.gz
5. while installing videocache iniparse errors out...

# python setup.py install
Traceback (most recent call last):
  File "setup.py", line 395, in <module>
    main(root)
  File "setup.py", line 333, in main
    mainconf =  readMainConfig(readStartupConfig(config_file, root))
  File "/home/dmonty/Download/videocache-1.9/videocache/config.py", line
710, in readStartupConfig
    parser.readfp(confpp_obj)
  File "/usr/lib/python2.5/site-packages/iniparse/compat.py", line 115, in
readfp
    self.data._readfp(fp)
  File "/usr/lib/python2.5/site-packages/iniparse/ini.py", line 581, in _readfp
    cur_option.extend(pending_lines)
AttributeError: 'NoneType' object has no attribute 'extend'



Original issue reported on code.google.com by [email protected] on 28 Feb 2009 at 3:39

Python 3 support

The project makes no mention of python 3 support.

If it is supported, the following tag should be added to setup.py:

"Programming Language :: Python :: 3",

Original issue reported on code.google.com by [email protected] on 6 Mar 2014 at 11:20

Exceptions not compatible

From: Oleg Deribas
Date: Mon, 06 Dec 2004 15:35:49 +0200
Subject: Re: cfgparse 0.1

>>But it is not compatible with ConfigParser's exceptions. I have used 
>>NoSectionError in my program, but cfgparse.compat does not support it.
>I looked at that code again quickly, and it does seem to be raising
>NoSectionError in many cases.  Can you send me the specific case where
>it raises the wrong exception?

Oh, I'm sorry.
I catch ConfigParser.Error (which is base class for all ConfigParser's
exceptions) to intercept any config errors on top level.
And there is no such class in cfgparse.compat

Original issue reported on code.google.com by [email protected] on 15 Jul 2007 at 11:25

Multi-line values cannot span comments and empty lines

Reported by David Timms:

Hi, on a machine running f8t1, I updated yum to development, which:
installed python-iniparse 0.2.1-2.fc8
updated   yum 3.2.4-3.fc8

Now yum commands rejects my repo files:
# yum update rpm
Loading "skip-broken" plugin
Config Error: File contains parsing errors:
file://///etc/yum.repos.d/fedora.reo
        [line  8]:
http://ftp.iinet.net.au/pub/fedora/linux/releases/7.90/Eve/

# cat /etc/yum.repos.d/fedora.repo
====
[fedora]
name=Fedora $releasever - $basearch
#baseurl=http://download.fedora.redhat.com/pub/fedora/linux/releases/$releasever
/Everything/$basearch/os/
baseurl=
#  ftp://infrastructure-server/linux/fedora/$releasever/$basearch/disc/
#
ftp://infrastructure-server/linux/fedora/$releasever/$basearch/yum/fedora/
#
ftp://ftp.iinet.net.au/pub/fedora/linux/releases/$releasever/Everything/$basearc
h/os/

http://ftp.iinet.net.au/pub/fedora/linux/releases/$releasever/Everything/$basear
ch/os/
#
ftp://mirror.pacific.net.au/linux/fedora/linux/releases/$releasever/Everything/$
basearch/os/
#
http://mirror.pacific.net.au/linux/fedora/linux/releases/$releasever/Everything/
$basearch/os/

#mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=fedora-$releasever&
arch=$basearch
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora
file:///etc/pki/rpm-gpg/RPM-GPG-KEY

[fedora-debuginfo]
====
Since the above will be wrapped and might not be obvious - simplified:

baseurl=
#  http://internalsite/fedora/path/
  http://ispsmirror/fedora/path/
  http://incountrymirror/fedora/path/
#  http://incountrymirror2/fedora/path/

mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=fedora-$releasever&a
rch=$basearch

OK, I can solve this deleting the two space characters that I used to
indent the baseurl's {leacing the commented lines}, aka:
=====
baseurl=
#  http://internalsite/fedora/path/
http://ispsmirror/fedora/path/
http://incountrymirror/fedora/path/
#  http://incountrymirror2/fedora/path/
=====
or  I can remove the commented lines alltogether, leaving the indentation:
=====
baseurl=
  http://incountrymirror/fedora/path/
=====

I think that rejecting indented lines if there is an intervening comment
is being unnecessarily strict. The key is capable of having multiple
values, separated by newlines. We should be able to comment out
individual lines {and not permanently remove them}. We should also be
able to indent lines to more clearly indicate the structure of the
settings in the file.

Original issue reported on code.google.com by [email protected] on 10 Sep 2007 at 5:32

Make it easier to access non-string values

At the moment, all config values are strings.  Individual config variables
should themselves be promoted to objects with .asint() .asbool(),
.asfloat() or .asstring() methods that convert that variable to the type
you actually need, and/or it should perhaps make an attempt at type
inference for basic types.

(see issue 18 for the original complaint)

Original issue reported on code.google.com by [email protected] on 17 Apr 2010 at 7:10

DEFAULT section is listed in SafeConfigParser.sections()

What steps will reproduce the problem?
1. create an ini-file with a DEFAULT section and another section
2. load the ini-file with a iniparse.SafeConfigParser opject
3. do a print parser.sections()

What is the expected output? What do you see instead?
In the output the section DEFAULT is shown, but according to the
ConfigParser documentation this should be filtered

What version of the product are you using? On what operating system?
Version 0.2.4 (on Ubuntu with python 2.5.2)

Please provide any additional information below.


Original issue reported on code.google.com by [email protected] on 1 Feb 2009 at 7:05

ValueError on cfg.defaults()

What steps will reproduce the problem?
1. print("cfg.defaults: %s" %(cfg.defaults()))

What is the expected output? What do you see instead?

Expected: options and values of [DEFAULT]

Instead:

Traceback (most recent call last):
  File "C:\PyPrg\dev\_testiniparse.py", line 32, in <module>
    print("cfg.defaults: %s" %(cfg.defaults()))
  File "C:\Python\lib\site-packages\iniparse\compat.py", line 40, in defaults
    for name, lineobj in self.data._defaults._options:
ValueError: too many values to unpack

What version of the product are you using? On what operating system?
Python-2.6 / iniparse-0.2.4

Please provide any additional information below.

Possible solution in compat.py, class RawConfigParser:

    def defaults(self):
        d = {}
        # next line, .items() inserted!
        for name, lineobj in self.data._defaults._options.items():
            d[name] = lineobj.value
        return d





Original issue reported on code.google.com by [email protected] on 10 Feb 2009 at 10:43

Setting new value on an option with continuation lines gives unexpected results

What steps will reproduce the problem?
1. Having an option with a mix of continuation lines and spaces
2. Changing that option to a new value without spaces
3.

What is the expected output? What do you see instead?

Expected:

To get new option with same indentation and without blank lines.

Got:

First line starting on option line (different from original)
New options that exceeded LineContainer.contents have different indentation 
from original.

What version of the product are you using? On what operating system?

iniparse 0.2.4

Please provide any additional information below.

The attached patch adds a test for the expected behavior and fixes 
LineContainer to match the expectations.

Original issue reported on code.google.com by [email protected] on 29 Dec 2008 at 9:20

Attachments:

ConfigParse compat mode with a defaults {'foo'=None} returns string 'None'

What steps will reproduce the problem?

With a 'test.ini' like:
[test]
foo = blip


and code like:

from iniparse import SafeConfigParser

defaults = {'foo':'bar', 'blip': None}
cp = SafeConfigParser(defaults = defaults)
cp.read('test.ini')
a = cp.get('test', 'blip')
print a, type(a)


What is the expected output? What do you see instead?

ConfigParser.SafeConfigParser will return None in this case

What version of the product are you using? On what operating system?
python-iniparse-0.4-2.fc14.noarch, python 2.7

Please provide any additional information below.


Original issue reported on code.google.com by [email protected] on 4 Jan 2011 at 9:17

pickle - Error

What steps will reproduce the problem?

1.

import pickle
from iniparse import ConfigParser
cfg = ConfigParser()
cfg.read('my.ini')

out = open('my.ini.pickled','wb')
pickle.dump(cfg.out)
out.close()

del cfg

iin = open('my.ini.pickled','rb')
cfg = pickle.load(iin)
...

2. Using the original ConfigParser seems ok!

What is the expected output? What do you see instead?

Expected: a picklefile

Instead:

Traceback (most recent call last):
  File "C:\PyPrg\dev\_testiniparse.py", line 44, in <module>
    pickle.dump(cfg,out)
  File "C:\Python\lib\pickle.py", line 1362, in dump
    Pickler(file, protocol).dump(obj)
  File "C:\Python\lib\pickle.py", line 224, in dump
    self.save(obj)
  File "C:\Python\lib\pickle.py", line 331, in save
    self.save_reduce(obj=obj, *rv)
  File "C:\Python\lib\pickle.py", line 419, in save_reduce
    save(state)
  File "C:\Python\lib\pickle.py", line 286, in save
    f(self, obj) # Call unbound method with explicit self
  File "C:\Python\lib\pickle.py", line 649, in save_dict
    self._batch_setitems(obj.iteritems())
  File "C:\Python\lib\pickle.py", line 663, in _batch_setitems
    save(v)
  File "C:\Python\lib\pickle.py", line 306, in save
    rv = reduce(self.proto)
  File "C:\Python\lib\copy_reg.py", line 84, in _reduce_ex
    dict = getstate()
TypeError: 'Undefined' object is not callable

What version of the product are you using? On what operating system?

Python 2.6 with iniparse 0.2.4 on Windows XP Sp3


Please provide any additional information below.

Using the original ConfigParser seems ok!

Original issue reported on code.google.com by [email protected] on 10 Feb 2009 at 11:34

Compatibility: optionxform

From: Gavin Kinsey
Date: Thu, 08 Feb 2007 12:32:59 +0000
Subject: Bug report for cfgparse

I'm playing with your cfgparse python module, I've wanted a better
config parser for a while but it's your backwards compatibility with
ConfigParser that is the killer feature that allowed me to actually
switch.  So thanks for writing it :-).  Now on to the bug...

One of my programs derives a new class from ConfigParser and overrides
optionxform in order to have case-sensitive option names. Switching to
the cfgparse.compat module this code no longer works.

I've written a little workaround so it's not a major issue, but it would
be nice if I didn't have to make any change.

This is what I use for a workaround:
@@ -90,9 +93,8 @@

 class CaseSensitiveSafeConfigParser(ConfigParser):
    """Case Sensitive version of ConfigParser"""
-     def optionxform(self, option):
-        """Use str()"""
-        return str(option)
+     def __init__(self):
+        self.data = cfgparse.iniparser.ini_namespace(optionxform=str)

 def getAndType(self, section, option):
     rawVal = self.get(section, option)

Original issue reported on code.google.com by [email protected] on 15 Jul 2007 at 11:28

get_sections and get_options methods for INIConfig and INISection

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

Original issue reported on code.google.com by [email protected] on 19 Jan 2011 at 7:03

config object are not passable to Queue object from multiprocessing module.

Python multiprocessing module have very nice Queue class to pass messages 
(objects) between the processed. I've tried to use this to propagate 
configuration changes between the processes. However, INIConfig instances 
have trouble with this.

What steps will reproduce the problem?
1. Place attached my.conf and mysend.py in the same directory.
2. Run python ./mysend.py
3.

What is the expected output? What do you see instead?
I would expect "test1" to be printed. Instead, I see this error messages:
Traceback (most recent call last):
  File "/usr/lib/pymodules/python2.5/multiprocessing/queues.py", line 242, 
in _feed
    send(obj)
TypeError: 'Undefined' object is not callable

What version of the product are you using? On what operating system?
I'm using python 2.5.2 on Debian Lenny amd 64 bit. iniparse 0.3.2.

Please provide any additional information below.


Original issue reported on code.google.com by [email protected] on 4 May 2010 at 1:28

Attachments:

Trailing whitespace is significant for inline comments

To find comments at the end of values, for example:
  [sec]
  opt = 7  ;comment

ConfigParser looks for a semicolon, and then does the following check:
  if pos != -1 and optval[pos-1].isspace():

That means that if pos == 0 - i.e., the value after '=' begins with a
semicolon, it is a comment only if the _last_ character on the line is a
whitespace character.

INIParse does not behave the same way at the moment.

Original issue reported on code.google.com by [email protected] on 2 Mar 2009 at 4:43

Adaptation to python 3

Hi,

I have taken to port iniparse to python 3.

Attached you will find my patch.

A second patch is a file that is missing causing the compat unit test to fail.

The resulting set passes all unit tests.

Robert de Vries

Original issue reported on code.google.com by [email protected] on 26 May 2010 at 1:04

Attachments:

config.section.key fails rather than returning Undefined for undefined section

Long summary: An INIConfig provides a nice Undefined object for undefined 
sections so that you can set values directly. Unfortunately, this Undefined 
does not provide magic __getitem__ or __getattr__ methods, so undefined values 
raise an AttributeError.

I use a simple function, ``ini_defined``, for some things on INI files for 
setting and validation of some INI files in a set format, where the sections 
and keys may or may not exist::

    from iniparse.config import Undefined

    def ini_defined(val):
        return not isinstance(val, Undefined)

I may add I think this would be helpful in ``iniparse.utils``.

On to the issue. Here is the current behaviour::

    >>> import iniparse
    >>> config = iniparse.INIConfig()
    >>> config.section
    <iniparse.config.Undefined object at 0x7fcfaeff9190>
    >>> config.section.key
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    AttributeError: 'Undefined' object has no attribute 'key'
    >>> config.section.key = 'value'
    >>> config.section.key2
    <iniparse.config.Undefined object at 0x7fcfaeff9350>

When the section is defined, an undefined key works, so that I can do 
``ini_defined(config.section.key2)``. However, 
``ini_defined(config.section2.key)`` will raise an AttributeError, so I've 
taken to doing ``ini_defined(config.section2) and 
ini_defined(config.section2.key)`` when the section may not exist. Not neat.

Here is a patch which provides __getitem__ and __getattr__ for the Undefined 
object, returning another Undefined object. There is one side-effect to it 
which I've identified; the getter can then go to any number of levels. But the 
setter will fail, so I think it's alright::

    >>> # New behaviour; foo.section2 is not a defined section
    >>> foo.section2.key
    <iniparse.config.Undefined object at 0x7f3d7ab63a50>
    >>> foo.section2.key.subkey
    <iniparse.config.Undefined object at 0x7f3d7ab63bd0>
    >>> foo.section2.key.subkey = 'value'
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "iniparse/config.py", line 108, in __setattr__
        obj = object.__getattribute__(self, 'namespace')._new_namespace(self.name)
    TypeError: 'Undefined' object is not callable
    >>> foo.section2.key.subkey.subkey
    <iniparse.config.Undefined object at 0x7f3d7ab63b50>
    >>> foo.section2.key.subkey.subkey = 'value'
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "iniparse/config.py", line 108, in __setattr__
        obj = object.__getattribute__(self, 'namespace')._new_namespace(self.name)
    TypeError: 'Undefined' object is not callable

I don't think it would be worth while "fixing" this getter behaviour with 
another Undefined subclass. Note that this is a different exception from the 
Exception: ('No sub-sections allowed', 'key3') you get if the section is 
defined but the key is not - e.g. ``foo.section.key3.subkey``. If it matters I 
can fix it up.

Side note: defining __getattribute__ instead of __getattr__ and using 
object.__getattribute__ locally (a decorator could switch self for a magic 
thing which would use object.__getattribute__ instead of self.__getattribute__) 
would remove the possibility of name clashes entirely. But I think I'll create 
another bug and patch for that. May take a while, though.

Original issue reported on code.google.com by chris.morganiser on 13 Nov 2010 at 12:30

Attachments:

Integration with command-line parsing

It would be nice to have an easy way of unifying configuration options from
an INI file and the command line - sort of like the "-o" option in ssh.

Original issue reported on code.google.com by [email protected] on 25 Mar 2009 at 3:51

Options in inifile with name beginning with REM are skipped

The RegExp for Class CommentLine should test for a space after REM.
If not, an option like Remote_dir is interpreted as a comment.


regexp like 
regex = re.compile(r'^(?P<csep>[;#]|[rR][eE][mM] +)'
                       r'(?P<comment>.*)$')

(" +'" added)
should work.

Original issue reported on code.google.com by [email protected] on 22 Feb 2012 at 2:24

Docs are misleading: All variables are 'string' type

All of the documentation examples use 'print' to display the results. This
is misleading because it allows you to believe that iniparse is magically
inferring the types of the config file elements. It is not. Everything is a
string, even integer and boolean config variables.

Either the documentation should be updated to reflect this shortcoming, or
the individual config variables should themselves be promoted to objects
with .asint() .asbool(), .asfloat() or .asstring() methods that convert
that variable to the type you actually need, and/or it should perhaps make
an attempt at type inference for basic types.

Original issue reported on code.google.com by [email protected] on 2 Apr 2010 at 9:31

test_compat fails: missing cfgparse.1

What steps will reproduce the problem?
1. Download pristine 0.4 tarball, untar
2. python setup.py build
3. ./runtests.py

Expected:

Should succeed all tests

Actual:

Fails for test_compat, in every case because cfgparse.1 is missing from the 
tarball. I was going to run iniparse through 2to3 to see if it ran in 3 (I've 
seen patches to make it compatible), and tests are quite useful in making sure 
iniparse works after that.


Versions:

iniparse 0.4 from the download page, with python 2.7.3rc2 in debian testing.



Original issue reported on code.google.com by [email protected] on 31 May 2012 at 5:02

Problems in removing sections

From: Jeremy Evans
Date: Sat, 23 Oct 2004 12:22:32 -0700
Subject: Problem with cfgparse.remove_section

Paramjit,

I've been using cfgparse for a project I'm working on, and I'm getting
an error in remove_section.  Here's the traceback:

  File "C:\Python23\Lib\site-packages\cfgparse\compat.py", line 175, in
remove_section
    del self.data[section]
  File "C:\Python23\Lib\site-packages\cfgparse\iniparser.py", line 377,
in __delitem__
    self._data.contents.remove(self._sections[key]._lineobj)
ValueError: list.remove(x): x not in list

The section name exists in the config.  If you try to remove a section
name that doesn't exist in the config, it is silently ignored instead of
raising a NoSectionError.

Just thought I'd let you know, so you could incorporate the fixes into a
future version.  Thanks for your work on cfgparse. I was planning to
write something similar for my project, so it's saved me quite a bit of
time.

Jeremy Evans

Original issue reported on code.google.com by [email protected] on 15 Jul 2007 at 11:15

UnboundLocalError: local variable 'optobj' referenced before assignment

Thanks for fixing the last issue so quickly... here is the next one I get...

What steps will reproduce the problem?
1. Ubuntu 8.04.2
2. Python 2.5.2
3. iniparse-0.3.0
4. videocache-1.9.tar.gz
5. while installing videocache iniparse errors out...

$ sudo python setup.py install
Traceback (most recent call last):
  File "setup.py", line 395, in <module>
    main(root)
  File "setup.py", line 333, in main
    mainconf =  readMainConfig(readStartupConfig(config_file, root))
  File "/home/dmonty/Download/videocache-1.9/videocache/config.py", line
710, in readStartupConfig
    parser.readfp(confpp_obj)
  File "/usr/lib/python2.5/site-packages/iniparse/compat.py", line 115, in
readfp
    self.data._readfp(fp)
  File "/usr/lib/python2.5/site-packages/iniparse/ini.py", line 584, in _readfp
    optobj._compat_skip_empty_lines.add(cur_option_name)
UnboundLocalError: local variable 'optobj' referenced before assignment

Original issue reported on code.google.com by [email protected] on 1 Mar 2009 at 2:46

Add option after commented-out option example

Many applications ship annotated configuration examples which include sections 
like these:

  [section]                                                                                                                             
  # Hello
  # option1 = foo                                                                                                                       

  #option2=bazz                                                                                                                         
  #option3=spam                                                                                                                         
  bumble=bee

When you edit this example with IniParse, a human would expect the following 
result:

  [section]                                                                                                                             
  # Hello
  # option1 = foo                                                                                                                       
  option1 = bar                                                                                                                         

  #option2=bazz
  option2 = bazz                                                                                                                        
  #option3=spam
  option3 = spam                                                                                                                        
  bumble=bee  

However, currently IniParse doesn't check for commented-out option lines, thus 
the output is actually:

  [section]
  # Hello
  # option1 = foo

  #option2=bazz
  #option3=spam
  bumble=bee
  option1 = bar
  option2 = bazz
  option3 = spam


The bigger the config file becomes, the more annoying this behavior is [0]. The 
attached patch tries to provide a solution. Feel free to critize the 
implementation :-)


Footnotes:
 [0] https://github.com/openstack/nova/blob/master/etc/nova/nova.conf.sample

Original issue reported on code.google.com by [email protected] on 27 May 2013 at 2:09

Attachments:

Regression in compat.RawConfigParser.remove_option

What steps will reproduce the problem?
1. Create one of the parsers in compat.py with a defaults dictionary.  The 
attached file uses a SafeConfigParser.
2. Add a section to the parser.
3. Attempt to remove the default option from the section created in step 2.

What is the expected output? What do you see instead?
The expected output should be False which is what ConfigParser returns.  
Instead, iniparse throws a KeyError.

What version of the product are you using? On what operating system?
This issue is present in iniparse 0.4.  I am using the python-iniparse library 
on Fedora 18: python-iniparse-0.4-6.fc18.noarch

Please provide any additional information below.
This issue was introduced in revision 141.

A small program is attached to demonstrate the error.


Original issue reported on code.google.com by [email protected] on 23 Jul 2013 at 5:24

Attachments:

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.