Ejemplo n.º 1
0
    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)
Ejemplo n.º 2
0
 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)
Ejemplo n.º 3
0
 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)
Ejemplo n.º 4
0
    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')
Ejemplo n.º 5
0
    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')
Ejemplo n.º 6
0
    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
Ejemplo n.º 7
0
    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
Ejemplo n.º 8
0
 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)
Ejemplo n.º 9
0
    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
Ejemplo n.º 10
0
 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
Ejemplo n.º 11
0
    def __init__(self, blocks):

        self.blocks=blocks
        tname, args, section = blocks[0]
        self.__name__="%s %s" % (tname, args)
        args = parse_params(args, required=1, where=1)
        if args.has_key(''): args[args['']]=1
        if args.has_key('required'): self.required=args['required']
        if args.has_key('where'): self.where=args['where']
Ejemplo n.º 12
0
 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
Ejemplo n.º 13
0
 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
Ejemplo n.º 14
0
    def __init__(self, blocks, encoding=None):
        self.encoding = encoding
        tname, args, section = blocks[0]
        args = parse_params(args,
                            mailhost=None,
                            mailto=None,
                            mailfrom=None,
                            subject=None,
                            smtphost=None,
                            port='25',
                            encode=None)

        smtphost = None

        if 'mailhost' in args:
            mailhost = args['mailhost']
        elif 'smtphost' in args:
            mailhost = smtphost = args['smtphost']
        elif '' in args:
            mailhost = args['mailhost'] = args['']
        else:
            raise MailHostError('No mailhost was specified in tag')

        for key in ('mailto', 'mailfrom', 'subject', 'port'):
            if key not in args:
                args[key] = ''

        if 'encode' in args:
            encoding = args['encode']
            if encoding not in ('base64', 'quoted-printable'):
                raise MailHostError(
                    'An unsupported encoding, "%s" was specified in tag' %
                    encoding)

        if not smtphost:
            self.__name__ = self.mailhost = mailhost
            self.smtphost = None
        else:
            self.__name__ = self.smtphost = smtphost
            self.mailhost = None
        self.section = section
        self.args = args
        self.mailto = args['mailto']
        self.mailfrom = args['mailfrom']
        self.subject = None or args['subject']
        if args['port'] and isinstance(args['port'], str):
            self.port = args['port'] = int(args['port'])
        elif args['port'] == '':
            self.port = args['port'] = 25
        else:
            self.port = args['port']
        if 'encode' in args:
            self.encode = args['encode']
        else:
            self.encode = None
Ejemplo n.º 15
0
    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)
Ejemplo n.º 16
0
    def __init__(self, blocks):
        tname, args, section = blocks[0]
        args = parse_params(args,
                            mailhost=None,
                            mailto=None,
                            mailfrom=None,
                            subject=None,
                            smtphost=None,
                            port='25',
                            encode=None)

        smtphost = None

        has_key = args.has_key
        if has_key('mailhost'):
            mailhost = args['mailhost']
        elif has_key('smtphost'):
            mailhost = smtphost = args['smtphost']
        elif has_key(''):
            mailhost = args['mailhost'] = args['']
        else:
            raise MailHostError('No mailhost was specified in tag')

        for key in ('mailto', 'mailfrom', 'subject', 'port'):
            if not key in args:
                args[key] = ''

        if has_key('encode') and args['encode'] not in \
        ('base64', 'quoted-printable', 'uuencode', 'x-uuencode',
         'uue', 'x-uue'):
            raise MailHostError('An unsupported encoding was specified in tag')

        if not smtphost:
            self.__name__ = self.mailhost = mailhost
            self.smtphost = None
        else:
            self.__name__ = self.smtphost = smtphost
            self.mailhost = None
        self.section = section
        self.args = args
        self.mailto = args['mailto']
        self.mailfrom = args['mailfrom']
        self.subject = None or args['subject']
        if args['port'] and type(args['port']) is type('s'):
            self.port = args['port'] = int(args['port'])
        elif args['port'] == '':
            self.port = args['port'] = 25
        else:
            self.port = args['port']
        if has_key('encode'):
            self.encode = args['encode']
        else:
            self.encode = None
