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=('i',)+tuple(sections)
def __init__(self, blocks, encoding=None): tname, args, section = blocks[0] self.encoding = encoding self.section = section.blocks args = parse_params(args, type='', expr='') self.__name__, self.expr = name_param(args, 'raise', 1, attr='type')
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=('i',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, 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, args): args = parse_params(args, name='', expr='', type=None, column=None, multiple=1, optional=1, op=None) name,expr = name_param(args,'sqlvar',1) if expr is None: expr=name else: expr=expr.eval self.__name__, self.expr = name, expr self.args=args if not args.has_key('type'): raise ParseError, ('the type attribute is required', 'sqltest') self.type=t=args['type'] if not valid_type(t): raise ParseError, ('invalid type, %s' % t, 'sqltest') if args.has_key('optional'): self.optional=args['optional'] if args.has_key('multiple'): self.multiple=args['multiple'] if args.has_key('column'): self.column=args['column'] elif self.__name__ is None: err = ' the column attribute is required if an expression is used' raise ParseError, (err, 'sqltest') else: self.column=self.__name__ # Deal with optional operator specification op = '=' # Default if args.has_key('op'): op = args['op'] # Try to get it from the chart, otherwise use the one provided op = comparison_operators.get(op, op) self.op = op
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 = ('i', cond, None, section.blocks)
def __init__(self, blocks): tname, args, section = blocks[0] args = parse_params( args, name=None, expr=None, nowrap=1, expand=None, leaves=None, header=None, footer=None, branches=None, branches_expr=None, sort=None, reverse=1, skip_unauthorized=1, id=None, single=1, url=None, # opened_decoration=None, # closed_decoration=None, # childless_decoration=None, assume_children=1, urlparam=None, prefix=None) has_key = args.has_key if has_key('') or has_key('name') or has_key('expr'): name, expr = name_param(args, 'tree', 1) if expr is not None: args['expr'] = expr elif has_key(''): args['name'] = name else: name = 'a tree tag' if has_key('branches_expr'): if has_key('branches'): raise ParseError, _tm('branches and and branches_expr given', 'tree') args['branches_expr'] = Eval(args['branches_expr']).eval elif not has_key('branches'): args['branches'] = 'tpValues' if not has_key('id'): args['id'] = 'tpId' if not has_key('url'): args['url'] = 'tpURL' if not has_key('childless_decoration'): args['childless_decoration'] = '' prefix = args.get('prefix') if prefix and not simple_name(prefix): raise ParseError, _tm('prefix is not a simple name', 'tree') self.__name__ = name self.section = section.blocks self.args = args
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)
def __init__(self, blocks): tname, args, section = blocks[0] args = parse_params(args, name=None, expr=None, nowrap=1, expand=None, leaves=None, header=None, footer=None, branches=None, branches_expr=None, sort=None, reverse=1, skip_unauthorized=1, id=None, single=1, url=None, # opened_decoration=None, # closed_decoration=None, # childless_decoration=None, assume_children=1, urlparam=None, prefix=None) has_key = args.has_key if has_key('') or has_key('name') or has_key('expr'): name, expr = name_param(args,'tree',1) if expr is not None: args['expr'] = expr elif has_key(''): args['name'] = name else: name='a tree tag' if has_key('branches_expr'): if has_key('branches'): raise ParseError, _tm( 'branches and and branches_expr given', 'tree') args['branches_expr'] = Eval(args['branches_expr']).eval elif not has_key('branches'): args['branches']='tpValues' if not has_key('id'): args['id'] = 'tpId' if not has_key('url'): args['url'] = 'tpURL' if not has_key('childless_decoration'): args['childless_decoration']='' prefix = args.get('prefix') if prefix and not simple_name(prefix): raise ParseError, _tm( 'prefix is not a simple name', 'tree') self.__name__ = name self.section = section.blocks self.args = args
def __init__(self, args, encoding=None): 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) self.encoding = encoding
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, encoding=None): tname, args, section = blocks[0] args = parse_params(args, name='', expr='') name, expr = name_param(args, 'if', 1) self.__name__ = name self.encoding = encoding 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 = ('i', ) + tuple(sections)
def __init__(self, args, fmt='s', encoding=None): 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.encoding = encoding self.modifiers = tuple( map( lambda t: t[1], filter(lambda m, args=args, used=args.__contains__: 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 'html_quote' in args: if expr is None: expr = name else: expr = expr.eval self.simple_form = ('v', expr, 'h')
def __init__(self, args): args = parse_params(args, name='', expr='', type=None, optional=1) name,expr=name_param(args,'sqlvar',1) if expr is None: expr=name else: expr=expr.eval self.__name__, self.expr = name, expr self.args=args if not args.has_key('type'): raise ParseError('the type attribute is required', 'dtvar') t=args['type'] if not valid_type(t): raise ParseError('invalid type, %s' % t, 'dtvar')
def __init__(self, args): args = parse_params(args, name='', expr='', type=None, optional=1) name, expr = name_param(args, 'ldifvar', 1) if expr is None: expr = name else: expr = expr.eval self.__name__, self.expr = name, expr self.args = args if not args.has_key('type'): raise ParseError, ('the type attribute is required', 'dtvar') t = args['type'] if not valid_type(t): raise ParseError, ('invalid type, %s' % t, 'dtvar')
def __init__(self, blocks, encoding=None): 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.encoding = encoding self.section = section.blocks if 'mapping' in args and args['mapping']: self.mapping = 1 if 'only' in args and args['only']: self.only = 1
def __init__(self, args): args = parse_params(args, name="", expr="", type=None, optional=1) name, expr = name_param(args, "sqlvar", 1) if expr is None: expr = name else: expr = expr.eval self.__name__, self.expr = name, expr self.args = args if not args.has_key("type"): raise ParseError, ("the type attribute is required", "dtvar") t = args["type"] if not valid_type(t): raise ParseError, ("invalid type, %s" % t, "dtvar")
def __init__(self, args): args = parse_params(args, name='', expr='', null='', tex_quote=1, format_maps='') name, expr = name_param(args, 'texvar', 1) if expr is None: expr = name else: expr = expr.eval self.__name__ = name self.expr = expr self.args = args
def __init__(self, args, encoding=None): self.encoding = encoding args = parse_params(args, name='', expr='', type=None, optional=1) name, expr = name_param(args, 'sqlvar', 1) if expr is None: expr = name else: expr = expr.eval self.__name__, self.expr = name, expr self.args = args if 'type' not in args: raise ParseError('the type attribute is required', 'dtvar') t = args['type'] if t not in valid_types: raise ParseError('invalid type, %s' % t, 'dtvar')
def __init__(self, args, encoding=None): self.encoding = encoding args = parse_params(args, name='', expr='', type=None, column=None, multiple=1, optional=1, op=None) name, expr = name_param(args, 'sqlvar', 1) if expr is None: expr = name else: expr = expr.eval self.__name__, self.expr = name, expr self.args = args if 'type' not in args: raise ParseError('the type attribute is required', 'sqltest') self.type = t = args['type'] if t not in valid_types: raise ParseError('invalid type, %s' % t, 'sqltest') if 'optional' in args: self.optional = args['optional'] if 'multiple' in args: self.multiple = args['multiple'] if 'column' in args: self.column = args['column'] elif self.__name__ is None: err = ' the column attribute is required if an expression is used' raise ParseError(err, 'sqltest') else: self.column = self.__name__ # Deal with optional operator specification op = '=' # Default if 'op' in args: op = args['op'] # Try to get it from the chart, otherwise use the one provided op = comparison_operators.get(op, op) self.op = op
def __init__(self, args): args = parse_params(args, name="", expr="", type=None, column=None, multiple=1, optional=1, op=None) name, expr = name_param(args, "sqlvar", 1) if expr is None: expr = name else: expr = expr.eval self.__name__, self.expr = name, expr self.args = args if not args.has_key("type"): raise ParseError, ("the type attribute is required", "sqltest") self.type = t = args["type"] if not valid_type(t): raise ParseError, ("invalid type, %s" % t, "sqltest") if args.has_key("optional"): self.optional = args["optional"] if args.has_key("multiple"): self.multiple = args["multiple"] if args.has_key("column"): self.column = args["column"] elif self.__name__ is None: err = " the column attribute is required if an expression is used" raise ParseError, (err, "sqltest") else: self.column = self.__name__ # Deal with optional operator specification op = "=" # Default if args.has_key("op"): op = args["op"] # Try to get it from the chart, otherwise use the one provided op = comparison_operators.get(op, op) self.op = op
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 if 'sort' in args: self.sort = sort = args['sort'] if sort == 'sequence-item': self.sort = '' if 'sort_expr' in args: self.sort_expr = Eval(args['sort_expr']) if 'reverse_expr' in args: self.reverse_expr = Eval(args['reverse_expr']) if 'reverse' in args: self.reverse = args['reverse'] if 'no_push_item' in args: self.no_push_item = args['no_push_item'] if 'mapping' in args: self.mapping = args['mapping'] for n in 'start', 'size', 'end': if n in args: self.batch = 1 prefix = args.get('prefix') if prefix and not simple_name(prefix): raise ParseError('prefix is not a simple name', 'in') for n in ('orphan', 'overlap', 'previous', 'next'): if n in args 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 'start' in args: v = args['start'] if isinstance(v, str): try: int(v) except Exception: 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] 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, encoding=None): args = parse_params(args, name='', expr='') name, expr = name_param(args, 'var', 1) self.__name__ = name self.expr = expr self.encoding = encoding
def __init__(self, args): args = parse_params(args, name='', expr='') name, expr = name_param(args, 'var', 1) self.__name__ = name self.expr = expr