Mercurial > p > roundup > code
comparison roundup/admin.py @ 7588:8329b2227adb
fix: restore roundup-admin display output format w/o pragmas
Do not indent the display output unless user requested protected
fields or headers. This returns the format to what it was prior to
2.3.0.
Parsing roundup-admin output programmaticly was never a use case, but
don't break the output format without a reason.
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Wed, 26 Jul 2023 11:05:10 -0400 |
| parents | df87f02c2930 |
| children | 4de48eadf5f4 |
comparison
equal
deleted
inserted
replaced
| 7587:8f29e4ea05ce | 7588:8329b2227adb |
|---|---|
| 519 for the given node. | 519 for the given node. |
| 520 """ | 520 """ |
| 521 if len(args) < 1: | 521 if len(args) < 1: |
| 522 raise UsageError(_('Not enough arguments supplied')) | 522 raise UsageError(_('Not enough arguments supplied')) |
| 523 | 523 |
| 524 display_protected = self.settings['display_protected'] | |
| 525 display_header = self.settings['display_header'] | |
| 526 | |
| 524 # decode the node designator | 527 # decode the node designator |
| 525 for designator in args[0].split(','): | 528 for designator in args[0].split(','): |
| 526 try: | 529 try: |
| 527 classname, nodeid = hyperdb.splitDesignator(designator) | 530 classname, nodeid = hyperdb.splitDesignator(designator) |
| 528 except hyperdb.DesignatorError as message: | 531 except hyperdb.DesignatorError as message: |
| 531 # get the class | 534 # get the class |
| 532 cl = self.get_class(classname) | 535 cl = self.get_class(classname) |
| 533 | 536 |
| 534 # display the values | 537 # display the values |
| 535 normal_props = sorted(cl.properties) | 538 normal_props = sorted(cl.properties) |
| 536 if self.settings['display_protected']: | 539 if display_protected: |
| 537 keys = sorted(cl.getprops()) | 540 keys = sorted(cl.getprops()) |
| 538 else: | 541 else: |
| 539 keys = normal_props | 542 keys = normal_props |
| 540 | 543 |
| 541 if self.settings['display_header']: | 544 if display_header: |
| 542 status = "retired" if cl.is_retired(nodeid) else "active" | 545 status = "retired" if cl.is_retired(nodeid) else "active" |
| 543 print('\n[%s (%s)]' % (designator, status)) | 546 print('\n[%s (%s)]' % (designator, status)) |
| 544 for key in keys: | 547 for key in keys: |
| 545 value = cl.get(nodeid, key) | 548 value = cl.get(nodeid, key) |
| 546 # prepend * for protected properties else just indent | 549 # prepend * for protected properties else just indent |
| 547 # with space. | 550 # with space. |
| 548 protected = "*" if key not in normal_props else ' ' | 551 if display_protected or display_header: |
| 552 protected = "*" if key not in normal_props else ' ' | |
| 553 else: | |
| 554 protected = "" | |
| 549 print(_('%(protected)s%(key)s: %(value)s') % locals()) | 555 print(_('%(protected)s%(key)s: %(value)s') % locals()) |
| 550 | 556 |
| 551 def do_export(self, args, export_files=True): | 557 def do_export(self, args, export_files=True): |
| 552 ''"""Usage: export [[-]class[,class]] export_dir | 558 ''"""Usage: export [[-]class[,class]] export_dir |
| 553 Export the database to colon-separated-value files. | 559 Export the database to colon-separated-value files. |