Ejemplo n.º 17
0
    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')
Ejemplo n.º 18
0
    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')
Ejemplo n.º 19
0
    def __init__(self, blocks, encoding=None):
        self.encoding = encoding
        tname, args, section = blocks[0]
        args = parse_params(args, mailhost=None, mailto=None, mailfrom=None,
                            subject=None, smtphost=None, port='25',
                            encode=None)

        smtphost = None

        if 'mailhost' in args:
            mailhost = args['mailhost']
        elif 'smtphost' in args:
            mailhost = smtphost = args['smtphost']
        elif '' in args:
            mailhost = args['mailhost'] = args['']
        else:
            raise MailHostError('No mailhost was specified in tag')

        for key in ('mailto', 'mailfrom', 'subject', 'port'):
            if key not in args:
                args[key] = ''

        if 'encode' in args:
            encoding = args['encode']
            if encoding not in ('base64', 'quoted-printable'):
                raise MailHostError(
                    'An unsupported encoding, "%s" was specified in tag'
                    % encoding)

        if not smtphost:
            self.__name__ = self.mailhost = mailhost
            self.smtphost = None
        else:
            self.__name__ = self.smtphost = smtphost
            self.mailhost = None
        self.section = section
        self.args = args
        self.mailto = args['mailto']
        self.mailfrom = args['mailfrom']
        self.subject = None or args['subject']
        if args['port'] and isinstance(args['port'], str):
            self.port = args['port'] = int(args['port'])
        elif args['port'] == '':
            self.port = args['port'] = 25
        else:
            self.port = args['port']
        if 'encode' in args:
            self.encode = args['encode']
        else:
            self.encode = None
Ejemplo n.º 20
0
    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')
Ejemplo n.º 21
0
    def __init__(self, blocks):
        tname, args, section=blocks[0]
        args=parse_params(args, mailhost=None, mailto=None, mailfrom=None,
                          subject=None, smtphost=None, port='25',
                          encode=None)

        smtphost=None

        has_key=args.has_key
        if has_key('mailhost'):
            mailhost = args['mailhost']
        elif has_key('smtphost'):
            mailhost = smtphost = args['smtphost']
        elif has_key(''):
            mailhost = args['mailhost'] = args['']
        else:
            raise MailHostError('No mailhost was specified in tag')

        for key in ('mailto', 'mailfrom', 'subject', 'port'):
            if not key in args:
                args[key] = ''

        if has_key('encode') and args['encode'] not in \
        ('base64', 'quoted-printable', 'uuencode', 'x-uuencode',
         'uue', 'x-uue'):
            raise MailHostError(
                'An unsupported encoding was specified in tag')

        if not smtphost:
            self.__name__=self.mailhost=mailhost
            self.smtphost=None
        else:
            self.__name__=self.smtphost=smtphost
            self.mailhost=None
        self.section=section
        self.args=args
        self.mailto=args['mailto']
        self.mailfrom=args['mailfrom']
        self.subject=None or args['subject']
        if args['port'] and type(args['port']) is type('s'):
            self.port=args['port']=int(args['port'])
        elif args['port']=='':
            self.port=args['port']=25
        else:
            self.port=args['port']
        if has_key('encode'):
            self.encode=args['encode']
        else:
            self.encode=None
Ejemplo n.º 22
0
    def __init__(self, blocks):
        tname, args, section = blocks[0]
        self.section = section.blocks

        args = parse_params(args, lang=None, lang_expr=None, verbatim=1, catalog=None, data=None)

        self.lang = name_or_expr(args, "lang", "lang_expr", None)

        self.verbatim = args.get("", None) == "verbatim" or args.get("verbatim", None)

        self.catalog = args.get("catalog", None)

        self.data = args.get("data", None)
        if self.data is not None:
            self.data = Eval(self.data)
