1.1 --- a/MoinSupport.py Fri May 17 20:22:39 2013 +0200
1.2 +++ b/MoinSupport.py Fri May 31 02:07:53 2013 +0200
1.3 @@ -456,6 +456,47 @@
1.4
1.5 return pairs
1.6
1.7 +def parseDictEntry(entry, unqualified=None):
1.8 +
1.9 + """
1.10 + Return the parameters specified by the given dict 'entry' string. The
1.11 + optional 'unqualified' parameter can be used to indicate parameters that
1.12 + need not be specified together with a keyword and can therefore be populated
1.13 + in the given order as such unqualified parameters are encountered.
1.14 +
1.15 + NOTE: This is similar to parseMacroArguments but employs space as a
1.16 + NOTE: separator and attempts to assign unqualified parameters.
1.17 + """
1.18 +
1.19 + parameters = {}
1.20 + unqualified = unqualified or ()
1.21 +
1.22 + try:
1.23 + parsed_args = entry and wikiutil.parse_quoted_separated(entry, separator=None, name_value=False) or []
1.24 + except AttributeError:
1.25 + parsed_args = entry.split()
1.26 +
1.27 + for arg in parsed_args:
1.28 + try:
1.29 + argname, argvalue = arg.split("=", 1)
1.30 +
1.31 + # Detect unlikely parameter names.
1.32 +
1.33 + if not argname.isalpha():
1.34 + raise ValueError
1.35 +
1.36 + parameters[argname] = argvalue
1.37 +
1.38 + # Unqualified parameters are assumed to be one of a recognised set.
1.39 +
1.40 + except ValueError:
1.41 + for argname in unqualified:
1.42 + if not parameters.has_key(argname):
1.43 + parameters[argname] = arg
1.44 + break
1.45 +
1.46 + return parameters
1.47 +
1.48 # Request-related classes and associated functions.
1.49
1.50 class Form:
2.1 --- a/README.txt Fri May 17 20:22:39 2013 +0200
2.2 +++ b/README.txt Fri May 31 02:07:53 2013 +0200
2.3 @@ -73,6 +73,7 @@
2.4 datetime parsing support.
2.5 * Fixed the time zone information associated with page revisions.
2.6 * Added RFC 2822 datetime parsing with help from the email.utils module.
2.7 + * Added a common wikidict entry parsing function.
2.8
2.9 New in MoinSupport 0.3 (Changes since MoinSupport 0.2)
2.10 ------------------------------------------------------