mirror of
https://github.com/explosion/spaCy.git
synced 2024-11-10 19:57:17 +03:00
Simplify function
This commit is contained in:
parent
ce7eec846b
commit
5c966d0874
|
@ -83,16 +83,11 @@ def print_markdown(data, title=None):
|
|||
data (dict or list of tuples): Label/value pairs.
|
||||
title (unicode or None): Title, will be rendered as headline 2.
|
||||
"""
|
||||
|
||||
def excl_value(value):
|
||||
# contains path, i.e. personal info
|
||||
return isinstance(value, basestring_) and Path(value).exists()
|
||||
|
||||
if isinstance(data, dict):
|
||||
data = list(data.items())
|
||||
markdown = [
|
||||
"* **{}:** {}".format(l, unicode_(v)) for l, v in data if not excl_value(v)
|
||||
]
|
||||
markdown = []
|
||||
for key, value in data.items():
|
||||
if isinstance(value, basestring_) and Path(value).exists():
|
||||
continue
|
||||
markdown.append("* **{}:** {}".format(key, unicode_(value)))
|
||||
if title:
|
||||
print("\n## {}".format(title))
|
||||
print("\n{}\n".format("\n".join(markdown)))
|
||||
|
|
Loading…
Reference in New Issue
Block a user