Ejemplo n.º 23
0
 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
Ejemplo n.º 24
0
    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")
Ejemplo n.º 25
0
 def __init__(self, blocks, encoding=None):
     self.encoding = encoding
     self.blocks = blocks
     tname, args, section = blocks[0]
     self.__name__ = '%s %s' % (tname, args)
     args = parse_params(args, required=1, where=1, set=1, noparens=1)
     if '' in args:
         args[args['']] = 1
     if 'required' in args:
         self.required = args['required']
     if 'where' in args:
         self.where = args['where']
     if 'set' in args:
         self.set = args['set']
     if 'noparens' in args:
         self.noparens = args['noparens']
Ejemplo n.º 26
0
    def __init__(self, blocks):

        self.blocks = blocks
        tname, args, section = blocks[0]
        self.__name__ = "%s %s" % (tname, args)
        args = parse_params(args, required=1, where=1, set=1, noparens=1)
        if args.has_key(''):
            args[args['']] = 1
        if args.has_key('required'):
            self.required = args['required']
        if args.has_key('where'):
            self.where = args['where']
        if args.has_key('set'):
            self.set = args['set']
        if args.has_key('noparens'):
            self.noparens = args['noparens']
Ejemplo n.º 27
0
 def __init__(self, blocks, encoding=None):
     self.encoding = encoding
     self.blocks = blocks
     tname, args, section = blocks[0]
     self.__name__ = '%s %s' % (tname, args)
     args = parse_params(args, required=1, where=1, set=1, noparens=1)
     if '' in args:
         args[args['']] = 1
     if 'required' in args:
         self.required = args['required']
     if 'where' in args:
         self.where = args['where']
     if 'set' in args:
         self.set = args['set']
     if 'noparens' in args:
         self.noparens = args['noparens']
Ejemplo n.º 28
0
    def __init__(self, blocks, encoding=None):
        tname, args, section = blocks[0]

        self.args = parse_params(args)
        self.section = section.blocks
        self.encoding = encoding

        # Find out if this is a try..finally type
        if len(blocks) == 2 and blocks[1][0] == 'finally':
            self.finallyBlock = blocks[1][2].blocks

        # This is a try [except]* [else] block.
        else:
            # store handlers as tuples (name,block)
            self.handlers = []
            defaultHandlerFound = 0

            for tname, nargs, nsection in blocks[1:]:
                if tname == 'else':
                    if self.elseBlock is not None:
                        raise ParseError(
                            'No more than one else block is allowed',
                            self.name)
                    self.elseBlock = nsection.blocks

                elif tname == 'finally':
                    raise ParseError(
                        'A try..finally combination cannot contain '
                        'any other else, except or finally blocks',
                        self.name)

                else:
                    if self.elseBlock is not None:
                        raise ParseError(
                            'The else block should be the last block '
                            'in a try tag', self.name)

                    for errname in nargs.split():
                        self.handlers.append((errname, nsection.blocks))
                    if nargs.strip() == '':
                        if defaultHandlerFound:
                            raise ParseError(
                                'Only one default exception handler '
                                'is allowed', self.name)
                        else:
                            defaultHandlerFound = 1
                            self.handlers.append(('', nsection.blocks))
