mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-28 15:28:27 +01:00
params/metrics: diff: implement tabulated markdown output (--show-md) (#3757)
* params/metrics: diff: implement tabulated markdown output Via `--show-md` on `diff`s. * table: show None on missing val * tests: use `dedent`, add tests for markdown * diff: add --show-md Co-authored-by: Ruslan Kuprieiev <[email protected]>
This commit is contained in:
co-authored by
Ruslan Kuprieiev
parent
ce946d1160
commit
666e203bbb
+11
-15
@@ -85,24 +85,20 @@ def diff(old, new, with_unchanged=False):
|
||||
return dict(res)
|
||||
|
||||
|
||||
def table(header, rows):
|
||||
from texttable import Texttable
|
||||
def table(header, rows, markdown=False):
|
||||
from tabulate import tabulate
|
||||
|
||||
if not rows:
|
||||
if not rows and not markdown:
|
||||
return ""
|
||||
|
||||
t = Texttable()
|
||||
|
||||
# disable automatic formatting
|
||||
t.set_cols_dtype(["t"] * len(header))
|
||||
|
||||
# remove borders to make it easier for users to copy stuff
|
||||
t.set_chars([""] * len(header))
|
||||
t.set_deco(0)
|
||||
|
||||
t.add_rows([header] + rows)
|
||||
|
||||
return t.draw()
|
||||
return tabulate(
|
||||
rows,
|
||||
header,
|
||||
tablefmt="github" if markdown else "plain",
|
||||
disable_numparse=True,
|
||||
# None will be shown as "" by default, overriding
|
||||
missingval="None",
|
||||
)
|
||||
|
||||
|
||||
def format_dict(d):
|
||||
|
||||
Reference in New Issue
Block a user