Mercurial > libervia-backend
comparison sat_frontends/jp/cmd_blog.py @ 3520:8acaf857cd0a
jp (blog/get): fix comments node parsing
author | Goffi <goffi@goffi.org> |
---|---|
date | Sat, 01 May 2021 18:38:58 +0200 |
parents | be6d91572633 |
children | 62f490eff51c |
comparison
equal
deleted
inserted
replaced
3519:02eec2a5b5f9 | 3520:8acaf857cd0a |
---|---|
263 items, blog_items = data | 263 items, blog_items = data |
264 blog_items['items'] = items | 264 blog_items['items'] = items |
265 return {"blog_items": blog_items} | 265 return {"blog_items": blog_items} |
266 | 266 |
267 def format_comments(self, item, keys): | 267 def format_comments(self, item, keys): |
268 comments_data = data_format.dict2iterdict( | |
269 "comments", item, ("node", "service"), pop=True | |
270 ) | |
271 lines = [] | 268 lines = [] |
272 for data in comments_data: | 269 for data in item.get('comments', []): |
273 lines.append(data["comments"]) | 270 lines.append(data["uri"]) |
274 for k in ("node", "service"): | 271 for k in ("node", "service"): |
275 if OUTPUT_OPT_NO_HEADER in self.args.output_opts: | 272 if OUTPUT_OPT_NO_HEADER in self.args.output_opts: |
276 header = "" | 273 header = "" |
277 else: | 274 else: |
278 header = C.A_HEADER + k + ": " + A.RESET | 275 header = f"{C.A_HEADER}comments_{k}: {A.RESET}" |
279 lines.append(header + data[k]) | 276 lines.append(header + data[k]) |
280 return "\n".join(lines) | 277 return "\n".join(lines) |
281 | 278 |
282 def format_tags(self, item, keys): | 279 def format_tags(self, item, keys): |
283 tags = item.pop('tags', []) | 280 tags = item.pop('tags', []) |