Ejemplo n.º 29
0
    def __init__(self, blocks, encoding=None):
        tname, args, section = blocks[0]

        self.args = parse_params(args)
        self.section = section.blocks
        self.encoding = encoding

        # Find out if this is a try..finally type
        if len(blocks) == 2 and blocks[1][0] == 'finally':
            self.finallyBlock = blocks[1][2].blocks

        # This is a try [except]* [else] block.
        else:
            # store handlers as tuples (name,block)
            self.handlers = []
            defaultHandlerFound = 0

            for tname, nargs, nsection in blocks[1:]:
                if tname == 'else':
                    if self.elseBlock is not None:
                        raise ParseError(
                            'No more than one else block is allowed',
                            self.name)
                    self.elseBlock = nsection.blocks

                elif tname == 'finally':
                    raise ParseError(
                        'A try..finally combination cannot contain '
                        'any other else, except or finally blocks', self.name)

                else:
                    if self.elseBlock is not None:
                        raise ParseError(
                            'The else block should be the last block '
                            'in a try tag', self.name)

                    for errname in nargs.split():
                        self.handlers.append((errname, nsection.blocks))
                    if nargs.strip() == '':
                        if defaultHandlerFound:
                            raise ParseError(
                                'Only one default exception handler '
                                'is allowed', self.name)
                        else:
                            defaultHandlerFound = 1
                            self.handlers.append(('', nsection.blocks))
Ejemplo n.º 30
0
    def __init__(self, blocks):
        tname, args, section = blocks[0]
        self.section = section.blocks

        args = parse_params(args, lang=None, lang_expr=None, verbatim=1,
                            catalog=None, data=None)

        self.lang = name_or_expr(args, 'lang', 'lang_expr', None)

        self.verbatim = args.get('', None) == 'verbatim' \
                        or args.get('verbatim', None)

        self.catalog = args.get('catalog', None)

        self.data = args.get('data', None)
        if self.data is not None:
            self.data = Eval(self.data)
Ejemplo n.º 31
0
    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
Ejemplo n.º 32
0
    def __init__(self, blocks):
        tname, args, section = blocks[0]
        self.section = section.blocks

        args = parse_params(args, lang=None, lang_expr=None, verbatim=1,
                            catalog=None, data=None)

        self.lang = name_or_expr(args, 'lang', 'lang_expr', None)

        self.verbatim = args.get('', None) == 'verbatim' \
                        or args.get('verbatim', None)

        self.catalog = args.get('catalog', None)

        self.data = args.get('data', None)
        if self.data is not None:
            self.data = Eval(self.data)
Ejemplo n.º 33
0
    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')
Ejemplo n.º 34
0
    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
Ejemplo n.º 35
0
    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
Ejemplo n.º 36
0
    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
Ejemplo n.º 37
0
    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
Ejemplo n.º 38
0
    def __init__(self, blocks, encoding=None):
        self.encoding = encoding
        self.sections = []
        self.multipart = 'mixed'

        for tname, args, section in blocks:
            if tname == 'mime':
                args = parse_params(args,
                                    type=None,
                                    type_expr=None,
                                    disposition=None,
                                    disposition_expr=None,
                                    encode=None,
                                    encode_expr=None,
                                    name=None,
                                    name_expr=None,
                                    filename=None,
                                    filename_expr=None,
                                    cid=None,
                                    cid_expr=None,
                                    charset=None,
                                    charset_expr=None,
                                    skip_expr=None,
                                    multipart=None)
                self.multipart = args.get('multipart', 'mixed')
            else:
                args = parse_params(args,
                                    type=None,
                                    type_expr=None,
                                    disposition=None,
                                    disposition_expr=None,
                                    encode=None,
                                    encode_expr=None,
                                    name=None,
                                    name_expr=None,
                                    filename=None,
                                    filename_expr=None,
                                    cid=None,
                                    cid_expr=None,
                                    charset=None,
                                    charset_expr=None,
                                    skip_expr=None)

            if 'type_expr' in args:
                if 'type' in args:
                    raise ParseError('dtml-mime: type and type_expr given')
                args['type_expr'] = Eval(args['type_expr'])
            elif 'type' not in args:
                args['type'] = 'application/octet-stream'

            if 'disposition_expr' in args:
                if 'disposition' in args:
                    raise ParseError(
                        'dtml-mime: disposition and disposition_expr given')
                args['disposition_expr'] = Eval(args['disposition_expr'])
            elif 'disposition' not in args:
                args['disposition'] = ''

            if 'encode_expr' in args:
                if 'encode' in args:
                    raise ParseError('dtml-mime: encode and encode_expr given')
                args['encode_expr'] = Eval(args['encode_expr'])
            elif 'encode' not in args:
                args['encode'] = 'base64'

            if 'name_expr' in args:
                if 'name' in args:
                    raise ParseError('dtml-mime: name and name_expr given')
                args['name_expr'] = Eval(args['name_expr'])
            elif 'name' not in args:
                args['name'] = ''

            if 'filename_expr' in args:
                if 'filename' in args:
                    raise ParseError(
                        'dtml-mime: filename and filename_expr given')
                args['filename_expr'] = Eval(args['filename_expr'])
            elif 'filename' not in args:
                args['filename'] = ''

            if 'cid_expr' in args:
                if 'cid' in args:
                    raise ParseError('dtml-mime: cid and cid_expr given')
                args['cid_expr'] = Eval(args['cid_expr'])
            elif 'cid' not in args:
                args['cid'] = ''

            if 'charset_expr' in args:
                if 'charset' in args:
                    raise ParseError(
                        'dtml-mime: charset and charset_expr given')
                args['charset_expr'] = Eval(args['charset_expr'])
            elif 'charset' not in args:
                args['charset'] = 'us-ascii'  # Default for text parts

            if 'skip_expr' in args:
                args['skip_expr'] = Eval(args['skip_expr'])

            if args['encode'] not in ENCODINGS:
                raise MIMEError('An unsupported encoding was specified in tag')

            self.sections.append((args, section.blocks))
