Author: rgheck
Date: Fri Nov  5 17:20:32 2010
New Revision: 36122
URL: http://www.lyx.org/trac/changeset/36122

Log:
Move del_token into the files where it is used. We could use such a
thing, but not one that returns what this does.

Modified:
   lyx-devel/trunk/lib/lyx2lyx/lyx_1_3.py
   lyx-devel/trunk/lib/lyx2lyx/lyx_1_4.py

Modified: lyx-devel/trunk/lib/lyx2lyx/lyx_1_3.py
==============================================================================
--- lyx-devel/trunk/lib/lyx2lyx/lyx_1_3.py      Fri Nov  5 17:18:20 2010        
(r36121)
+++ lyx-devel/trunk/lib/lyx2lyx/lyx_1_3.py      Fri Nov  5 17:20:32 2010        
(r36122)
@@ -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 @@
     "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
 ####################################################################
 

Modified: lyx-devel/trunk/lib/lyx2lyx/lyx_1_4.py
==============================================================================
--- lyx-devel/trunk/lib/lyx2lyx/lyx_1_4.py      Fri Nov  5 17:18:20 2010        
(r36121)
+++ lyx-devel/trunk/lib/lyx2lyx/lyx_1_4.py      Fri Nov  5 17:20:32 2010        
(r36122)
@@ -24,7 +24,7 @@
 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 @@
     "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
 ####################################################################
 

Reply via email to