[Patches] [ python-Patches-1165404 ] ConfigParser alternative key-value delimitier
SourceForge.net
noreply at sourceforge.net
Sun Mar 18 03:56:49 CET 2007
Patches item #1165404, was opened at 2005-03-17 16:57
Message generated for change (Comment added) made by aptshansen
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1165404&group_id=5470
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Sergey Dorofeev (fidoman)
Assigned to: Nobody/Anonymous (nobody)
Summary: ConfigParser alternative key-value delimitier
Initial Comment:
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.
----------------------------------------------------------------------
Comment By: Stephen Hansen (aptshansen)
Date: 2007-03-18 02:56
Message:
Logged In: YES
user_id=1720594
Originator: NO
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.
----------------------------------------------------------------------
Comment By: Stephen Hansen (aptshansen)
Date: 2007-03-17 04:47
Message:
Logged In: YES
user_id=1720594
Originator: NO
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.
----------------------------------------------------------------------
Comment By: Neal Norwitz (nnorwitz)
Date: 2007-03-16 06:23
Message:
Logged In: YES
user_id=33168
Originator: NO
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.).
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1165404&group_id=5470
More information about the Patches
mailing list