def __textdata_as_details()

in migration/src/jira_util.py [0:0]


def __textdata_as_details(path: Path, lang: str) -> str:
    assert path.exists()
    name = path.name
    att_open = "open" if path.stat().st_size < 5000 else ""
    text = ""
    with open(path) as fp:
        try:
            data = fp.read()
            # use <details> markup to collapse long texts as default
            # https://gist.github.com/pierrejoubert73/902cc94d79424356a8d20be2b382e1ab
            text = f"\n<details {att_open}>\n<summary>{name}</summary>\n\n```{lang}\n{data}\n```\n\n</details>\n\n"
        except UnicodeDecodeError:
            # other encoding than 'utf-8' is used in the file
            pass
    return text