X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=lib%2Flyx2lyx%2Flyx_1_3.py;h=35f04db8c4ef4b8ad96096f6355731b662e2a8b5;hb=6ab3be039ee0d74bbb7782bae8e1e0b278d14b3d;hp=91dae09ec0d1c81ef7e61df06c735bc7885874d8;hpb=26c0f379c7c997b9158ebe6792e62c52e6e21db3;p=lyx.git diff --git a/lib/lyx2lyx/lyx_1_3.py b/lib/lyx2lyx/lyx_1_3.py index 91dae09ec0..35f04db8c4 100644 --- a/lib/lyx2lyx/lyx_1_3.py +++ b/lib/lyx2lyx/lyx_1_3.py @@ -15,13 +15,13 @@ # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA """ Convert files to the file format generated by lyx 1.3""" import re from parser_tools import find_token, find_end_of, get_value,\ - find_token_exact, del_token + find_token_exact #################################################################### # Private helper functions @@ -30,6 +30,22 @@ def find_end_of_inset(lines, i): "Finds the matching \end_inset" return find_end_of(lines, i, "\\begin_inset", "\\end_inset") + +def del_token(lines, token, start, end): + """ del_token(lines, token, start, end) -> int + + Find the lower line in lines where token is the first element and + delete that line. + + Returns the number of lines remaining.""" + + k = find_token_exact(lines, token, start, end) + if k == -1: + return end + else: + del lines[k] + return end - 1 + # End of helper functions #################################################################### @@ -38,7 +54,7 @@ def change_insetgraphics(document): " Change inset Graphics." lines = document.body i = 0 - while 1: + while True: i = find_token(lines, "\\begin_inset Graphics", i) if i == -1: break @@ -97,7 +113,7 @@ def change_tabular(document): " Change tabular." lines = document.body i = 0 - while 1: + while True: i = find_token(lines, "