##// END OF EJS Templates
IPython/Extensions/ipipe.py (xiter): Make sure that iterating...
walter.doerwald -
Show More
@@ -149,7 +149,7 b' class _BrowserLevel(object):'
149 149 # position of cursor and screen, etc.) of one browser level
150 150 # An ``ibrowse`` object keeps multiple ``_BrowserLevel`` objects in
151 151 # a stack.
152 def __init__(self, browser, input,mainsizey, *attrs):
152 def __init__(self, browser, input, mainsizey, *attrs):
153 153 self.browser = browser
154 154 self.input = input
155 155 self.header = [x for x in ipipe.xrepr(input, "header") if not isinstance(x[0], int)]
@@ -925,23 +925,27 b' class ibrowse(ipipe.Display):'
925 925 Enter the object ``item``. If ``attrs`` is specified, it will be used
926 926 as a fixed list of attributes to display.
927 927 """
928 oldlevels = len(self.levels)
929 self._calcheaderlines(oldlevels+1)
930 try:
931 level = _BrowserLevel(
932 self,
933 item,
934 self.scrsizey-1-self._headerlines-2,
935 *attrs
936 )
937 except (KeyboardInterrupt, SystemExit):
938 raise
939 except Exception, exc:
940 self._calcheaderlines(oldlevels)
928 if self.levels and item is self.levels[-1].input:
941 929 curses.beep()
942 self.report(exc)
930 self.report(CommandError("Recursion on input object"))
943 931 else:
944 self.levels.append(level)
932 oldlevels = len(self.levels)
933 self._calcheaderlines(oldlevels+1)
934 try:
935 level = _BrowserLevel(
936 self,
937 item,
938 self.scrsizey-1-self._headerlines-2,
939 *attrs
940 )
941 except (KeyboardInterrupt, SystemExit):
942 raise
943 except Exception, exc:
944 self._calcheaderlines(oldlevels)
945 curses.beep()
946 self.report(exc)
947 else:
948 self.levels.append(level)
945 949
946 950 def startkeyboardinput(self, mode):
947 951 """
@@ -943,7 +943,13 b' def xiter(item):'
943 943 elif _isstr(item):
944 944 if not item:
945 945 raise ValueError("can't enter empty string")
946 return iter(item.splitlines())
946 lines = item.splitlines()
947 if len(lines) == 1:
948 def iterone(item):
949 yield item
950 return iterone(item)
951 else:
952 return iter(lines)
947 953 return iter(item)
948 954 else:
949 955 return iter(func()) # iter() just to be safe
@@ -1,3 +1,13 b''
1 2007-01-23 Walter Doerwald <walter@livinglogic.de>
2
3 * IPython/Extensions/ipipe.py (xiter): Make sure that iterating
4 a string containing a single line yields the string itself as the
5 only item.
6
7 * IPython/Extensions/ibrowse.py (ibrowse): Avoid entering an
8 object if it's the same as the one on the last level (This avoids
9 infinite recursion for one line strings).
10
1 11 2007-01-17 Fernando Perez <Fernando.Perez@colorado.edu>
2 12
3 13 * IPython/ultraTB.py (AutoFormattedTB.__call__): properly flush
General Comments 0
You need to be logged in to leave comments. Login now