Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

info output garbled when terminal does not support formatting #1889

Open
braingram opened this issue Dec 23, 2024 · 0 comments
Open

info output garbled when terminal does not support formatting #1889

braingram opened this issue Dec 23, 2024 · 0 comments

Comments

@braingram
Copy link
Contributor

braingram commented Dec 23, 2024

Description of the problem

In situations where the output doesn't support ANSI escape codes the info output is garbled (the same is true for diff).

FWIW rich doesn't have this issue. Checking sys.stdout.isatty might also be sufficient.

Example of the problem

If the following is in a script info.py:

import asdf
import numpy as np

tree = {
    "a": {
        "b": 1,
        "c": [1, 2, 3, 4, 5],
    },
    "arr": np.arange(42),
}

af = asdf.AsdfFile(tree)
af.info()

Running python info.py | less results in garbled output in less:

ESC[1mrootESC[0m (AsdfObject)
ESC[2m├─ESC[0mESC[1maESC[0m (dict)
ESC[2m│ ├─ESC[0mESC[1mbESC[0m (int): 1
ESC[2m│ └─ESC[0mESC[1mcESC[0m (list)
ESC[2m│   ├─ESC[0m[ESC[1m0ESC[0m] (int): 1
ESC[2m│   ├─ESC[0m[ESC[1m1ESC[0m] (int): 2
ESC[2m│   ├─ESC[0m[ESC[1m2ESC[0m] (int): 3
ESC[2m│   ├─ESC[0m[ESC[1m3ESC[0m] (int): 4
ESC[2m│   └─ESC[0m[ESC[1m4ESC[0m] (int): 5
ESC[2m└─ESC[0mESC[1marrESC[0m (ndarray): shape=(42,), dtype=int64

System information

asdf version: main
python version: 3.12
operating system: mac osx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant