當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。