当前位置: 首页>>代码示例>>Python>>正文


Python compat.exception_as方法代码示例

本文整理汇总了Python中mako.compat.exception_as方法的典型用法代码示例。如果您正苦于以下问题:Python compat.exception_as方法的具体用法?Python compat.exception_as怎么用?Python compat.exception_as使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mako.compat的用法示例。


在下文中一共展示了compat.exception_as方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _include_file

# 需要导入模块: from mako import compat [as 别名]
# 或者: from mako.compat import exception_as [as 别名]
def _include_file(context, uri, calling_uri, **kwargs):
    """locate the template from the given uri and include it in
    the current output."""

    template = _lookup_template(context, uri, calling_uri)
    (callable_, ctx) = _populate_self_namespace(
        context._clean_inheritance_tokens(), template
    )
    kwargs = _kwargs_for_include(callable_, context._data, **kwargs)
    if template.include_error_handler:
        try:
            callable_(ctx, **kwargs)
        except Exception:
            result = template.include_error_handler(ctx, compat.exception_as())
            if not result:
                compat.reraise(*sys.exc_info())
    else:
        callable_(ctx, **kwargs) 
开发者ID:remg427,项目名称:misp42splunk,代码行数:20,代码来源:runtime.py

示例2: _exec_template

# 需要导入模块: from mako import compat [as 别名]
# 或者: from mako.compat import exception_as [as 别名]
def _exec_template(callable_, context, args=None, kwargs=None):
    """execute a rendering callable given the callable, a
    Context, and optional explicit arguments

    the contextual Template will be located if it exists, and
    the error handling options specified on that Template will
    be interpreted here.
    """
    template = context._with_template
    if template is not None and (
        template.format_exceptions or template.error_handler
    ):
        try:
            callable_(context, *args, **kwargs)
        except Exception:
            _render_error(template, context, compat.exception_as())
        except:
            e = sys.exc_info()[0]
            _render_error(template, context, e)
    else:
        callable_(context, *args, **kwargs) 
开发者ID:remg427,项目名称:misp42splunk,代码行数:23,代码来源:runtime.py

示例3: _exec_template

# 需要导入模块: from mako import compat [as 别名]
# 或者: from mako.compat import exception_as [as 别名]
def _exec_template(callable_, context, args=None, kwargs=None):
    """execute a rendering callable given the callable, a
    Context, and optional explicit arguments

    the contextual Template will be located if it exists, and
    the error handling options specified on that Template will
    be interpreted here.
    """
    template = context._with_template
    if template is not None and \
            (template.format_exceptions or template.error_handler):
        try:
            callable_(context, *args, **kwargs)
        except Exception:
            _render_error(template, context, compat.exception_as())
        except:
            e = sys.exc_info()[0]
            _render_error(template, context, e)
    else:
        callable_(context, *args, **kwargs) 
开发者ID:jpush,项目名称:jbox,代码行数:22,代码来源:runtime.py

示例4: _include_file

# 需要导入模块: from mako import compat [as 别名]
# 或者: from mako.compat import exception_as [as 别名]
def _include_file(context, uri, calling_uri, **kwargs):
    """locate the template from the given uri and include it in
    the current output."""

    template = _lookup_template(context, uri, calling_uri)
    (callable_, ctx) = _populate_self_namespace(
        context._clean_inheritance_tokens(),
        template)
    kwargs = _kwargs_for_include(callable_, context._data, **kwargs)
    if template.include_error_handler:
        try:
            callable_(ctx, **kwargs)
        except Exception:
            result = template.include_error_handler(ctx, compat.exception_as())
            if not result:
                compat.reraise(*sys.exc_info())
    else:
        callable_(ctx, **kwargs) 
开发者ID:tp4a,项目名称:teleport,代码行数:20,代码来源:runtime.py

示例5: parse

# 需要导入模块: from mako import compat [as 别名]
# 或者: from mako.compat import exception_as [as 别名]
def parse(code, mode="exec", **exception_kwargs):
    """Parse an expression into AST"""

    try:
        return _ast_util.parse(code, "<unknown>", mode)
    except Exception:
        raise exceptions.SyntaxException(
            "(%s) %s (%r)"
            % (
                compat.exception_as().__class__.__name__,
                compat.exception_as(),
                code[0:50],
            ),
            **exception_kwargs
        ) 
开发者ID:remg427,项目名称:misp42splunk,代码行数:17,代码来源:pyparser.py

示例6: _lookup_template

# 需要导入模块: from mako import compat [as 别名]
# 或者: from mako.compat import exception_as [as 别名]
def _lookup_template(context, uri, relativeto):
    lookup = context._with_template.lookup
    if lookup is None:
        raise exceptions.TemplateLookupException(
            "Template '%s' has no TemplateLookup associated"
            % context._with_template.uri
        )
    uri = lookup.adjust_uri(uri, relativeto)
    try:
        return lookup.get_template(uri)
    except exceptions.TopLevelLookupException:
        raise exceptions.TemplateLookupException(str(compat.exception_as())) 
开发者ID:remg427,项目名称:misp42splunk,代码行数:14,代码来源:runtime.py

示例7: parse

# 需要导入模块: from mako import compat [as 别名]
# 或者: from mako.compat import exception_as [as 别名]
def parse(code, mode='exec', **exception_kwargs):
    """Parse an expression into AST"""

    try:
        return _ast_util.parse(code, '<unknown>', mode)
    except Exception:
        raise exceptions.SyntaxException(
            "(%s) %s (%r)" % (
                compat.exception_as().__class__.__name__,
                compat.exception_as(),
                code[0:50]
            ), **exception_kwargs) 
开发者ID:jpush,项目名称:jbox,代码行数:14,代码来源:pyparser.py

示例8: _lookup_template

# 需要导入模块: from mako import compat [as 别名]
# 或者: from mako.compat import exception_as [as 别名]
def _lookup_template(context, uri, relativeto):
    lookup = context._with_template.lookup
    if lookup is None:
        raise exceptions.TemplateLookupException(
            "Template '%s' has no TemplateLookup associated" %
            context._with_template.uri)
    uri = lookup.adjust_uri(uri, relativeto)
    try:
        return lookup.get_template(uri)
    except exceptions.TopLevelLookupException:
        raise exceptions.TemplateLookupException(str(compat.exception_as())) 
开发者ID:jpush,项目名称:jbox,代码行数:13,代码来源:runtime.py


注:本文中的mako.compat.exception_as方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。