##// END OF EJS Templates
Fix various small bugs.
Thomas Kluyver -
Show More
@@ -146,7 +146,7 b' class HistoryManager(Configurable):'
146 -------
146 -------
147 An iterator over tuples: (session, line_number, command)
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 return self.db.execute("SELECT session, line, " +toget+ \
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
@@ -425,6 +425,12 b" def magic_history(self, parameter_s = ''):"
425 # For brevity
425 # For brevity
426 history_manager = self.shell.history_manager
426 history_manager = self.shell.history_manager
427
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)
433
428 # Check if output to specific file was requested.
434 # Check if output to specific file was requested.
429 try:
435 try:
430 outfname = opts['f']
436 outfname = opts['f']
@@ -458,9 +464,9 b" def magic_history(self, parameter_s = ''):"
458 matches_current_session = []
464 matches_current_session = []
459 for session, line, s in history_manager.get_hist_search(pattern, raw):
465 for session, line, s in history_manager.get_hist_search(pattern, raw):
460 if session == history_manager.session_number:
466 if session == history_manager.session_number:
461 matches_current_session.append(line, s)
467 matches_current_session.append((line, s))
462 continue
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 if matches_current_session:
470 if matches_current_session:
465 print("=== Current session: ===", file=outfile)
471 print("=== Current session: ===", file=outfile)
466 for line, s in matches_current_session:
472 for line, s in matches_current_session:
@@ -499,7 +505,7 b" def magic_history(self, parameter_s = ''):"
499 multiline = "\n" in inline
505 multiline = "\n" in inline
500 line_sep = '\n' if multiline else ''
506 line_sep = '\n' if multiline else ''
501 if print_nums:
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 line_sep), file=outfile, end='')
509 line_sep), file=outfile, end='')
504 if pyprompts:
510 if pyprompts:
505 print(">>> ", end="", file=outfile)
511 print(">>> ", end="", file=outfile)
General Comments 0
You need to be logged in to leave comments. Login now