]> git.lyx.org Git - features.git/commitdiff
Move del_token into the files where it is used. We could use such a
authorRichard Heck <rgheck@comcast.net>
Fri, 5 Nov 2010 16:20:32 +0000 (16:20 +0000)
committerRichard Heck <rgheck@comcast.net>
Fri, 5 Nov 2010 16:20:32 +0000 (16:20 +0000)
thing, but not one that returns what this does.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@36122 a592a061-630c-0410-9148-cb99ea01b6c8

lib/lyx2lyx/lyx_1_3.py
lib/lyx2lyx/lyx_1_4.py

index 91dae09ec0d1c81ef7e61df06c735bc7885874d8..3ef648c56ec6aedca53afdfed52ac50563321591 100644 (file)
@@ -21,7 +21,7 @@
 
 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
 ####################################################################
 
index 0e04b478cf10a86c7f8373c06033e27e431a5f05..4e1c95df5d5ec6ebfa75dde09b507ea40e27a557 100644 (file)
@@ -24,7 +24,7 @@ import re
 from os import access, F_OK
 import os.path
 from parser_tools import check_token, find_token, \
-                         get_value, del_token, is_nonempty_line, \
+                         get_value, is_nonempty_line, \
                          find_tokens, find_end_of, find_beginning_of, find_token_exact, find_tokens_exact, \
                          find_re, find_tokens_backwards
 from sys import stdin
@@ -84,6 +84,21 @@ 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
 ####################################################################