Issue 1165404: ConfigParser alternative key-value delimitier (original) (raw)

Issue1165404

Created on 2005-03-17 16:57 by fidoman, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
ConfigParser.diff fidoman,2005-03-17 16:57 diff file
Messages (5)
msg47990 - (view) Author: Sergey Dorofeev (fidoman) Date: 2005-03-17 16:57
ConfigParser is module which parses commonly used INI files. It gets sections from file and values from sections. By now, it gets from file key and value divided by symbol ":" or "=". For FTN application, a want to use FTN addresses as keys. FTN address looks like "2:5020/12000". So if I try to use it as key, ConfigParser considers "2" as key and "5020/12000 = ..." as value. I made patch, which allows to use any set of symbols (or '=' and ':' by default for compatibility) as delimitier between key and value in INI file.
msg47991 - (view) Author: Neal Norwitz (nnorwitz) * (Python committer) Date: 2007-03-16 06:23
Note: delimmap doesn't look like it's needed. Should be able to just check if vi in self.delim. (Although I'm kinda tired and don't feel like thinking too hard, so maybe that's just bs.).
msg47992 - (view) Author: Stephen Hansen (aptshansen) Date: 2007-03-17 04:47
I think the basis of this patch is a good one; I think 'delimiter' should be plural as delimiters, but that might be all picky. :) I don't think "self.delimmap = map(lambda x: x, self.delim)" should be done; map and lambda aren't needed here. Wouldn't it be cleaner to just accept a list and join it instead? More Pythonic? Since delimiter=":=" to me looks like you want the string ":=" to be a delimiter, but I might be having pascal flashbacks. To me its more clear. E.g.: def __init__(self, defaults=None, delimiters=(':', '=')): self._delimiters = ''.join(delimiters) As stated below, you don't need delimmap; "if vi in self.delim" will work fine. Anyways, all that aside (and that's just opinions, but--): 1) The patch no longer applies cleanly to the HEAD. I believe it would be very straightforward to fix the patch up though. 2) It needs documentation, and 3) It definitely needs tests added to test_cfgparser.
msg47993 - (view) Author: Stephen Hansen (aptshansen) Date: 2007-03-18 02:56
It actually turns out this patch would make *my* life easier, so instead of leaving it to the original submitter to make current and add stuff to, I modified it and added docs and tests as 1682942.
msg82180 - (view) Author: Daniel Diniz (ajaksu2) * (Python triager) Date: 2009-02-15 23:32
Closing as #1682942 has a better patch (a link to this one is automagically added).
History
Date User Action Args
2022-04-11 14:56:10 admin set github: 41712
2009-02-16 03:13:43 ajaksu2 set status: open -> closed
2009-02-15 23:32:35 ajaksu2 set versions: + Python 2.7nosy: + ajaksu2messages: + superseder: ConfigParser support for alt delimiterscomponents: + Library (Lib), - Nonetype: enhancement
2005-03-17 16:57:04 fidoman create