##// END OF EJS Templates
Fix various small bugs.
Thomas Kluyver -
Show More
@@ -146,9 +146,9 b' class HistoryManager(Configurable):'
146 146 -------
147 147 An iterator over tuples: (session, line_number, command)
148 148 """
149 toget = "source_raw" if raw else source
149 toget = "source_raw" if raw else "source"
150 150 return self.db.execute("SELECT session, line, " +toget+ \
151 "FROM history WHERE" +toget+ "GLOB ?", (pattern,))
151 " FROM history WHERE " +toget+ " GLOB ?", (pattern,))
152 152
153 153 def _get_hist_session(self, start=1, stop=None, raw=True, output=False):
154 154 """Get input and output history from the current session. Called by
@@ -424,6 +424,12 b" def magic_history(self, parameter_s = ''):"
424 424
425 425 # For brevity
426 426 history_manager = self.shell.history_manager
427
428 def _format_lineno(session, line):
429 """Helper function to format line numbers properly."""
430 if session in (0, history_manager.session_number):
431 return str(line)
432 return "%s/%s" % (session, line)
427 433
428 434 # Check if output to specific file was requested.
429 435 try:
@@ -458,9 +464,9 b" def magic_history(self, parameter_s = ''):"
458 464 matches_current_session = []
459 465 for session, line, s in history_manager.get_hist_search(pattern, raw):
460 466 if session == history_manager.session_number:
461 matches_current_session.append(line, s)
467 matches_current_session.append((line, s))
462 468 continue
463 print("%d#%d: %s" %(session, line, s.expandtabs(4)), file=outfile)
469 print("%d/%d: %s" %(session, line, s.expandtabs(4)), file=outfile)
464 470 if matches_current_session:
465 471 print("=== Current session: ===", file=outfile)
466 472 for line, s in matches_current_session:
@@ -499,7 +505,7 b" def magic_history(self, parameter_s = ''):"
499 505 multiline = "\n" in inline
500 506 line_sep = '\n' if multiline else ''
501 507 if print_nums:
502 print('%s:%s' % (_format_lineno(session, lineno).ljust(width),
508 print('%s:%s' % (_format_lineno(session, lineno).rjust(width),
503 509 line_sep), file=outfile, end='')
504 510 if pyprompts:
505 511 print(">>> ", end="", file=outfile)
General Comments 0
You need to be logged in to leave comments. Login now