From 6e70992c6cfe35fd26287e631cc536c414dce742 Mon Sep 17 00:00:00 2001 From: Goffi Date: Thu, 27 Apr 2017 00:57:04 +0200 Subject: [PATCH] jp: added constant to handle ANSI code for header and subheaders --- frontends/src/jp/cmd_blog.py | 5 ++--- frontends/src/jp/constants.py | 5 +++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/frontends/src/jp/cmd_blog.py b/frontends/src/jp/cmd_blog.py index 1c482d87..114e2b3e 100644 --- a/frontends/src/jp/cmd_blog.py +++ b/frontends/src/jp/cmd_blog.py @@ -67,7 +67,6 @@ URL_REDIRECT_PREFIX = 'url_redirect_' INOTIFY_INSTALL = '"pip install inotify"' SECURE_UNLINK_MAX = 10 * 2 # we double value as there are 2 files per draft (content and metadata) SECURE_UNLINK_DIR = ".backup" -HEADER_ANSI = A.BOLD + A.FG_YELLOW MB_KEYS = (u"id", u"atom_id", u"updated", @@ -223,7 +222,7 @@ class Get(base.CommandBase, BlogCommon): if OUTPUT_OPT_NO_HEADER in self.args.output_opts: header = u'' else: - header = HEADER_ANSI + k + u': ' + A.RESET + header = C.A_HEADER + k + u': ' + A.RESET lines.append(header + data[k]) return u'\n'.join(lines) @@ -279,7 +278,7 @@ class Get(base.CommandBase, BlogCommon): header = '' else: header = u"{k_fmt}{key}:{k_fmt_e} {sep}".format( - k_fmt = HEADER_ANSI, + k_fmt = C.A_HEADER, key = k, k_fmt_e = A.RESET, sep = u'\n' if 'content' in k else u'') diff --git a/frontends/src/jp/constants.py b/frontends/src/jp/constants.py index ba991e27..f2594b60 100644 --- a/frontends/src/jp/constants.py +++ b/frontends/src/jp/constants.py @@ -18,6 +18,7 @@ # along with this program. If not, see . from sat_frontends.quick_frontend import constants +from sat.tools.common.ansi import ANSI as A class Const(constants.Const): @@ -33,6 +34,10 @@ class Const(constants.Const): OUTPUT_LIST_XML = u'list_xml' # list of XML nodes (as unicode strings) OUTPUT_TYPES = (OUTPUT_TEXT, OUTPUT_DICT, OUTPUT_LIST, OUTPUT_COMPLEX, OUTPUT_XML, OUTPUT_LIST_XML) + # ANSI + A_HEADER = A.BOLD + A.FG_YELLOW + A_SUBHEADER = A.BOLD + A.FG_RED + # exit codes EXIT_OK = 0 EXIT_ERROR = 1 # generic error, when nothing else match