def parseargs(args, defpagename, defyear, defmonth, defoffset, defheight6, defanniversary): """ parse macro arguments """ _, args, _ = paramparser.parse_quoted_separated(args) parmpagename = paramparser.get_str(args.get('item'), 'item', defpagename) parmyear = paramparser.get_int(args.get('year'), 'year', defyear) parmmonth = paramparser.get_int(args.get('month'), 'month', defmonth) parmoffset = paramparser.get_int(args.get('month_offset'), 'month_offset', defoffset) parmheight6 = paramparser.get_bool(args.get('fixed_height'), 'fixed_height', defheight6) parmanniversary = paramparser.get_bool(args.get('anniversary'), 'anniversary', defanniversary) # multiple pagenames separated by "*" - split into list of pagenames parmpagename = re.split(r'\*', parmpagename) return parmpagename, parmyear, parmmonth, parmoffset, parmheight6, parmanniversary
def parseargs_legacy(args, defpagename, defyear, defmonth, defoffset, defoffset2, defheight6, defanniversary, deftemplate): """ Slightly modified parsing function from MonthCalendar.py in moin-1.9 From the moin-1.9 version of the function * the request argument was dropped * get_unicode was changed to get_str """ args = paramparser.parse_quoted_separated(args, name_value=False) args += [None] * 8 # fill up with None to trigger defaults parmpagename, parmyear, parmmonth, parmoffset, parmoffset2, parmheight6, parmanniversary, parmtemplate = args[: 8] parmpagename = paramparser.get_str(parmpagename, 'pagename', defpagename) parmyear = paramparser.get_int(parmyear, 'year', defyear) parmmonth = paramparser.get_int(parmmonth, 'month', defmonth) parmoffset = paramparser.get_int(parmoffset, 'offset', defoffset) parmoffset2 = paramparser.get_int(parmoffset2, 'offset2', defoffset2) parmheight6 = paramparser.get_bool(parmheight6, 'height6', defheight6) parmanniversary = paramparser.get_bool(parmanniversary, 'anniversary', defanniversary) parmtemplate = paramparser.get_str(parmtemplate, 'template', deftemplate) return parmpagename, parmyear, parmmonth, parmoffset, parmoffset2, parmheight6, parmanniversary, parmtemplate
def testGetInt(self): tests = [ # default testing for None value (None, None, None, None), (None, None, -23, -23), (None, None, 42, 42), # some real values ('0', None, None, 0), ('42', None, None, 42), ('-23', None, None, -23), ] for arg, name, default, expected in tests: assert paramparser.get_int(arg, name, default) == expected