Prettify the output of print_term() - wr - Translate a term via WordReference.com
(HTM) hg clone https://bitbucket.org/iamleot/wr
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
---
(DIR) changeset e4cab39042e06f9158917c9eeeeae77ecee0d901
(DIR) parent c9b37cf07c3e0b33a05777eab183f1405f9998bf
(HTM) Author: Leonardo Taccari <iamleot@gmail.com>
Date: Tue, 29 Oct 2019 15:16:42
Prettify the output of print_term()
Remove the `[...]' for term type, remove extra spaces when printing
description and add a new line between each terms.
From and thanks to Rocky Hotas!
Diffstat:
wr.py | 10 ++++++----
1 files changed, 6 insertions(+), 4 deletions(-)
---
diff -r c9b37cf07c3e -r e4cab39042e0 wr.py
--- a/wr.py Tue Oct 22 19:35:03 2019 +0200
+++ b/wr.py Tue Oct 29 15:16:42 2019 +0100
@@ -151,9 +151,9 @@
def print_term(term: Term):
"""Pretty print a Term"""
- print('{term} [{term_type}]'.format(
- term=term.term, term_type=term.term_type))
- print(' {description}'.format(description=term.term_description))
+ print('{term} {term_type}'.format(term=term.term,
+ term_type=term.term_type))
+ print('{description}'.format(description=term.term_description))
for translation, translation_type in zip(term.translation, term.translation_type):
print(textwrap.fill('{translation} [{translation_type}]'.format(
translation=translation,
@@ -178,5 +178,7 @@
dictionary = sys.argv[1]
term = sys.argv[2]
- for t in translate(dictionary, term):
+ for i, t in enumerate(translate(dictionary, term)):
+ if i > 0:
+ print()
print_term(t)