mirror of
https://github.com/daylinmorgan/yartsu.git
synced 2024-11-10 00:23:15 -06:00
55 lines
1 KiB
Python
55 lines
1 KiB
Python
|
#!/usr/bin/env python3
|
||
|
|
||
|
from importlib.metadata import version
|
||
|
|
||
|
from rich._export_format import CONSOLE_SVG_FORMAT as DEFAULT
|
||
|
|
||
|
from yartsu._export_format import CONSOLE_SVG_FORMAT as MODIFIED
|
||
|
|
||
|
MARKDOWN_DOC = """
|
||
|
# Deviation From Rich
|
||
|
|
||
|
## Versions
|
||
|
|
||
|
- Rich: {rich_version}
|
||
|
- Yartsu: {yartsu_version}
|
||
|
|
||
|
## Diff
|
||
|
|
||
|
```diff
|
||
|
{diff}
|
||
|
```
|
||
|
|
||
|
AUTO-GENERATED by code_svg_format_diff.py"""
|
||
|
|
||
|
|
||
|
def unidiff_output(expected, actual):
|
||
|
"""
|
||
|
Helper function. Returns a string containing the unified diff of two multiline strings.
|
||
|
"""
|
||
|
# see https://stackoverflow.com/questions/845276/how-to-print-the-comparison-of-two-multiline-strings-in-unified-diff-format
|
||
|
|
||
|
import difflib
|
||
|
|
||
|
expected = expected.splitlines(1)
|
||
|
actual = actual.splitlines(1)
|
||
|
|
||
|
diff = difflib.unified_diff(expected, actual)
|
||
|
|
||
|
return "".join(diff)
|
||
|
|
||
|
|
||
|
def main():
|
||
|
|
||
|
print(
|
||
|
MARKDOWN_DOC.format(
|
||
|
rich_version=version("rich"),
|
||
|
yartsu_version=version("yartsu"),
|
||
|
diff=unidiff_output(DEFAULT, MODIFIED),
|
||
|
)
|
||
|
)
|
||
|
|
||
|
|
||
|
if __name__ == "__main__":
|
||
|
main()
|