mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
RTFInput: first modifications to add_brackets.py
This commit is contained in:
parent
7fc2bbc947
commit
3682756f67
@ -82,6 +82,7 @@ class AddBrackets:
|
|||||||
|
|
||||||
def __initiate_values(self):
|
def __initiate_values(self):
|
||||||
"""
|
"""
|
||||||
|
Init temp values
|
||||||
"""
|
"""
|
||||||
self.__state = 'before_body'
|
self.__state = 'before_body'
|
||||||
self.__inline = {}
|
self.__inline = {}
|
||||||
@ -92,6 +93,7 @@ class AddBrackets:
|
|||||||
|
|
||||||
def __before_body_func(self, line):
|
def __before_body_func(self, line):
|
||||||
"""
|
"""
|
||||||
|
If we are before the body, not interest in changing anything
|
||||||
"""
|
"""
|
||||||
if self.__token_info == 'mi<mk<body-open_':
|
if self.__token_info == 'mi<mk<body-open_':
|
||||||
self.__state = 'in_body'
|
self.__state = 'in_body'
|
||||||
@ -172,11 +174,12 @@ class AddBrackets:
|
|||||||
self.__state = 'in_body'
|
self.__state = 'in_body'
|
||||||
|
|
||||||
def __check_brackets(self, in_file):
|
def __check_brackets(self, in_file):
|
||||||
self.__check_brack_obj = check_brackets.CheckBrackets\
|
"""
|
||||||
|
Return True if brackets match
|
||||||
|
"""
|
||||||
|
check_brack_obj = check_brackets.CheckBrackets\
|
||||||
(file = in_file)
|
(file = in_file)
|
||||||
good_br = self.__check_brack_obj.check_brackets()[0]
|
return check_brack_obj.check_brackets()[0]
|
||||||
if not good_br:
|
|
||||||
return True
|
|
||||||
|
|
||||||
def add_brackets(self):
|
def add_brackets(self):
|
||||||
"""
|
"""
|
||||||
@ -197,7 +200,7 @@ class AddBrackets:
|
|||||||
'%s\n' % self.__state)
|
'%s\n' % self.__state)
|
||||||
action(line)
|
action(line)
|
||||||
#Check bad brackets
|
#Check bad brackets
|
||||||
if not self.__check_brackets(self.__write_to):
|
if self.__check_brackets(self.__write_to):
|
||||||
copy_obj = copy.Copy(bug_handler = self.__bug_handler)
|
copy_obj = copy.Copy(bug_handler = self.__bug_handler)
|
||||||
if self.__copy:
|
if self.__copy:
|
||||||
copy_obj.copy_file(self.__write_to, "add_brackets.data")
|
copy_obj.copy_file(self.__write_to, "add_brackets.data")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user