Commit Graph

68 Commits

Author SHA1 Message Date
David Goodger 1cbf206d32 SF bug #997050: Document, test, & check for non-string values in ConfigParser. Moved the new string-only restriction added in rev. 1.65 to the SafeConfigParser class, leaving existing ConfigParser & RawConfigParser behavior alone, and documented the conditions under which non-string values work. 2004-10-03 15:55:09 +00:00
David Goodger 68a1abdade SF bug #1017864: ConfigParser now correctly handles default keys, processing them with ``ConfigParser.optionxform`` when supplied, consistent with the handling of config file entries and runtime-set options. 2004-10-03 15:40:25 +00:00
Fred Drake 82903148a8 ConfigParser:
- read() method returns a list of files parsed successfully
- add tests, documentation
(closes SF patch #677651)
2004-05-18 04:24:02 +00:00
Fred Drake abc086fb0d ConfigParser:
- don't allow setting options to non-string values; raise TypeError
  when the value is set, instead of raising an arbitrary exception
  later (such as when string interpolation is performed)
- add tests, documentation
(closes SF bug #810843)
2004-05-18 03:29:52 +00:00
Fred Drake bc12b01d83 ConfigParser:
- ensure that option names in interpolations are handled by
  self.optionxform in the same way that other references to option
  names
- add tests, documentation
(closes SF bug #857881, patch #865455)
2004-05-18 02:25:51 +00:00
Raymond Hettinger bac788a3cd Replace str.find()!=1 with the more readable "in" operator. 2004-05-04 09:21:43 +00:00
Walter Dörwald 70a6b49821 Replace backticks with repr() or "%r"
From SF patch #852334.
2004-02-12 17:35:32 +00:00
Fred Drake 8c4da53afe Make both items() methods return lists; one had changed to return an
iterator where it probably shouldn't have.
Closes SF bug #818861.
2003-10-21 16:45:00 +00:00
Walter Dörwald f0dfc7ac5c Fix a bunch of typos in documentation, docstrings and comments.
(From SF patch #810751)
2003-10-20 14:01:56 +00:00
Raymond Hettinger 99c2d531d1 SF patch #790443: add SafeConfigParser to __all__
(Contributed by George Yoshida.)
2003-09-01 23:30:44 +00:00
Neal Norwitz 10f3018023 Fix arguments for instantiating InterpolationSyntaxError 2003-06-29 04:23:35 +00:00
Fred Drake e2c649126e Further cleanup of exceptions. All interpolation-related exceptions
now derive from InterpolationError, which is not raised directly (only
subclasses get raised).  This matches what the docs already said.
2002-12-31 17:23:27 +00:00
Fred Drake 00dc5a93c1 ConfigParser._interpolate(): Pass the missing key to the
InterpolationError constructor, not the KeyError exception itself.
    (Caught by the new InterpolationError test.)

SafeConfigParser._interpolate_some():  Pass the right number of
    arguments to the InterpolationError constructor.
    (Caught by pychecker.)
2002-12-31 06:55:41 +00:00
Fred Drake 8d5dd98a2e - added InterpolationSyntaxError to __all__
- added docstring to exceptions
2002-12-30 23:51:45 +00:00
Neal Norwitz ce1d944b6b Add missing InterpolationSyntaxError.
XXX Not sure this is correct.
2002-12-30 23:38:47 +00:00
Neal Norwitz f680cc460c Update doc for getboolean() to match code (ie, returning True/False)
Convert remaining uses of 1/0 to True/False
2002-12-17 01:56:47 +00:00
Tim Peters 230a60c6ec Whitespace normalization. 2002-11-09 05:08:07 +00:00
Andrew M. Kuchling 9050a517c8 Fix docstring typos 2002-11-06 14:51:20 +00:00
Fred Drake 0eebd5cef9 Implement a safer and more predictable interpolation approach.
Closes SF bug #511737.
2002-10-25 21:52:00 +00:00
Fred Drake df393bd46a According to the docs, __name__ is not exposed via the API except
indirectly via %(__name__)s.  Not sure why, but maintain the
documented behavior for the new items() method.

Be a little more efficient about how we compute the list of options in
the ConfigParser.items() method.
2002-10-25 20:41:30 +00:00
Fred Drake fce6557c6b Re-factor: Use a RawConfigParser base class and make ConfigParser a
derived class that adds the ugly string interpolation code.  In the
process, changed all "__" methods and instance variables to "_".
2002-10-25 18:08:18 +00:00
Fred Drake 176916a989 Allow internal whitespace in keys.
Closes SF bug #583248; backporting to r22-maint branch.
2002-09-27 16:21:18 +00:00
Fred Drake 2ca041fde0 items(): New method, provided by Gustavo Niemeyer in SF bug #545096. 2002-09-27 15:49:56 +00:00
Fred Drake c2ff9051d2 has_option(): Use the option name transform consistently.
Closes SF bug #561822.

Integrate the "code cleanup and general bug fix patch" (SF bug #545096),
contributed by Gustavo Niemeyer.  This is the portion of that patch that
does not add new functionality.
2002-09-27 15:33:11 +00:00
Walter Dörwald 65230a2de7 Remove uses of the string and types modules:
x in string.whitespace => x.isspace()
type(x) in types.StringTypes => isinstance(x, basestring)
isinstance(x, types.StringTypes) => isinstance(x, basestring)
type(x) is types.StringType => isinstance(x, str)
type(x) == types.StringType => isinstance(x, str)
string.split(x, ...) => x.split(...)
string.join(x, y) => y.join(x)
string.zfill(x, ...) => x.zfill(...)
string.count(x, ...) => x.count(...)
hasattr(types, "UnicodeType") => try: unicode except NameError:
type(x) != types.TupleTuple => not isinstance(x, tuple)
isinstance(x, types.TupleType) => isinstance(x, tuple)
type(x) is types.IntType => isinstance(x, int)

Do not mention the string module in the rlcompleter docstring.

This partially applies SF patch http://www.python.org/sf/562373
(with basestring instead of string). (It excludes the changes to
unittest.py and does not change the os.stat stuff.)
2002-06-03 15:58:32 +00:00
Raymond Hettinger 54f0222547 SF 563203. Replaced 'has_key()' with 'in'. 2002-06-01 14:18:47 +00:00
Raymond Hettinger 0f4940c0a8 Replaced boolean test with 'is None' 2002-06-01 00:57:55 +00:00
Fred Drake d451ec1cdb Clean up uses of some deprecated features.
Reported by Neal Norwitz on python-dev.
2002-04-26 02:29:55 +00:00
Tim Peters bc0e910826 Convert a pile of obvious "yes/no" functions to return bool. 2002-04-04 22:55:58 +00:00
Andrew M. Kuchling 00824ed733 [Bug #523301] ConfigParser.write() produces broken output for values that
were originally rfc822-like line continuations.
   Modified version of a patch from Matthias Ralfs.
2002-03-08 18:08:47 +00:00
Tim Peters e0c446bb4a Whitespace normalization. 2001-10-18 21:57:37 +00:00
Guido van Rossum fb06f75c5a Apply modified SF patch 467580: ConfigParser.getboolean(): FALSE, TRUE.
This patch allows ConfigParser.getboolean() to interpret TRUE,
    FALSE, YES, NO, ON and OFF instead just '0' and '1'.

    While just allowing '0' and '1' sounds more correct users often
    demand to use more descriptive directives in configuration
    files. Instead of forcing every programmer do brew his own
    solution a system should include the batteries for this.

[My modification to the patch is a slight rewording of the docstring
and use of lowercase instead of uppercase templates.  The code is
still case sensitive. GvR.]
2001-10-04 19:58:46 +00:00
Martin v. Löwis 339d0f720e Patch #445762: Support --disable-unicode
- Do not compile unicodeobject, unicodectype, and unicodedata if Unicode is disabled
- check for Py_USING_UNICODE in all places that use Unicode functions
- disables unicode literals, and the builtin functions
- add the types.StringTypes list
- remove Unicode literals from most tests.
2001-08-17 18:39:25 +00:00
Andrew M. Kuchling 7c2cf73811 Remove redefinition of has_option() method 2001-08-13 14:58:32 +00:00
Martin v. Löwis 02d893cfae Patch #444359: Remove unused imports. 2001-08-02 07:15:29 +00:00
Fred Drake beb6713ea7 When reading a continuation line, make sure we still use the transformed
name when filling in the internal data structures, otherwise we incorrectly
raise a KeyError.

This fixes SF bug #432369.
2001-07-06 17:22:48 +00:00
Fred Drake 3c823aa4b6 Make sure ConfigParser uses .optionxform() consistently; this affects
.has_option(), .remove_option(), and .set().

This closes SF tracker #232913.
2001-02-26 21:55:34 +00:00
Fred Drake d4df94b56d Be much more permissive in what we accept in section names; there has been
at least one addition to the set of accepted characters for every release
since this module was first added; this should take care of the problem
in a more substantial way.

This closes SF bug #132288.
2001-02-14 15:24:17 +00:00
Fred Drake d83bbbfd22 Allow square brackets in the option names; this makes it possible to use
ConfigParser with GNOME-ish config files that use the internationalization
conventions found in GNOME.

This closes SF bug #131635.
2001-02-12 17:18:11 +00:00
Eric S. Raymond f296019cc5 Correction after second code path test. 2001-02-09 05:37:25 +00:00
Eric S. Raymond 9eb54d9828 String method conversion. 2001-02-09 05:19:09 +00:00
Skip Montanaro e99d5ea25b added __all__ lists to a number of Python modules
added test script and expected output file as well
this closes patch 103297.
__all__ attributes will be added to other modules without first submitting
a patch, just adding the necessary line to the test script to verify
more-or-less correct implementation.
2001-01-20 19:54:20 +00:00
Tim Peters 88869f9787 Whitespace normalization. 2001-01-14 23:36:06 +00:00
Fred Drake 7c1e5adf27 Make ConfigParser.Error inherit from Exception. 2000-12-11 18:13:19 +00:00
Fred Drake ff4a23bbcb remove_option(): Use the right variable name for the option name!
This closes bug #124324.
2000-12-04 16:29:13 +00:00
Fred Drake 2a37f9f862 Allow spaces in section names.
Do not expose the __name__ when reporting the list of options available
for a section since that is for internal use.

This closes SourceForge bug #115357.

Additionally, define InterpolationDepthError and MAX_INTERPOLATION_DEPTH.
The exception is raised by get*() when value interpolation cannot be
completed within the defined recursion limit.  The constant is only
informative; changing it will not affect the allowed depth.

Fix the exit from get() so that None is not returned if the depth is met
or exceeded; either return the value of raise InterpolationDepthError.
2000-09-27 22:43:54 +00:00
Guido van Rossum 4126736791 When reading the file, option names were not passed through
self.optionxform(), which (in the default case) caused options spelled
with opper case letters in their name to be inaccessible.  Reported by
"Todd R. Palmer" <t2palmer@bellsouth.net> on
activepython@listserv1.ActiveState.com.
2000-09-25 14:42:33 +00:00
Thomas Wouters ff4df6d6fb Small fixes by Petru Paler (patch #100946) checked in with esr's approval. 2000-07-21 05:19:59 +00:00
Eric S. Raymond 649685ad9b ConfigParser enhancements to edit existing configs, part 2 2000-07-14 14:28:22 +00:00
Eric S. Raymond 417c489def Give ConfigParser the capability to set as well as read options, and to write
a representation of the configuration state in .ini format that can be read
back in by a future read() call.  Thus this class is now a back end
for .ini editors as well as parsers.

This patch is complete and tested, but exposes a bug in the ConfigParser
implementation which I have not yet fixed.  Because case information is
discarded during parsing, the output of write() has its case smashed.

I wrote this for a SourceForge interface script called forgetool.
Documentation for the new entry points included.
2000-07-10 18:11:00 +00:00