This commit is contained in:
Kovid Goyal 2014-11-21 12:27:26 +05:30
parent 01f9a4a330
commit adc6a173a5
3 changed files with 3 additions and 2 deletions

View File

@ -359,8 +359,8 @@ class TextEdit(PlainTextEdit):
raw, count = pat.subn(template, raw) raw, count = pat.subn(template, raw)
if repl_is_func: if repl_is_func:
from calibre.gui2.tweak_book.search import show_function_debug_output from calibre.gui2.tweak_book.search import show_function_debug_output
show_function_debug_output(template)
template.end() template.end()
show_function_debug_output(template)
if count > 0: if count > 0:
start_pos = min(c.anchor(), c.position()) start_pos = min(c.anchor(), c.position())
c.insertText(raw) c.insertText(raw)

View File

@ -97,7 +97,7 @@ class Function(object):
return self.func(None, self.match_index, self.context_name, self.boss.current_metadata, dictionaries, self.data, self.functions) return self.func(None, self.match_index, self.context_name, self.boss.current_metadata, dictionaries, self.data, self.functions)
finally: finally:
sys.stdout, sys.stderr = oo, oe sys.stdout, sys.stderr = oo, oe
self.data, self.debug_buf, self.boss, self.functions = {}, None, None, {} self.data, self.boss, self.functions = {}, None, {}
class DebugOutput(Dialog): class DebugOutput(Dialog):

View File

@ -1188,6 +1188,7 @@ def get_search_function(search):
def show_function_debug_output(func): def show_function_debug_output(func):
if isinstance(func, Function): if isinstance(func, Function):
val = func.debug_buf.getvalue().strip() val = func.debug_buf.getvalue().strip()
func.debug_buf.truncate(0)
if val: if val:
from calibre.gui2.tweak_book.boss import get_boss from calibre.gui2.tweak_book.boss import get_boss
get_boss().gui.sr_debug_output.show_log(func.name, val) get_boss().gui.sr_debug_output.show_log(func.name, val)