Ejemplo n.º 39
0
    def __init__(self, blocks):
        self.sections = []
        self.multipart = "mixed"

        for tname, args, section in blocks:
            if tname == "mime":
                args = parse_params(
                    args,
                    type=None,
                    type_expr=None,
                    disposition=None,
                    disposition_expr=None,
                    encode=None,
                    encode_expr=None,
                    name=None,
                    name_expr=None,
                    filename=None,
                    filename_expr=None,
                    cid=None,
                    cid_expr=None,
                    charset=None,
                    charset_expr=None,
                    skip_expr=None,
                    multipart=None,
                )
                self.multipart = args.get("multipart", "mixed")
            else:
                args = parse_params(
                    args,
                    type=None,
                    type_expr=None,
                    disposition=None,
                    disposition_expr=None,
                    encode=None,
                    encode_expr=None,
                    name=None,
                    name_expr=None,
                    filename=None,
                    filename_expr=None,
                    cid=None,
                    cid_expr=None,
                    charset=None,
                    charset_expr=None,
                    skip_expr=None,
                )

            if "type_expr" in args:
                if "type" in args:
                    raise ParseError(_tm("type and type_expr given", "mime"))
                args["type_expr"] = Eval(args["type_expr"])
            elif "type" not in args:
                args["type"] = "application/octet-stream"

            if "disposition_expr" in args:
                if "disposition" in args:
                    raise ParseError(_tm("disposition and disposition_expr given", "mime"))
                args["disposition_expr"] = Eval(args["disposition_expr"])
            elif "disposition" not in args:
                args["disposition"] = ""

            if "encode_expr" in args:
                if "encode" in args:
                    raise ParseError(_tm("encode and encode_expr given", "mime"))
                args["encode_expr"] = Eval(args["encode_expr"])
            elif "encode" not in args:
                args["encode"] = "base64"

            if "name_expr" in args:
                if "name" in args:
                    raise ParseError(_tm("name and name_expr given", "mime"))
                args["name_expr"] = Eval(args["name_expr"])
            elif "name" not in args:
                args["name"] = ""

            if "filename_expr" in args:
                if "filename" in args:
                    raise ParseError(_tm("filename and filename_expr given", "mime"))
                args["filename_expr"] = Eval(args["filename_expr"])
            elif "filename" not in args:
                args["filename"] = ""

            if "cid_expr" in args:
                if "cid" in args:
                    raise ParseError(_tm("cid and cid_expr given", "mime"))
                args["cid_expr"] = Eval(args["cid_expr"])
            elif "cid" not in args:
                args["cid"] = ""

            if "charset_expr" in args:
                if "charset" in args:
                    raise ParseError(_tm("charset and charset_expr given", "mime"))
                args["charset_expr"] = Eval(args["charset_expr"])
            elif "charset" not in args:
                args["charset"] = ""

            if "skip_expr" in args:
                args["skip_expr"] = Eval(args["skip_expr"])

            if args["encode"] not in ENCODINGS:
                raise MIMEError("An unsupported encoding was specified in tag")

            self.sections.append((args, section.blocks))
