def __init__(self, context, args): args = parse_params(args, name='', expr='') name, expr = name_param(context, args, 'call', 1) if expr is None: expr = name else: expr = expr.eval self.simple_form = expr, None
def __init__(self, context, blocks): tname, args, section = blocks[0] self.section = section.blocks args = parse_params(args, type='', expr='') self.__name__, self.expr = name_param(context, args, 'raise', 1, attr='type')
def __init__(self, context, blocks): tname, args, section = blocks[0] args = parse_params(args, name='', expr='') name, expr = name_param(context, args, 'unless', 1) if expr is None: cond = name else: cond = expr.eval self.simple_form = (cond, None, section.blocks)
def __init__(self, context, blocks): tname, args, section = blocks[0] args = parse_params(args, name='', expr='') name, expr = name_param(context, args, 'if', 1) self.__name__ = name if expr is None: cond = name else: cond = expr.eval sections = [cond, section.blocks] if blocks[-1][0] == 'else': tname, args, section = blocks[-1] del blocks[-1] args = parse_params(args, name='') if args: ename, expr = name_param(context, args, 'else', 1) if ename != name: raise ParseError, ('name in else does not match if', 'in') elses = section.blocks else: elses = None for tname, args, section in blocks[1:]: if tname == 'else': raise ParseError, ( 'more than one else tag for a single if tag', 'in') args = parse_params(args, name='', expr='') name, expr = name_param(context, args, 'elif', 1) if expr is None: cond = name else: cond = expr.eval sections.append(cond) sections.append(section.blocks) if elses is not None: sections.append(elses) self.simple_form = tuple(sections)
def __init__(self, context, blocks): tname, args, section = blocks[0] args = parse_params(args, name='', expr='', mapping=1, only=1) name, expr = name_param(context, args, 'with', 1) if expr is None: expr = name else: expr = expr.eval self.__name__, self.expr = name, expr self.section = section.blocks if args.has_key('mapping') and args['mapping']: self.mapping = 1 if args.has_key('only') and args['only']: self.only = 1
def __init__(self, context, args, fmt='s'): if args[:4] == 'var ': args = args[4:] args = parse_params(args, name='', lower=1, upper=1, expr='', capitalize=1, spacify=1, null='', fmt='s', size=0, etc='...', thousands_commas=1, html_quote=1, url_quote=1, sql_quote=1, url_quote_plus=1, missing='', newline_to_br=1, url=1) self.args = args self.modifiers = tuple( map( lambda t: t[1], filter(lambda m, args=args, used=args.has_key: used(m[0]) and args[m[0]], modifiers))) name, expr = name_param(context, args, 'var', 1) self.__name__, self.expr = name, expr self.fmt = fmt if len(args) == 1 and fmt == 's': if expr is None: expr = name else: expr = expr.eval self.simple_form = expr,
def __init__(self, context, blocks): tname, args, section = blocks[0] args=parse_params(args, name='', start='1',end='-1',size='10', orphan='3',overlap='1',mapping=1, skip_unauthorized=1, previous=1, next=1, expr='', sort='', reverse=1, sort_expr='', reverse_expr='') self.args=args has_key=args.has_key if has_key('sort'): self.sort=sort=args['sort'] if sort=='sequence-item': self.sort='' if has_key('sort_expr'): self.sort_expr = Eval(context, args['sort_expr']) if has_key('reverse_expr'): self.reverse_expr = Eval(context, args['reverse_expr']) if has_key('reverse'): self.reverse = args['reverse'] if has_key('mapping'): self.mapping = args['mapping'] for n in 'start', 'size', 'end': if has_key(n): self.batch=1 for n in 'orphan','overlap','previous','next': if has_key(n) and not self.batch: raise ParseError, ( """ The %s attribute was used but neither of the <code>start</code>, <code>end</code>, or <code>size</code> attributes were used. """ % n, 'in') if has_key('start'): v = args['start'] if isinstance(v, str): try: v.atoi() except: self.start_name_re = re.compile( '&+'+ ''.join(map(lambda c: "[%s]" % c, v))+ '=[0-9]+&+') name, expr = name_param(context, args, 'in', 1) if expr is not None: expr = expr.eval self.__name__, self.expr = name, expr self.section = section.blocks if len(blocks) > 1: if len(blocks) != 2: raise ParseError, ( 'too many else blocks', 'in') tname, args, section = blocks[1] args=parse_params(args, name='') if args: ename = name_param(context, args) if ename != name: raise ParseError, ( 'name in else does not match in', 'in') self.elses = section.blocks
def __init__(self, context, args): args = parse_params(args, name='', expr='') name, expr = name_param(context, args, 'var', 1) self.__name__, self.expr = name, expr