How to use the diazo.utils.split_params function in diazo

To help you get started, we’ve selected a few diazo examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github plone / diazo / lib / diazo / run.py View on Github external
if options.trace:
        logger.setLevel(logging.DEBUG)

    runtrace = False
    if options.runtrace_xml or options.runtrace_html:
        runtrace = True

    parser = etree.HTMLParser()
    parser.resolvers.add(RunResolver(os.path.dirname(content)))

    if options.xsl is not None:
        output_xslt = etree.parse(options.xsl)
    else:
        xsl_params = None
        if options.xsl_params:
            xsl_params = split_params(options.xsl_params)

        output_xslt = compile_theme(
            rules=options.rules,
            theme=options.theme,
            extra=options.extra,
            parser=parser,
            read_network=options.read_network,
            absolute_prefix=options.absolute_prefix,
            includemode=options.includemode,
            indent=options.pretty_print,
            xsl_params=xsl_params,
            runtrace=runtrace,
        )

    if content == '-':
        content = sys.stdin
github plone / diazo / lib / diazo / run.py View on Github external
if content == '-':
        content = sys.stdin

    if options.read_network:
        access_control = AC_READ_NET
    else:
        access_control = AC_READ_FILE

    transform = etree.XSLT(output_xslt, access_control=access_control)
    content_doc = etree.parse(content, parser=parser)
    params = {}
    if options.path is not None:
        params['path'] = "'{path}'".format(path=options.path)

    if options.parameters:
        for key, value in split_params(options.parameters).items():
            params[key] = quote_param(value)

    output_html = transform(content_doc, **params)
    if isinstance(options.output, string_types):
        out = open(options.output, 'wt')
    else:
        out = options.output
    out.write(str(output_html))

    if runtrace:
        runtrace_doc = diazo.runtrace.generate_runtrace(
            rules=options.rules,
            error_log=transform.error_log,
        )
        if options.runtrace_xml:
            if options.runtrace_xml == '-':
github plone / diazo / lib / diazo / compiler.py View on Github external
if options.rules is None:
        if len(args) == 2 and options.theme is None:
            options.rules, options.theme = args
        elif len(args) == 1:
            options.rules, = args
        else:
            parser.error('Wrong number of arguments.')
    elif args:
        parser.error('Wrong number of arguments.')

    if options.trace:
        logger.setLevel(logging.DEBUG)

    xsl_params = None
    if options.xsl_params:
        xsl_params = split_params(options.xsl_params)

    output_xslt = compile_theme(
        rules=options.rules,
        theme=options.theme,
        extra=options.extra,
        trace=options.trace,
        absolute_prefix=options.absolute_prefix,
        includemode=options.includemode,
        read_network=options.read_network,
        xsl_params=xsl_params,
    )
    root = output_xslt.getroot()
    if not root.tail:
        root.tail = '\n'
    output_xslt.write(
        options.output,