Ejemplo n.º 40
0
 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
Ejemplo n.º 41
0
    def __init__(self, blocks, encoding=None):
        self.encoding = encoding
        self.sections = []
        self.multipart = 'mixed'

        for tname, args, section in blocks:
            if tname == 'mime':
                args = parse_params(args, type=None, type_expr=None,
                                    disposition=None, disposition_expr=None,
                                    encode=None, encode_expr=None, name=None,
                                    name_expr=None, filename=None,
                                    filename_expr=None, cid=None,
                                    cid_expr=None, charset=None,
                                    charset_expr=None, skip_expr=None,
                                    multipart=None)
                self.multipart = args.get('multipart', 'mixed')
            else:
                args = parse_params(args, type=None, type_expr=None,
                                    disposition=None, disposition_expr=None,
                                    encode=None, encode_expr=None, name=None,
                                    name_expr=None, filename=None,
                                    filename_expr=None, cid=None,
                                    cid_expr=None, charset=None,
                                    charset_expr=None, skip_expr=None)

            if 'type_expr' in args:
                if 'type' in args:
                    raise ParseError('dtml-mime: type and type_expr given')
                args['type_expr'] = Eval(args['type_expr'])
            elif 'type' not in args:
                args['type'] = 'application/octet-stream'

            if 'disposition_expr' in args:
                if 'disposition' in args:
                    raise ParseError(
                        'dtml-mime: disposition and disposition_expr given')
                args['disposition_expr'] = Eval(args['disposition_expr'])
            elif 'disposition' not in args:
                args['disposition'] = ''

            if 'encode_expr' in args:
                if 'encode' in args:
                    raise ParseError('dtml-mime: encode and encode_expr given')
                args['encode_expr'] = Eval(args['encode_expr'])
            elif 'encode' not in args:
                args['encode'] = 'base64'

            if 'name_expr' in args:
                if 'name' in args:
                    raise ParseError('dtml-mime: name and name_expr given')
                args['name_expr'] = Eval(args['name_expr'])
            elif 'name' not in args:
                args['name'] = ''

            if 'filename_expr' in args:
                if 'filename' in args:
                    raise ParseError(
                        'dtml-mime: filename and filename_expr given')
                args['filename_expr'] = Eval(args['filename_expr'])
            elif 'filename' not in args:
                args['filename'] = ''

            if 'cid_expr' in args:
                if 'cid' in args:
                    raise ParseError('dtml-mime: cid and cid_expr given')
                args['cid_expr'] = Eval(args['cid_expr'])
            elif 'cid' not in args:
                args['cid'] = ''

            if 'charset_expr' in args:
                if 'charset' in args:
                    raise ParseError(
                        'dtml-mime: charset and charset_expr given')
                args['charset_expr'] = Eval(args['charset_expr'])
            elif 'charset' not in args:
                args['charset'] = 'us-ascii'  # Default for text parts

            if 'skip_expr' in args:
                args['skip_expr'] = Eval(args['skip_expr'])

            if args['encode'] not in ENCODINGS:
                raise MIMEError('An unsupported encoding was specified in tag')

            self.sections.append((args, section.blocks))
Ejemplo n.º 42
0
 def __init__(self, args):
     args = parse_params(args, name='', expr='')
     name, expr = name_param(args, 'var', 1)
     self.__name__ = name
     self.expr = expr