def __init__(self, blocks): tname, args, section = blocks[0] args=parse_params(args, name='', expr='') name,expr=name_param(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(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(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, blocks): tname, args, section = blocks[0] args=parse_params(args, name='', expr='') name,expr=name_param(args,'unless',1) if expr is None: cond=name else: cond=expr.eval self.simple_form=(cond,None,section.blocks)
def __init__(self, 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(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, blocks): tname, args, section = blocks[0] args = parse_params(args, name='', expr='') name, expr = name_param(args, 'unless', 1) if expr is None: cond = name else: cond = expr.eval self.simple_form = (cond, None, section.blocks)
def __init__(self, blocks): tname, args, section = blocks[0] args = parse_params(args, name='', expr='', mapping=1, only=1) name, expr = name_param(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, blocks): tname, args, section = blocks[0] args=parse_params(args, name='', expr='', mapping=1, only=1) name,expr=name_param(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, blocks): tname, args, section = blocks[0] args = parse_params(args, name='', expr='') name, expr = name_param(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(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(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, 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, url_unquote=1, url_unquote_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(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 = ('v', expr) elif len(args) == 2 and fmt == 's' and args.has_key('html_quote'): if expr is None: expr = name else: expr = expr.eval self.simple_form = ('v', expr, 'h')
def __init__(self, blocks): tname, args, section = blocks[0] args=parse_params(args, name='', start='1',end='-1',size='10', orphan='0',overlap='1',mapping=1, no_push_item=1, skip_unauthorized=1, previous=1, next=1, expr='', sort='', reverse=1, sort_expr='', reverse_expr='', prefix='') 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(args['sort_expr']) if has_key('reverse_expr'): self.reverse_expr=Eval(args['reverse_expr']) if has_key('reverse'): self.reverse=args['reverse'] if has_key('no_push_item'): self.no_push_item=args['no_push_item'] if has_key('mapping'): self.mapping=args['mapping'] for n in 'start', 'size', 'end': if has_key(n): self.batch=1 prefix = args.get('prefix') if prefix and not simple_name(prefix): raise ParseError, _tm( 'prefix is not a simple name', 'in') 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 type(v)==type(''): try: int(v) except: self.start_name_re=re.compile( '&+'+ ''.join(["[%s]" % c for c in v])+ '=[0-9]+&+') name,expr=name_param(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(args) if ename != name: raise ParseError, ( 'name in else does not match in', 'in') self.elses=section.blocks
def __init__(self, blocks): tname, args, section = blocks[0] self.section=section.blocks args=parse_params(args, type='', expr='') self.__name__, self.expr = name_param(args, 'raise', 1, attr='type')
def __init__(self, args): args = parse_params(args, name='', expr='') name, expr = name_param(args, 'var', 1) self.__name__, self.expr = name, expr
def __init__(self, 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=VSEval.Eval(args['sort_expr'], expr_globals) if has_key('reverse_expr'): self.reverse_expr=VSEval.Eval(args['reverse_expr'], expr_globals) 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 type(v)==type(''): try: atoi(v) except: self.start_name_re=ts_regex.compile( '&+'+ join(map(lambda c: "[%s]" % c, v),'')+ '=[0-9]+&+') name,expr=name_param(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(args) if ename != name: raise ParseError, ( 'name in else does not match in', 'in') self.elses=section.blocks
def __init__(self, args): args = parse_params(args, name='', expr='') name, expr = name_param(args,'call',1) if expr is None: expr=name else: expr=expr.eval self.simple_form=(expr, None)
def __init__(self, blocks): tname, args, section = blocks[0] args = parse_params(args, name='', start='1', end='-1', size='10', orphan='0', overlap='1', mapping=1, no_push_item=1, skip_unauthorized=1, previous=1, next=1, expr='', sort='', reverse=1, sort_expr='', reverse_expr='', prefix='') 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(args['sort_expr']) if has_key('reverse_expr'): self.reverse_expr = Eval(args['reverse_expr']) if has_key('reverse'): self.reverse = args['reverse'] if has_key('no_push_item'): self.no_push_item = args['no_push_item'] if has_key('mapping'): self.mapping = args['mapping'] for n in 'start', 'size', 'end': if has_key(n): self.batch = 1 prefix = args.get('prefix') if prefix and not simple_name(prefix): raise ParseError, _tm('prefix is not a simple name', 'in') 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 type(v) == type(''): try: int(v) except: self.start_name_re = re.compile( '&+' + ''.join(["[%s]" % c for c in v]) + '=[0-9]+&+') name, expr = name_param(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(args) if ename != name: raise ParseError, ('name in else does not match in', 'in') self.elses = section.blocks
def __init__(self, args): args = parse_params(args, name='', expr='') name, expr = name_param(args,'var',1) self.__name__, self.expr = name, expr
def __init__(self, args): args = parse_params(args, name='', expr='') name, expr = name_param(args, 'call', 1) if expr is None: expr = name else: expr = expr.eval self.simple_form = ('i', expr, None)