Advanced Argument Parser for WikiMacros
This plug-in provides an advanced version of the parse_args function for WikiMacros.
This function is used in WikiMacros to parse the macro arguments. This enhanced version is meant as a replacement of trac.wiki.macros.parse_args and supports several advanced options (see section #Parameters). The most important feature is the support for quoting the delimiter, e.g. 'key1=val1,key2="some,text",key3=val3' will correctly return 'some,text' as the value of key2. The original parse_args function would return '"some' and handle 'text"' as separate argument.
def parse_args (args, strict = True, multi = False, listonly = False, minlen = 0, quotechar = '"', escchar = '\\', delim = ',', delquotes = False)
# Instead of: from trac.wiki.macros import parse_args # Use: from tracadvparseargs import * class SomeMacro(WikiMacroBase): def expand_macro(self, formatter, name, args): largs, kwargs = parse_args( args, <options> )
- The argument string; 'content' in `expand_macro. This is the only mandatory argument.
- Enables strict checking of keys.
- Enables folding of muliple given keys into list.
If set to True, values of multiple given keys will be returned as list, but single given keys will return a scalar.
If set to a list, only the values of the listed keys will be returned as list, but always as list even when there is only one value.
If this list contains '*', all values are always returned as list.
- If true only a list is returned, no directionary.
- Extend returned list to given minimum length. Only used when listonly=True.
- The quote character to be used.
- The escape character to be used.
- The delimiter character to be used.
- Selects if quotes should be removed.
TracHacks Macros which use this Function
If you have any issues, create a new ticket.
Download the zipped source from here.
This package is also available from the Python Package Index.
-  by rjollos on 2014-01-24 01:45:47
Changed license to BSD 3-Clause with permission of author (comment:1:ticket:11500). Fixes #11500.
-  by martin_s on 2010-08-30 23:57:20
Added encoding meta-comment and declared SVN keywords as unicode to avoid issues with non-english locales.
-  by martin_s on 2010-08-23 13:11:20
Removed outdated variable rev from setup file.