#
# 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.1.5"""
import re
-import string
from parser_tools import find_token, find_token_backwards, find_re
####################################################################
def get_layout(line, default_layout):
" Get the line layout, beware of the empty layout."
- tokens = string.split(line)
+ tokens = line.split()
if len(tokens) > 1:
return tokens[1]
return default_layout
" Replace protected separator. "
lines = document.body
i=0
- while 1:
+ while True:
i = find_token(lines, "\\protected_separator", i)
if i == -1:
break
" Merge formula insets. "
lines = document.body
i=0
- while 1:
+ while True:
i = find_token(lines, "\\begin_inset Formula", i)
if i == -1: break
if lines[i+1] in math_env:
lines = document.body
lyxtable_re = re.compile(r".*\\LyXTable$")
i=0
- while 1:
+ while True:
i = find_re(lines, lyxtable_re, i)
if i == -1:
break
lines[i]='multicol5'
i = i + 1
- rows = int(string.split(lines[i])[0])
- columns = int(string.split(lines[i])[1])
+ rows = int(lines[i].split()[0])
+ columns = int(lines[i].split()[1])
i = i + rows + 1
for j in range(columns):
- col_info = string.split(lines[i])
+ col_info = lines[i].split()
if len(col_info) == 3:
lines[i] = lines[i] + '"" ""'
else:
- lines[i] = string.join(col_info[:3]) + ' "%s" ""' % col_info[3]
+ lines[i] = " ".join(col_info[:3]) + ' "%s" ""' % col_info[3]
i = i + 1
while lines[i]:
" Update table of contents. "
lines = document.body
i = 0
- while 1:
+ while True:
i = find_token(lines,
'\\begin_inset LatexCommand \\tableofcontents', i)
if i == -1:
for margin in margins:
i = 0
- while 1:
+ while True:
i = find_token(lines, margin, i)
if i == -1:
break
lines = document.body
# play safe, clean empty lines
- while 1:
+ while True:
if lines[i]:
break
del lines[i]
document.warning("Unexpected end of inset.")
j = find_token(lines, '\\begin_inset LatexDel }{', i)
- ref = string.join(lines[i:j])
+ ref = " ".join(lines[i:j])
del lines[i:j + 1]
# play safe, clean empty lines
- while 1:
+ while True:
if lines[i]:
break
del lines[i]
else:
document.warning("Unexpected end of inset.")
j = find_token(lines, '\\begin_inset LatexDel }', i)
- label = string.join(lines[i:j])
+ label = " ".join(lines[i:j])
del lines[i:j + 1]
return ref, label
" Update reference inset. "
lines = document.body
i = 0
- while 1:
+ while True:
i = find_token(lines, '\\begin_inset LatexCommand', i)
if i == -1:
return
- if string.split(lines[i])[-1] == "\\ref{":
+ if lines[i].split()[-1] == "\\ref{":
i = i + 1
ref, label = latexdel_getargs(document, i)
lines[i - 1] = "%s[%s]{%s}" % (lines[i - 1][:-1], ref, label)
lines = document.body
i = 0
latexdel_re = re.compile(r".*\\begin_inset LatexDel")
- while 1:
+ while True:
i = find_re(lines, latexdel_re, i)
if i == -1:
return
- lines[i] = string.replace(lines[i],
- '\\begin_inset LatexDel',
- '\\begin_inset LatexCommand')
+ lines[i] = lines[i].replace('\\begin_inset LatexDel',
+ '\\begin_inset LatexCommand')
- j = string.find(lines[i],'\\begin_inset')
+ j = lines[i].find('\\begin_inset')
lines.insert(i+1, lines[i][j:])
- lines[i] = string.strip(lines[i][:j])
+ lines[i] = lines[i][:j].strip()
i = i + 1
- if string.split(lines[i])[-1] in ("\\url{", "\\htmlurl{"):
+ if lines[i].split()[-1] in ("\\url{", "\\htmlurl{"):
i = i + 1
ref, label = latexdel_getargs(document, i)