~ibid-core/ibid/old-trunk-1.6

« back to all changes in this revision

Viewing changes to docs/api/ibid.plugins.rst

  • Committer: Tarmac
  • Author(s): Keegan Carruthers-Smith
  • Date: 2011-03-23 16:11:13 UTC
  • mfrom: (1015.6.8 named-groups-656201)
  • Revision ID: ibid-lp-lander@rivera.za.net-20110323161113-vzgpclmucy8fxyzi
Added named arguments to the match decorator.
Author: Keegan Carruthers-Smith
Merge Request: http://code.launchpad.net/~keegan-csmith/ibid/named-groups-656201/+merge/51159
Approved by: Stefano Rivera, Max Rabkin
Fixes LP: #656201

Show diffs side-by-side

added added

removed removed

Lines of Context:
147
147
   Selector     expands to
148
148
   ============ ==========================================
149
149
   ``{alpha}``  ``[a-zA-Z]+``
150
 
   ``{any}``    ``.*``
 
150
   ``{any}``    ``.+``
151
151
   ``{chunk}``  ``\S+``
152
152
   ``{digits}`` ``\d+``
153
153
   ``{number}`` ``\d*\.?\d+``
169
169
 
170
170
      @match(r'^(?:foo|bar)\s+(\S+)$', simple=False)
171
171
 
 
172
   Optionally you can specify keyword arguments, which will get passed on to
 
173
   the function. The syntax is ``{keyword:selector}``, where the keywords will
 
174
   get passed onto the decorated method::
 
175
 
 
176
      @match(r'I am {nick:chunk} on {network:chunk}')
 
177
      def register(self, event, network, nick):
 
178
         pass
 
179
 
 
180
   The above match is equivalent to this non-simple version::
 
181
 
 
182
      @match(r'^I\s+am\s+(?P<nick>\S+)\s+on\s+(?P<network>\S+)$', simple=False)
 
183
 
 
184
   Note that you cannot mix positional and keyword arguments. All your
 
185
   selectors must either be named, or all be unnamed.
 
186
 
172
187
   *version* can be set to one of:
173
188
 
174
189
   ``'clean'``