示例#1
0
def std_substring(args, ctxt):
    (s, start) = argver(args, [core.string, core.number],
                             reqargs=2, maxargs=3)
    start = int(start) - 1 # XPath is 1-based
    if start < 0: start = 0
    if (len(args)>2):
        span = int(core.number(args[2]))
        if span < 0: span = 0
        return s[start:start+span]
    return s[start:]
示例#2
0
def std_number(args, ctxt):
    "convert argument to a number"
    argver(args, [core.number], reqargs=1, maxargs=1)
    return core.number(args[0])