示例#1
0
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
示例#2
0
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
示例#3
0
    def testGetBoolean(self):
        tests = [
            # default testing for None value
            (None, None, None, None),
            (None, None, False, False),
            (None, None, True, True),

            # some real values
            ('0', None, None, False),
            ('1', None, None, True),
            ('false', None, None, False),
            ('true', None, None, True),
            ('FALSE', None, None, False),
            ('TRUE', None, None, True),
            ('no', None, None, False),
            ('yes', None, None, True),
            ('NO', None, None, False),
            ('YES', None, None, True),
        ]
        for arg, name, default, expected in tests:
            assert paramparser.get_bool(arg, name, default) == expected