pycontribs / ansi2html

Convert text with ansi color codes to HTML
GNU Lesser General Public License v3.0
389 stars 78 forks source link

AttributeError: 'list' object has no attribute 'replace' #242

Open fenchu opened 9 months ago

fenchu commented 9 months ago
/root/.pyenv/shims/python3 ./html-report.py --host="https://$acmehostname.$acmedomain/" --fname="$TESTENV.html" --directory=$SERVER

deploy is a string.

python 3,12,2 linux ubuntu 22.04LTS

Traceback (most recent call last):
  File "/builds/tlsvid/acme/acme-azure-auto-test/./html-report.py", line 31, in <module>
    deploy = Ansi2HTMLConverter(linkify=True, inline=True).convert(deploy)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.pyenv/versions/base/lib/python3.12/site-packages/ansi2html/converter.py", line 627, in convert
    attrs = self.prepare(ansi, ensure_trailing_newline=ensure_trailing_newline)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.pyenv/versions/base/lib/python3.12/site-packages/ansi2html/converter.py", line 604, in prepare
    body, styles = self.apply_regex(ansi)
                   ^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.pyenv/versions/base/lib/python3.12/site-packages/ansi2html/converter.py", line 353, in apply_regex
    no_cursor_parts = self._collapse_cursor(all_parts)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.pyenv/versions/base/lib/python3.12/site-packages/ansi2html/converter.py", line 574, in _collapse_cursor
    for part in parts:
  File "/root/.pyenv/versions/base/lib/python3.12/site-packages/ansi2html/converter.py", line 396, in _apply_regex
    ansi = ansi.replace(pattern, special)
           ^^^^^^^^^^^^
AttributeError: 'list' object has no attribute 'replace'

probalby do a check of the

fenchu commented 9 months ago

I can fix it doing an explicit "".join(ansi)