|
16 | 16 | # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, |
17 | 17 | # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. |
18 | 18 | # |
19 | | -# $Id: admin.py,v 1.45 2003-03-21 04:02:12 richard Exp $ |
| 19 | +# $Id: admin.py,v 1.46 2003-03-23 06:07:05 richard Exp $ |
20 | 20 |
|
21 | 21 | '''Administration commands for maintaining Roundup trackers. |
22 | 22 | ''' |
@@ -95,11 +95,11 @@ def props_from_args(self, args): |
95 | 95 | if arg.find('=') == -1: |
96 | 96 | raise UsageError, _('argument "%(arg)s" not propname=value' |
97 | 97 | )%locals() |
98 | | - try: |
99 | | - key, value = arg.split('=') |
100 | | - except ValueError: |
| 98 | + l = arg.split('=') |
| 99 | + if len(l) < 2: |
101 | 100 | raise UsageError, _('argument "%(arg)s" not propname=value' |
102 | 101 | )%locals() |
| 102 | + key, value = l[0], '='.join(l[1:]) |
103 | 103 | if value: |
104 | 104 | props[key] = value |
105 | 105 | else: |
@@ -751,14 +751,25 @@ def do_table(self, args): |
751 | 751 |
|
752 | 752 | Lists all instances of the given class. If the properties are not |
753 | 753 | specified, all properties are displayed. By default, the column widths |
754 | | - are the width of the property names. The width may be explicitly defined |
| 754 | + are the width of the largest value. The width may be explicitly defined |
755 | 755 | by defining the property as "name:width". For example:: |
756 | 756 | roundup> table priority id,name:10 |
757 | 757 | Id Name |
758 | 758 | 1 fatal-bug |
759 | 759 | 2 bug |
760 | 760 | 3 usability |
761 | 761 | 4 feature |
| 762 | +
|
| 763 | + Also to make the width of the column the width of the label, |
| 764 | + leave a trailing : without a width on the property. E.G. |
| 765 | + roundup> table priority id,name: |
| 766 | + Id Name |
| 767 | + 1 fata |
| 768 | + 2 bug |
| 769 | + 3 usab |
| 770 | + 4 feat |
| 771 | +
|
| 772 | + will result in a the 4 character wide "Name" column. |
762 | 773 | ''' |
763 | 774 | if len(args) < 1: |
764 | 775 | raise UsageError, _('Not enough arguments supplied') |
@@ -790,10 +801,19 @@ def do_table(self, args): |
790 | 801 | for spec in prop_names: |
791 | 802 | if ':' in spec: |
792 | 803 | name, width = spec.split(':') |
793 | | - props.append((name, int(width))) |
| 804 | + if width == '': |
| 805 | + props.append((name, len(spec))) |
| 806 | + else: |
| 807 | + props.append((name, int(width))) |
794 | 808 | else: |
795 | | - props.append((spec, len(spec))) |
796 | | - |
| 809 | + # this is going to be slow |
| 810 | + maxlen = len(spec) |
| 811 | + for nodeid in cl.list(): |
| 812 | + curlen = len(str(cl.get(nodeid, spec))) |
| 813 | + if curlen > maxlen: |
| 814 | + maxlen = curlen |
| 815 | + props.append((spec, maxlen)) |
| 816 | + |
797 | 817 | # now display the heading |
798 | 818 | print ' '.join([name.capitalize().ljust(width) for name,width in props]) |
799 | 819 |
|
|
0 commit comments