From 8909c1865826619dee1acea94b0a3f3304c6f511 Mon Sep 17 00:00:00 2001 From: Frank Brehm Date: Wed, 28 Feb 2018 12:37:31 +0100 Subject: [PATCH] Implementing IDNA translation --- pp_lib/idna_xlate.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/pp_lib/idna_xlate.py b/pp_lib/idna_xlate.py index d75da15..86f612c 100644 --- a/pp_lib/idna_xlate.py +++ b/pp_lib/idna_xlate.py @@ -27,7 +27,7 @@ try: except ImportError: from .global_version import __version__ as my_version -__version__ = '0.1.0' +__version__ = '0.2.1' LOG = logging.getLogger(__name__) @@ -92,7 +92,18 @@ class IdnaXlateApp(PpApplication): for item in self.args.items: - print(" * {i!r}:".format(i=item)) + if item == 'xn--': + print(" * {}".format(self.colored( + "Invalid item 'xn--'", ('BOLD', 'RED')))) + continue + + item_idna = item + if 'xn--' in item: + item_idna = to_str(to_bytes(item).decode('idna')) + else: + item_idna = to_str(item.encode('idna')) + + print(" * {i!r}: {p!r}".format(i=item, p=item_idna)) # ============================================================================= -- 2.39.5