From: Douglas Bagnall Date: Tue, 15 May 2018 10:26:43 +0000 (+1200) Subject: python/samba/graph: use look up table for ascii-art charsets X-Git-Tag: tevent-0.9.37~396 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=4f7638f8aba737240352199cc253dbd286f7907c;p=thirdparty%2Fsamba.git python/samba/graph: use look up table for ascii-art charsets Signed-off-by: Douglas Bagnall Reviewed-by: Andrew Bartlett --- diff --git a/python/samba/graph.py b/python/samba/graph.py index 385e377906b..53515a32710 100644 --- a/python/samba/graph.py +++ b/python/samba/graph.py @@ -439,6 +439,27 @@ COLOUR_SETS = { } } +CHARSETS = { + 'utf8': { + 'vertical': '│', + 'horizontal': '─', + 'corner': '╭', + #'diagonal': '╲', + 'diagonal': '·', + #'missing': '🕱', + 'missing': '-', + 'right_arrow': '←', + }, + 'ascii': { + 'vertical': '|', + 'horizontal': '-', + 'corner': ',', + 'diagonal': '0', + 'missing': '-', + 'right_arrow': '<-', + } +} + def find_transitive_distance(vertices, edges): all_vertices = (set(vertices) | @@ -518,18 +539,13 @@ def distance_matrix(vertices, edges, lines = [] write = lines.append - if utf8: - vertical = '│' - horizontal = '─' - corner = '╭' - #diagonal = '╲' - diagonal = '·' - #missing = '🕱' - missing = '-' - right_arrow = '←' - else: - vertical, horizontal, corner, diagonal, missing = '|-,0-' - right_arrow = '<-' + charset = CHARSETS['utf8' if utf8 else 'ascii'] + vertical = charset['vertical'] + horizontal = charset['horizontal'] + corner = charset['corner'] + diagonal = charset['diagonal'] + missing = charset['missing'] + right_arrow = charset['right_arrow'] colours = COLOUR_SETS[colour]