| 35 | show(total, d, '') |
| 36 | |
| 37 | def show(total, d, prefix): |
| 38 | if not d: return |
| 39 | list = [] |
| 40 | sum = 0 |
| 41 | for key in d.keys(): |
| 42 | tsub, dsub = d[key] |
| 43 | list.append((tsub, key)) |
| 44 | if tsub is not None: sum = sum + tsub |
| 45 | ## if sum < total: |
| 46 | ## list.append((total - sum, os.curdir)) |
| 47 | list.sort() |
| 48 | list.reverse() |
| 49 | width = len(repr(list[0][0])) |
| 50 | for tsub, key in list: |
| 51 | if tsub is None: |
| 52 | psub = prefix |
| 53 | else: |
| 54 | print(prefix + repr(tsub).rjust(width) + ' ' + key) |
| 55 | psub = prefix + ' '*(width-1) + '|' + ' '*(len(key)+1) |
| 56 | if key in d: |
| 57 | show(tsub, d[key][1], psub) |
| 58 | |
| 59 | if __name__ == '__main__': |
| 60 | main() |