##// END OF EJS Templates
Rename ipipe._default to ipipe.noitem (which makes...
walter.doerwald -
Show More
@@ -232,7 +232,7 b' class _BrowserLevel(object):'
232 232 self.displayattrs = []
233 233
234 234 # index and name of attribute under the cursor
235 self.displayattr = (None, ipipe._default)
235 self.displayattr = (None, ipipe.noitem)
236 236
237 237 # Maps attribute names to column widths
238 238 self.colwidths = {}
@@ -284,13 +284,13 b' class _BrowserLevel(object):'
284 284 item = self.items[i].item
285 285 for attrname in self.displayattrs:
286 286 try:
287 value = ipipe._getattr(item, attrname, ipipe._default)
287 value = ipipe._getattr(item, attrname, ipipe.noitem)
288 288 except (KeyboardInterrupt, SystemExit):
289 289 raise
290 290 except Exception, exc:
291 291 value = exc
292 292 # only store attribute if it exists (or we got an exception)
293 if value is not ipipe._default:
293 if value is not ipipe.noitem:
294 294 parts = []
295 295 totallength = 0
296 296 align = None
@@ -351,7 +351,7 b' class _BrowserLevel(object):'
351 351 break
352 352 pos += self.colwidths[attrname]+1
353 353 else:
354 self.displayattr = (None, ipipe._default)
354 self.displayattr = (None, ipipe.noitem)
355 355
356 356 def moveto(self, x, y, refresh=False):
357 357 # Move the cursor to the position ``(x,y)`` (in data coordinates,
@@ -846,12 +846,12 b' class ibrowse(ipipe.Display):'
846 846 def cmd_pickattr(self):
847 847 level = self.levels[-1]
848 848 attrname = level.displayattr[1]
849 if attrname is ipipe._default:
849 if attrname is ipipe.noitem:
850 850 curses.beep()
851 851 self.report(AttributeError(ipipe._attrname(attrname)))
852 852 return
853 853 attr = ipipe._getattr(level.items[level.cury].item, attrname)
854 if attr is ipipe._default:
854 if attr is ipipe.noitem:
855 855 curses.beep()
856 856 self.report(AttributeError(ipipe._attrname(attrname)))
857 857 else:
@@ -861,14 +861,14 b' class ibrowse(ipipe.Display):'
861 861 def cmd_pickallattrs(self):
862 862 level = self.levels[-1]
863 863 attrname = level.displayattr[1]
864 if attrname is ipipe._default:
864 if attrname is ipipe.noitem:
865 865 curses.beep()
866 866 self.report(AttributeError(ipipe._attrname(attrname)))
867 867 return
868 868 result = []
869 869 for cache in level.items:
870 870 attr = ipipe._getattr(cache.item, attrname)
871 if attr is not ipipe._default:
871 if attr is not ipipe.noitem:
872 872 result.append(attr)
873 873 self.returnvalue = result
874 874 return True
@@ -881,7 +881,7 b' class ibrowse(ipipe.Display):'
881 881 def cmd_pickmarkedattr(self):
882 882 level = self.levels[-1]
883 883 attrname = level.displayattr[1]
884 if attrname is ipipe._default:
884 if attrname is ipipe.noitem:
885 885 curses.beep()
886 886 self.report(AttributeError(ipipe._attrname(attrname)))
887 887 return
@@ -889,7 +889,7 b' class ibrowse(ipipe.Display):'
889 889 for cache in level.items:
890 890 if cache.marked:
891 891 attr = ipipe._getattr(cache.item, attrname)
892 if attr is not ipipe._default:
892 if attr is not ipipe.noitem:
893 893 result.append(attr)
894 894 self.returnvalue = result
895 895 return True
@@ -947,7 +947,7 b' class ibrowse(ipipe.Display):'
947 947 def cmd_enterattr(self):
948 948 level = self.levels[-1]
949 949 attrname = level.displayattr[1]
950 if attrname is ipipe._default:
950 if attrname is ipipe.noitem:
951 951 curses.beep()
952 952 self.report(AttributeError(ipipe._attrname(attrname)))
953 953 return
@@ -958,7 +958,7 b' class ibrowse(ipipe.Display):'
958 958 curses.beep()
959 959 else:
960 960 attr = ipipe._getattr(item, attrname)
961 if attr is ipipe._default:
961 if attr is ipipe.noitem:
962 962 self.report(AttributeError(ipipe._attrname(attrname)))
963 963 else:
964 964 self.report("entering object attribute %s..." % ipipe._attrname(attrname))
@@ -978,7 +978,7 b' class ibrowse(ipipe.Display):'
978 978 def cmd_detailattr(self):
979 979 level = self.levels[-1]
980 980 attrname = level.displayattr[1]
981 if attrname is ipipe._default:
981 if attrname is ipipe.noitem:
982 982 curses.beep()
983 983 self.report(AttributeError(ipipe._attrname(attrname)))
984 984 return
@@ -989,7 +989,7 b' class ibrowse(ipipe.Display):'
989 989 curses.beep()
990 990 else:
991 991 attr = ipipe._getattr(item, attrname)
992 if attr is ipipe._default:
992 if attr is ipipe.noitem:
993 993 self.report(AttributeError(ipipe._attrname(attrname)))
994 994 else:
995 995 self.report("entering detail view for attribute...")
@@ -1013,7 +1013,7 b' class ibrowse(ipipe.Display):'
1013 1013 def cmd_sortattrasc(self):
1014 1014 level = self.levels[-1]
1015 1015 attrname = level.displayattr[1]
1016 if attrname is ipipe._default:
1016 if attrname is ipipe.noitem:
1017 1017 curses.beep()
1018 1018 self.report(AttributeError(ipipe._attrname(attrname)))
1019 1019 return
@@ -1030,7 +1030,7 b' class ibrowse(ipipe.Display):'
1030 1030 def cmd_sortattrdesc(self):
1031 1031 level = self.levels[-1]
1032 1032 attrname = level.displayattr[1]
1033 if attrname is ipipe._default:
1033 if attrname is ipipe.noitem:
1034 1034 curses.beep()
1035 1035 self.report(AttributeError(ipipe._attrname(attrname)))
1036 1036 return
@@ -1276,7 +1276,7 b' class ibrowse(ipipe.Display):'
1276 1276
1277 1277 attrstyle = [(astyle.style_default, "no attribute")]
1278 1278 attrname = level.displayattr[1]
1279 if attrname is not ipipe._default and attrname is not None:
1279 if attrname is not ipipe.noitem and attrname is not None:
1280 1280 posx += self.addstr(posy, posx, 0, endx, " | ", self.style_footer)
1281 1281 posx += self.addstr(posy, posx, 0, endx, ipipe._attrname(attrname), self.style_footer)
1282 1282 posx += self.addstr(posy, posx, 0, endx, ": ", self.style_footer)
@@ -1286,7 +1286,7 b' class ibrowse(ipipe.Display):'
1286 1286 raise
1287 1287 except Exception, exc:
1288 1288 attr = exc
1289 if attr is not ipipe._default:
1289 if attr is not ipipe.noitem:
1290 1290 attrstyle = ipipe.xrepr(attr, "footer")
1291 1291 for (nostyle, text) in attrstyle:
1292 1292 if not isinstance(nostyle, int):
@@ -219,9 +219,9 b' except TypeError:'
219 219 return real_eval(code, _globals, newlocals)
220 220
221 221
222 _default = object()
222 noitem = object()
223 223
224 def item(iterator, index, default=_default):
224 def item(iterator, index, default=noitem):
225 225 """
226 226 Return the ``index``th item from the iterator ``iterator``.
227 227 ``index`` must be an integer (negative integers are relative to the
@@ -249,7 +249,7 b' def item(iterator, index, default=_default):'
249 249 cache.popleft()
250 250 if len(cache)==i:
251 251 return cache.popleft()
252 if default is _default:
252 if default is noitem:
253 253 raise IndexError(index)
254 254 else:
255 255 return default
@@ -336,7 +336,7 b' class Pipe(Table):'
336 336 return self
337 337
338 338
339 def _getattr(obj, name, default=_default):
339 def _getattr(obj, name, default=noitem):
340 340 """
341 341 Internal helper for getting an attribute of an item. If ``name`` is ``None``
342 342 return the object itself. If ``name`` is an integer, use ``__getitem__``
General Comments 0
You need to be logged in to leave comments. Login now