1# -*- coding: iso-8859-1 -*- 2""" 3 MoinMoin - Parser Package 4 5 See "plain.py" for the most simple parser that also 6 defines the parser interface. 7 8 @copyright: 2000 Juergen Hermann <jh@web.de> 9 @license: GNU GPL, see COPYING for details. 10""" 11 12from MoinMoin.util import pysupport 13from MoinMoin import wikiutil 14 15modules = pysupport.getPackageModules(__file__) 16 17 18def parse_start_step(request, args): 19 """ 20 Parses common Colorizer parameters start, step, numbers. 21 Uses L{wikiutil.parseAttributes} and sanitizes the results. 22 23 Start and step must be a non negative number and default to 1, 24 numbers might be on, off, or none and defaults to on. On or off 25 means that numbers are switchable via JavaScript (html formatter), 26 disabled means that numbers are disabled completely. 27 28 attrdict is returned as last element in the tuple, to enable the 29 calling parser to extract further arguments. 30 31 @param request: a request instance 32 @param args: the argument string 33 34 @returns: numbers, start, step, attrdict 35 """ 36 nums, start, step = 1, 1, 1 37 attrs, msg = wikiutil.parseAttributes(request, args) 38 if not msg: 39 try: 40 start = int(attrs.get('start', '"1"')[1:-1]) 41 except ValueError: 42 pass 43 try: 44 step = int(attrs.get('step', '"1"')[1:-1]) 45 except ValueError: 46 pass 47 if attrs.get('numbers', '"on"')[1:-1].lower() in ('off', 'false', 'no'): 48 nums = 0 49 elif attrs.get('numbers', '"on"')[1:-1].lower() in ('none', 'disable'): 50 nums = -1 51 return nums, start, step, attrs 52 53