Show More
@@ -344,7 +344,10 b' def _getattr(obj, name, default=_default):' | |||||
344 | elif isinstance(name, basestring): |
|
344 | elif isinstance(name, basestring): | |
345 | return getattr(obj, name, default) |
|
345 | return getattr(obj, name, default) | |
346 | elif callable(name): |
|
346 | elif callable(name): | |
|
347 | try: | |||
347 | return name(obj) |
|
348 | return name(obj) | |
|
349 | except AttributeError: | |||
|
350 | return default | |||
348 | else: |
|
351 | else: | |
349 | try: |
|
352 | try: | |
350 | return obj[name] |
|
353 | return obj[name] | |
@@ -444,8 +447,14 b' def xrepr(item, mode):' | |||||
444 | except AttributeError: |
|
447 | except AttributeError: | |
445 | pass |
|
448 | pass | |
446 | else: |
|
449 | else: | |
|
450 | try: | |||
447 | for x in func(mode): |
|
451 | for x in func(mode): | |
448 | yield x |
|
452 | yield x | |
|
453 | except (KeyboardInterrupt, SystemExit): | |||
|
454 | raise | |||
|
455 | except Exception: | |||
|
456 | yield (-1, True) | |||
|
457 | yield (style_default, repr(item)) | |||
449 | return |
|
458 | return | |
450 | if item is None: |
|
459 | if item is None: | |
451 | yield (-1, True) |
|
460 | yield (-1, True) | |
@@ -574,7 +583,12 b' def xattrs(item, mode):' | |||||
574 | except AttributeError: |
|
583 | except AttributeError: | |
575 | return (None,) |
|
584 | return (None,) | |
576 | else: |
|
585 | else: | |
|
586 | try: | |||
577 | return func(mode) |
|
587 | return func(mode) | |
|
588 | except (KeyboardInterrupt, SystemExit): | |||
|
589 | raise | |||
|
590 | except Exception: | |||
|
591 | return (None,) | |||
578 |
|
592 | |||
579 |
|
593 | |||
580 | def xiter(item, mode): |
|
594 | def xiter(item, mode): | |
@@ -1887,7 +1901,7 b' if curses is not None:' | |||||
1887 | def __init__(self, browser, input, iterator, mainsizey, *attrs): |
|
1901 | def __init__(self, browser, input, iterator, mainsizey, *attrs): | |
1888 | self.browser = browser |
|
1902 | self.browser = browser | |
1889 | self.input = input |
|
1903 | self.input = input | |
1890 |
self.header = |
|
1904 | self.header = [x for x in xrepr(input, "header") if not isinstance(x[0], int)] | |
1891 | # iterator for the input |
|
1905 | # iterator for the input | |
1892 | self.iterator = iterator |
|
1906 | self.iterator = iterator | |
1893 |
|
1907 | |||
@@ -2626,8 +2640,14 b' if curses is not None:' | |||||
2626 |
|
2640 | |||
2627 | def cmd_enterdefault(self): |
|
2641 | def cmd_enterdefault(self): | |
2628 | level = self.levels[-1] |
|
2642 | level = self.levels[-1] | |
|
2643 | try: | |||
|
2644 | item = level.items[level.cury].item | |||
|
2645 | except IndexError: | |||
|
2646 | self.report(CommandError("No object")) | |||
|
2647 | curses.beep() | |||
|
2648 | else: | |||
2629 | self.report("entering object (default mode)...") |
|
2649 | self.report("entering object (default mode)...") | |
2630 |
self.enter( |
|
2650 | self.enter(item, "default") | |
2631 |
|
2651 | |||
2632 | def cmd_leave(self): |
|
2652 | def cmd_leave(self): | |
2633 | self.report("leave") |
|
2653 | self.report("leave") | |
@@ -2640,8 +2660,14 b' if curses is not None:' | |||||
2640 |
|
2660 | |||
2641 | def cmd_enter(self): |
|
2661 | def cmd_enter(self): | |
2642 | level = self.levels[-1] |
|
2662 | level = self.levels[-1] | |
|
2663 | try: | |||
|
2664 | item = level.items[level.cury].item | |||
|
2665 | except IndexError: | |||
|
2666 | self.report(CommandError("No object")) | |||
|
2667 | curses.beep() | |||
|
2668 | else: | |||
2643 | self.report("entering object...") |
|
2669 | self.report("entering object...") | |
2644 |
self.enter( |
|
2670 | self.enter(item, None) | |
2645 |
|
2671 | |||
2646 | def cmd_enterattr(self): |
|
2672 | def cmd_enterattr(self): | |
2647 | level = self.levels[-1] |
|
2673 | level = self.levels[-1] | |
@@ -2650,7 +2676,13 b' if curses is not None:' | |||||
2650 | curses.beep() |
|
2676 | curses.beep() | |
2651 | self.report(AttributeError(_attrname(attrname))) |
|
2677 | self.report(AttributeError(_attrname(attrname))) | |
2652 | return |
|
2678 | return | |
2653 | attr = _getattr(level.items[level.cury].item, attrname) |
|
2679 | try: | |
|
2680 | item = level.items[level.cury].item | |||
|
2681 | except IndexError: | |||
|
2682 | self.report(CommandError("No object")) | |||
|
2683 | curses.beep() | |||
|
2684 | else: | |||
|
2685 | attr = _getattr(item, attrname) | |||
2654 | if attr is _default: |
|
2686 | if attr is _default: | |
2655 | self.report(AttributeError(_attrname(attrname))) |
|
2687 | self.report(AttributeError(_attrname(attrname))) | |
2656 | else: |
|
2688 | else: | |
@@ -2659,8 +2691,14 b' if curses is not None:' | |||||
2659 |
|
2691 | |||
2660 | def cmd_detail(self): |
|
2692 | def cmd_detail(self): | |
2661 | level = self.levels[-1] |
|
2693 | level = self.levels[-1] | |
|
2694 | try: | |||
|
2695 | item = level.items[level.cury].item | |||
|
2696 | except IndexError: | |||
|
2697 | self.report(CommandError("No object")) | |||
|
2698 | curses.beep() | |||
|
2699 | else: | |||
2662 | self.report("entering detail view for object...") |
|
2700 | self.report("entering detail view for object...") | |
2663 |
self.enter( |
|
2701 | self.enter(item, "detail") | |
2664 |
|
2702 | |||
2665 | def cmd_detailattr(self): |
|
2703 | def cmd_detailattr(self): | |
2666 | level = self.levels[-1] |
|
2704 | level = self.levels[-1] | |
@@ -2669,7 +2707,13 b' if curses is not None:' | |||||
2669 | curses.beep() |
|
2707 | curses.beep() | |
2670 | self.report(AttributeError(_attrname(attrname))) |
|
2708 | self.report(AttributeError(_attrname(attrname))) | |
2671 | return |
|
2709 | return | |
2672 | attr = _getattr(level.items[level.cury].item, attrname) |
|
2710 | try: | |
|
2711 | item = level.items[level.cury].item | |||
|
2712 | except IndexError: | |||
|
2713 | self.report(CommandError("No object")) | |||
|
2714 | curses.beep() | |||
|
2715 | else: | |||
|
2716 | attr = _getattr(item, attrname) | |||
2673 | if attr is _default: |
|
2717 | if attr is _default: | |
2674 | self.report(AttributeError(_attrname(attrname))) |
|
2718 | self.report(AttributeError(_attrname(attrname))) | |
2675 | else: |
|
2719 | else: | |
@@ -2795,6 +2839,11 b' if curses is not None:' | |||||
2795 | posx += self.addstr(posy, posx, 0, self.scrsizex, msg, self.style_objheadernumber) |
|
2839 | posx += self.addstr(posy, posx, 0, self.scrsizex, msg, self.style_objheadernumber) | |
2796 | posx += self.addchr(posy, posx, 0, self.scrsizex, " ", self.scrsizex-posx, self.style_objheadernumber) |
|
2840 | posx += self.addchr(posy, posx, 0, self.scrsizex, " ", self.scrsizex-posx, self.style_objheadernumber) | |
2797 |
|
2841 | |||
|
2842 | if not level.items: | |||
|
2843 | self.addchr(self._headerlines, 0, 0, self.scrsizex, " ", self.scrsizex, self.style_colheader) | |||
|
2844 | self.addstr(self._headerlines+1, 0, 0, self.scrsizex, " <empty>", style_error) | |||
|
2845 | scr.clrtobot() | |||
|
2846 | else: | |||
2798 | # Paint column headers |
|
2847 | # Paint column headers | |
2799 | scr.move(self._headerlines, 0) |
|
2848 | scr.move(self._headerlines, 0) | |
2800 | scr.addstr(" %*s " % (level.numbersizex, "#"), self.getstyle(self.style_colheader)) |
|
2849 | scr.addstr(" %*s " % (level.numbersizex, "#"), self.getstyle(self.style_colheader)) |
General Comments 0
You need to be logged in to leave comments.
Login now