comparison frontends/src/jp/cmd_blog.py @ 2161:62dfa6e02f54

jp (base, blog, output(std)): fixed bad unicode handling in stdout, use of jp.disp instead of simple print
author Goffi <goffi@goffi.org>
date Tue, 21 Feb 2017 21:01:40 +0100
parents 970a348d3fe9
children 63d191c05ecd
comparison
equal deleted inserted replaced
2160:e67e8cd24141 2161:62dfa6e02f54
275 k_fmt = HEADER_ANSI, 275 k_fmt = HEADER_ANSI,
276 key = k, 276 key = k,
277 k_fmt_e = A.RESET, 277 k_fmt_e = A.RESET,
278 sep = u'\n' if 'content' in k else u'') 278 sep = u'\n' if 'content' in k else u'')
279 value = k_cb[k](item, keys) if k in k_cb else item[k] 279 value = k_cb[k](item, keys) if k in k_cb else item[k]
280 print header + value 280 self.disp(header + value)
281 # we want a separation line after each item but the last one 281 # we want a separation line after each item but the last one
282 if idx < len(items)-1: 282 if idx < len(items)-1:
283 print(u'') 283 print(u'')
284 284
285 def format_time(self, timestamp): 285 def format_time(self, timestamp):
330 if tags: 330 if tags:
331 print(A.color(A.FG_MAGENTA, u', '.join(tags))) 331 print(A.color(A.FG_MAGENTA, u', '.join(tags)))
332 if (title or tags) and content: 332 if (title or tags) and content:
333 print("") 333 print("")
334 if content: 334 if content:
335 print content 335 self.disp(content)
336 336
337 print(u'\n' + sep + '\n') 337 print(u'\n' + sep + '\n')
338 338
339 339
340 def mbGetCb(self, mb_result): 340 def mbGetCb(self, mb_result):
810 if self.args.location is None: 810 if self.args.location is None:
811 for name in ('option', 'service', 'no_images_upload'): 811 for name in ('option', 'service', 'no_images_upload'):
812 if getattr(self.args, name): 812 if getattr(self.args, name):
813 self.parser.error(_(u"{name} argument can't be used without location argument").format(name=name)) 813 self.parser.error(_(u"{name} argument can't be used without location argument").format(name=name))
814 if self.args.importer is None: 814 if self.args.importer is None:
815 print u'\n'.join([u'{}: {}'.format(name, desc) for name, desc in self.host.bridge.blogImportList()]) 815 self.disp(u'\n'.join([u'{}: {}'.format(name, desc) for name, desc in self.host.bridge.blogImportList()]))
816 else: 816 else:
817 try: 817 try:
818 short_desc, long_desc = self.host.bridge.blogImportDesc(self.args.importer) 818 short_desc, long_desc = self.host.bridge.blogImportDesc(self.args.importer)
819 except Exception as e: 819 except Exception as e:
820 msg = [l for l in unicode(e).split('\n') if l][-1] # we only keep the last line 820 msg = [l for l in unicode(e).split('\n') if l][-1] # we only keep the last line
821 print msg 821 self.disp(msg)
822 self.host.quit(1) 822 self.host.quit(1)
823 else: 823 else:
824 print u"{name}: {short_desc}\n\n{long_desc}".format(name=self.args.importer, short_desc=short_desc, long_desc=long_desc) 824 self.disp(u"{name}: {short_desc}\n\n{long_desc}".format(name=self.args.importer, short_desc=short_desc, long_desc=long_desc))
825 self.host.quit() 825 self.host.quit()
826 else: 826 else:
827 # we have a location, an import is requested 827 # we have a location, an import is requested
828 options = {key: value for key, value in self.args.option} 828 options = {key: value for key, value in self.args.option}
829 if self.args.host: 829 if self.args.host: