comparison frontends/src/jp/cmd_blog.py @ 2232:4f389486667d

jp: added constant to handle ANSI code for header and subheaders
author Goffi <goffi@goffi.org>
date Thu, 27 Apr 2017 00:57:04 +0200
parents 301bb52c8715
children ed28798fd76c
comparison
equal deleted inserted replaced
2231:230fc5b609a8 2232:4f389486667d
65 65
66 URL_REDIRECT_PREFIX = 'url_redirect_' 66 URL_REDIRECT_PREFIX = 'url_redirect_'
67 INOTIFY_INSTALL = '"pip install inotify"' 67 INOTIFY_INSTALL = '"pip install inotify"'
68 SECURE_UNLINK_MAX = 10 * 2 # we double value as there are 2 files per draft (content and metadata) 68 SECURE_UNLINK_MAX = 10 * 2 # we double value as there are 2 files per draft (content and metadata)
69 SECURE_UNLINK_DIR = ".backup" 69 SECURE_UNLINK_DIR = ".backup"
70 HEADER_ANSI = A.BOLD + A.FG_YELLOW
71 MB_KEYS = (u"id", 70 MB_KEYS = (u"id",
72 u"atom_id", 71 u"atom_id",
73 u"updated", 72 u"updated",
74 u"published", 73 u"published",
75 u"comments", # this key is used for all comments* keys 74 u"comments", # this key is used for all comments* keys
221 lines.append(data[u'comments']) 220 lines.append(data[u'comments'])
222 for k in (u'node', u'service'): 221 for k in (u'node', u'service'):
223 if OUTPUT_OPT_NO_HEADER in self.args.output_opts: 222 if OUTPUT_OPT_NO_HEADER in self.args.output_opts:
224 header = u'' 223 header = u''
225 else: 224 else:
226 header = HEADER_ANSI + k + u': ' + A.RESET 225 header = C.A_HEADER + k + u': ' + A.RESET
227 lines.append(header + data[k]) 226 lines.append(header + data[k])
228 return u'\n'.join(lines) 227 return u'\n'.join(lines)
229 228
230 def format_tags(self, item, keys): 229 def format_tags(self, item, keys):
231 tags = data_format.dict2iter('tag', item, pop=True) 230 tags = data_format.dict2iter('tag', item, pop=True)
277 continue 276 continue
278 if OUTPUT_OPT_NO_HEADER in self.args.output_opts: 277 if OUTPUT_OPT_NO_HEADER in self.args.output_opts:
279 header = '' 278 header = ''
280 else: 279 else:
281 header = u"{k_fmt}{key}:{k_fmt_e} {sep}".format( 280 header = u"{k_fmt}{key}:{k_fmt_e} {sep}".format(
282 k_fmt = HEADER_ANSI, 281 k_fmt = C.A_HEADER,
283 key = k, 282 key = k,
284 k_fmt_e = A.RESET, 283 k_fmt_e = A.RESET,
285 sep = u'\n' if 'content' in k else u'') 284 sep = u'\n' if 'content' in k else u'')
286 value = k_cb[k](item, keys) if k in k_cb else item[k] 285 value = k_cb[k](item, keys) if k in k_cb else item[k]
287 self.disp(header + value) 286 self.disp(header + value)