Earlier today, I committed a patch to ConfigParser that adds three new methods to the class. Here is the documentation: \begin{methoddesc}{has_option}{section, option} If the given section exists, and contains the given option. return 1; otherwise return 0. (New in 1.6) \end{methoddesc} \begin{methoddesc}{set}{section, option, value} If the given section exists, set the given option to the specified value; otherwise raise \exception{NoSectionError}. (New in 1.6) \end{methoddesc} \begin{methoddesc}{write}{fileobect} Write a representation of the configuration to the specified file object. This representation can be parsed by a future \method{read()} call. (New in 1.6) \end{methoddesc} These new methods are additions to the class, and do not change any existing code. Nevertheless Guido sent me a heads-up that I had committed a marginal violation of Python etiquette by changing the module without the explicit sign-off of the maintainers. For this I apologize, specifically to Andrew Kuchling and Barry Warsaw. Please note that I specifically refrained from fixing a bug in the existing code that was exposed by the new methods, in order to avoid the risk of breaking compatibility. Now I want to explain what I'm doing, specifically the next steps in my plan, and make sure there is a consensus to support it. I am working on a program called `forgetool' that is intended as a front end to SourceForge. It will keep your CVSROOT set properly as you hop between multiple projects, make it easy to do uploads to project HTTP directories without remembering a lot of boilerplate, enable remote scripting of releases, and in general serve as a SourceForge developer's Swiss-army knife. To do these things, forgetool needs to maintain some local state that is conveniently represented in the format of a Windows .ini file. More, it needs to be able to *update* .ini files as well as parse them. Accordingly, forgetool subclasses ConfigParser into EnhancedConfigParser adding the above methods. After testing them, I copied this code into ConfigParser for others to use. Two more things remain to be done: First, for completeness there ought to be remove_section and remove_option methods (though forgetool does not yet use them). I have documented these as follows: \begin{methoddesc}{remove_option}{section, option} Remove the specified \var{option} from the specified \var{section}. If the section does not exist, raise \exception{NoSectionError}. If the option existed to be removed, return 1; otherwise return 0. (New in 1.6) \end{methoddesc} \begin{methoddesc}{remove_section}{section} Remove the specified \var{section} from the configuration. If the section in fact existed, return 1. Otherwise return 0. \end{methoddesc} Second, the new methods expose a bug in the existing code. Because the case of section and option names is folded on input, the new write() method emits edited configurations with their case smashed. I think the existing code should be fixed to preserve case, with string.lower() being applied at key lookup time. Does anybody have a problem with these changes? Barry? Andrew? Again, I apologize for offending the local norms. I'm still learning... -- <a href="http://www.tuxedo.org/~esr">Eric S. Raymond</a> If gun laws in fact worked, the sponsors of this type of legislation should have no difficulty drawing upon long lists of examples of criminal acts reduced by such legislation. That they cannot do so after a century and a half of trying -- that they must sweep under the rug the southern attempts at gun control in the 1870-1910 period, the northeastern attempts in the 1920-1939 period, the attempts at both Federal and State levels in 1965-1976 -- establishes the repeated, complete and inevitable failure of gun laws to control serious crime. -- Senator Orrin Hatch, in a 1982 Senate Report
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4