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


Python ansi2html.Ansi2HTMLConverter方法代码示例

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


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

示例1: ansi2html

# 需要导入模块: import ansi2html [as 别名]
# 或者: from ansi2html import Ansi2HTMLConverter [as 别名]
def ansi2html(s):
    return mark_safe(Ansi2HTMLConverter(inline=True).convert(s, full=False)) 
开发者ID:DMOJ,项目名称:online-judge,代码行数:4,代码来源:reference.py

示例2: convert_file_contents_to_html2

# 需要导入模块: import ansi2html [as 别名]
# 或者: from ansi2html import Ansi2HTMLConverter [as 别名]
def convert_file_contents_to_html2(normalized_output_file):
    #conv = Ansi2HTMLConverter()
    with open(normalized_output_file, "rb") as scan_file:
        test_data = "".join(read_to_unicode(scan_file))
        #expected_data = [e.rstrip('\n') for e in read_to_unicode(scan_file)]
        html = Ansi2HTMLConverter().convert(test_data, ensure_trailing_newline=True)

    return html 
开发者ID:sethsec,项目名称:celerystalk,代码行数:10,代码来源:report.py

示例3: get

# 需要导入模块: import ansi2html [as 别名]
# 或者: from ansi2html import Ansi2HTMLConverter [as 别名]
def get(self, request, *args, **kwargs):
        filename = self.request.query_params.get('std', None)
        is_html = self.request.query_params.get('html', False)
        if not filename:
            return common.message(500, 'stdout not found')

        options = dbutils.get_stateless_options()
        wss = options.get('WORKSPACES')

        filename = utils.clean_path(filename).strip('/')
        p = pathlib.Path(filename)

        # we don't want a LFI here even when we're admin
        if p.parts[0] not in os.listdir(wss):
            return common.message(500, 'Workspace not found ')

        stdout = utils.join_path(wss, filename)
        content = utils.just_read(stdout)
        if not content:
            return HttpResponse("No result found")

        if filename.endswith('.html') or is_html:
            return HttpResponse(content)

        try:
            # convert console output to html
            conv = Ansi2HTMLConverter(scheme='mint-terminal')
            html = conv.convert(content)
            return HttpResponse(html)
            # return Response(html)
        except:
            return HttpResponse(content) 
开发者ID:j3ssie,项目名称:Osmedeus,代码行数:34,代码来源:views.py

示例4: terminalize_output

# 需要导入模块: import ansi2html [as 别名]
# 或者: from ansi2html import Ansi2HTMLConverter [as 别名]
def terminalize_output(output):
    # Replace "<,&,>" signs
    output = output.replace("&", "&amp;")
    output = output.replace("<", "&lt;")
    output = output.replace(">", "&gt;")
    output = output.replace("\n", "<br/>")
    '''
       Substitute terminal color codes for CSS tags.
       The bold tag can be a modifier on another tag
       and thus sometimes doesn't have its own
       closing tag. Just ignore it in that case.
    '''
    conv = ansi2html.Ansi2HTMLConverter(escaped=False, scheme="xterm")
    return conv.convert(output, full=False) 
开发者ID:idaholab,项目名称:civet,代码行数:16,代码来源:models.py

示例5: ansi_to_html

# 需要导入模块: import ansi2html [as 别名]
# 或者: from ansi2html import Ansi2HTMLConverter [as 别名]
def ansi_to_html(ansi_text):
    return Ansi2HTMLConverter(inline=True).convert(wrangle_to_unicode(ansi_text), full=False) 
开发者ID:octobear2,项目名称:ob2,代码行数:4,代码来源:templating.py

示例6: gen_ansi_output

# 需要导入模块: import ansi2html [as 别名]
# 或者: from ansi2html import Ansi2HTMLConverter [as 别名]
def gen_ansi_output():

    conv = Ansi2HTMLConverter()

    input_file = EXAMPLES_DIR / 'devtools_main.py'
    os.environ['PY_DEVTOOLS_HIGHLIGHT'] = 'true'
    p = subprocess.run((sys.executable, str(input_file)), stdout=subprocess.PIPE, check=True, encoding='utf8')
    html = conv.convert(p.stdout, full=False).strip('\r\n')
    full_html = f'<div class="terminal">\n<pre class="terminal-content">\n{html}\n</pre>\n</div>'
    path = TMP_EXAMPLES_DIR / f'{input_file.stem}.html'
    path.write_text(full_html)
    print(f'generated ansi output to {path}') 
开发者ID:samuelcolvin,项目名称:pydantic,代码行数:14,代码来源:exec_examples.py

示例7: format_log

# 需要导入模块: import ansi2html [as 别名]
# 或者: from ansi2html import Ansi2HTMLConverter [as 别名]
def format_log(log):
    conv = Ansi2HTMLConverter(dark_bg=False, scheme="solarized", markup_lines=True)
    headers = conv.produce_headers()
    content = conv.convert(log, full=False)
    content = '<pre class="ansi2html-content">{}</pre>'.format(content)
    return headers + content 
开发者ID:SFDO-Tooling,项目名称:MetaCI,代码行数:8,代码来源:utils.py


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