Convert leading tabs to 4 spaces

This commit is contained in:
Charles Haley 2011-01-13 19:09:03 +00:00
parent 97a0ae8a3e
commit 5d00117f44

View File

@ -449,8 +449,13 @@ class FormatterUserFunction(FormatterFunction):
self.arg_count = arg_count self.arg_count = arg_count
self.program_text = program_text self.program_text = program_text
tabs = re.compile(r'^\t*')
def compile_user_function(name, doc, arg_count, eval_func): def compile_user_function(name, doc, arg_count, eval_func):
func = '\t' + eval_func.replace('\n', '\n\t') def replace_func(mo):
return mo.group().replace('\t', ' ')
func = ' ' + '\n '.join([tabs.sub(replace_func, line )
for line in eval_func.splitlines()])
prog = ''' prog = '''
from calibre.utils.formatter_functions import FormatterUserFunction from calibre.utils.formatter_functions import FormatterUserFunction
class UserFunction(FormatterUserFunction): class UserFunction(FormatterUserFunction):