rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
import SCons from SCons.Script.SConscript import SConsEnvironment SConsEnvironment.Chmod = SCons.Action.ActionFactory(os.chmod, lambda dest, mode: 'Chmod("%s", 0%o)' % (dest, mode)) def installPerm(target, source, env, perm): ''' install program with permission, will copy files recursively if needed ''' target_dir =...
def setLoggedSpawn(env, logfile = '', longarg=False, info=''): ''' This function modify env and allow logging of commands to a logfile. If the argument is too long a win32 spawn will be used instead of the system one ''' # # create a new spwn object ls = loggedSpawn(env, logfile, longarg, info) # replace the old SPAWN ...
sys.stderr.write("i,j=%d,%d\n" % (i,j))
def fix_oldfloatinset(lines): i = 0 while 1: i = find_token(lines, "\\begin_inset Float ", i) if i == -1: break j = find_token(lines, "collapsed", i) if j != -1: lines[j:j] = ["wide false"] sys.stderr.write("i,j=%d,%d\n" % (i,j)) i = i+1
elif line[-1:-1] == '\r' or line[-1:-1] == '\n':
elif line[-1:] == '\r' or line[-1:] == '\n':
def trim_eol(line): " Remove end of line char(s)." if line[-2:-1] == '\r': return line[:-2] elif line[-1:-1] == '\r' or line[-1:-1] == '\n': return line[:-1] else: # file with no EOL in last line return line
def checkCygwinPath(srcdir): ''' Adjust PATH for Win32 (Cygwin) ''' cygwin_path_fix = '' if os.name == 'nt': cygwin_path_fix = 'true' elif sys.platform == 'cygwin':
def checkTeXPaths(): ''' Determine the path-style needed by the TeX engine on Win32 (Cygwin) ''' windows_style_tex_paths = '' if os.name == 'nt' or sys.platform == 'cygwin':
def checkCygwinPath(srcdir): ''' Adjust PATH for Win32 (Cygwin) ''' cygwin_path_fix = '' if os.name == 'nt': cygwin_path_fix = 'true' elif sys.platform == 'cygwin': from tempfile import mkstemp fd, tmpfname = mkstemp(suffix='.ltx', dir='/tmp') os.write(fd, r'''
fd, tmpfname = mkstemp(suffix='.ltx', dir='/tmp')
fd, tmpfname = mkstemp(suffix='.ltx') wfd, wtmpfname = mkstemp(suffix='.ltx') if os.name == 'nt': inpname = tmpfname.replace('\\', '/') wtmpfname = wtmpfname.replace('\\', '/') else: inpname = cmdOutput('cygpath -m ' + tmpfname) wtmpfname = cmdOutput('cygpath -m ' + wtmpfname)
def checkCygwinPath(srcdir): ''' Adjust PATH for Win32 (Cygwin) ''' cygwin_path_fix = '' if os.name == 'nt': cygwin_path_fix = 'true' elif sys.platform == 'cygwin': from tempfile import mkstemp fd, tmpfname = mkstemp(suffix='.ltx', dir='/tmp') os.write(fd, r'''
inpname = cmdOutput('cygpath -m ' + tmpfname) wfd, wtmpfname = mkstemp(suffix='.ltx', dir='/tmp') wtmpfname = cmdOutput('cygpath -m ' + wtmpfname) os.write(wfd, r'\input{' + inpname + '}' )
os.write(wfd, r'\input{' + inpname.replace('~', '\\string~') + '}' )
def checkCygwinPath(srcdir): ''' Adjust PATH for Win32 (Cygwin) ''' cygwin_path_fix = '' if os.name == 'nt': cygwin_path_fix = 'true' elif sys.platform == 'cygwin': from tempfile import mkstemp fd, tmpfname = mkstemp(suffix='.ltx', dir='/tmp') os.write(fd, r'''
print "configure: cygwin detected; path correction is not needed" cygwin_path_fix = 'false'
print "configure: TeX engine needs posix-style paths in latex files" windows_style_tex_paths = 'false'
def checkCygwinPath(srcdir): ''' Adjust PATH for Win32 (Cygwin) ''' cygwin_path_fix = '' if os.name == 'nt': cygwin_path_fix = 'true' elif sys.platform == 'cygwin': from tempfile import mkstemp fd, tmpfname = mkstemp(suffix='.ltx', dir='/tmp') os.write(fd, r'''
print "configure: cygwin detected; path correction" srcdir = cmdOutput('cygpath -m ' + srcdir) print "srcdir = ", srcdir cygwin_path_fix = 'true'
print "configure: TeX engine needs windows-style paths in latex files" windows_style_tex_paths = 'true'
def checkCygwinPath(srcdir): ''' Adjust PATH for Win32 (Cygwin) ''' cygwin_path_fix = '' if os.name == 'nt': cygwin_path_fix = 'true' elif sys.platform == 'cygwin': from tempfile import mkstemp fd, tmpfname = mkstemp(suffix='.ltx', dir='/tmp') os.write(fd, r'''
return cygwin_path_fix
return windows_style_tex_paths
def checkCygwinPath(srcdir): ''' Adjust PATH for Win32 (Cygwin) ''' cygwin_path_fix = '' if os.name == 'nt': cygwin_path_fix = 'true' elif sys.platform == 'cygwin': from tempfile import mkstemp fd, tmpfname = mkstemp(suffix='.ltx', dir='/tmp') os.write(fd, r'''
cygwin_path_fix = checkCygwinPath(srcdir)
windows_style_tex_paths = checkTeXPaths()
def removeTempFiles(): # Final clean-up if not lyx_keep_temps: removeFiles(['chkconfig.sed', 'chkconfig.vars', \ 'wrap_chkconfig.ltx', 'wrap_chkconfig.log', \ 'chklayouts.tex', 'missfont.log', 'chklatex.ltx', 'chklatex.log'])
if cygwin_path_fix != '': addToRC(r'\cygwin_path_fix_needed %s' % cygwin_path_fix)
def removeTempFiles(): # Final clean-up if not lyx_keep_temps: removeFiles(['chkconfig.sed', 'chkconfig.vars', \ 'wrap_chkconfig.ltx', 'wrap_chkconfig.log', \ 'chklayouts.tex', 'missfont.log', 'chklatex.ltx', 'chklatex.log'])
lines[1] = '<features rotate="%s" islongtable="%s" endhead="%s" endfirsthead="%s" endfoot="%s" endlastfoot="%s">' % (bool_table[val[0]], bool_table[val[1]], val[2], val[3], val[4], val[5])
lines[1] = '<features rotate="%s" islongtable="%s" endhead="%s" endfirsthead="%s" endfoot="%s" endlastfoot="%s">' % (bool_table(val[0]), bool_table(val[1]), val[2], val[3], val[4], val[5])
def table_update(lines): lines[1] = string.replace(lines[1], '<Features', '<features') res = features_re.match( lines[1] ) if res: val = res.groups() lines[1] = '<features rotate="%s" islongtable="%s" endhead="%s" endfirsthead="%s" endfoot="%s" endlastfoot="%s">' % (bool_table[val[0]], bool_table[val[1]], val[2], val[3...
lines[i] = '<cell multicolumn="%s" alignment="%s" valignment="%s" topline="%s" bottomline="%s" leftline="%s" rightline="%s" rotate="%s" usebox="%s" width="%s" special="%s">' % ( val[0], align_table[val[1]], align_table[val[2]], bool_table[val[3]], bool_table[val[4]], bool_table[val[5]], bool_table[val[6]], bool_table[v...
lines[i] = '<cell multicolumn="%s" alignment="%s" valignment="%s" topline="%s" bottomline="%s" leftline="%s" rightline="%s" rotate="%s" usebox="%s" width="%s" special="%s">' % ( val[0], align_table[val[1]], align_table[val[2]], bool_table(val[3]), bool_table(val[4]), bool_table(val[5]), bool_table(val[6]), bool_table(v...
def table_update(lines): lines[1] = string.replace(lines[1], '<Features', '<features') res = features_re.match( lines[1] ) if res: val = res.groups() lines[1] = '<features rotate="%s" islongtable="%s" endhead="%s" endfirsthead="%s" endfoot="%s" endlastfoot="%s">' % (bool_table[val[0]], bool_table[val[1]], val[2], val[3...
lines[i] = '<row topline="%s" bottomline="%s" newpage="%s">' % (bool_table[val[0]], bool_table[val[1]], bool_table[val[2]])
lines[i] = '<row topline="%s" bottomline="%s" newpage="%s">' % (bool_table(val[0]), bool_table(val[1]), bool_table(val[2]))
def table_update(lines): lines[1] = string.replace(lines[1], '<Features', '<features') res = features_re.match( lines[1] ) if res: val = res.groups() lines[1] = '<features rotate="%s" islongtable="%s" endhead="%s" endfirsthead="%s" endfoot="%s" endlastfoot="%s">' % (bool_table[val[0]], bool_table[val[1]], val[2], val[3...
% ( align_table[val[0]], align_table[val[1]], bool_table[val[2]], bool_table[val[3]], val[4],val[5])
% ( align_table[val[0]], align_table[val[1]], bool_table(val[2]), bool_table(val[3]), val[4],val[5])
def table_update(lines): lines[1] = string.replace(lines[1], '<Features', '<features') res = features_re.match( lines[1] ) if res: val = res.groups() lines[1] = '<features rotate="%s" islongtable="%s" endhead="%s" endfirsthead="%s" endfoot="%s" endlastfoot="%s">' % (bool_table[val[0]], bool_table[val[1]], val[2], val[3...
"subsection" : "@Section@.\\arabic{subsection}", "subsubsection" : "@Subsection@.\\arabic{subsubsection}", "paragraph" : "@Subsubsection@.\\arabic{paragraph}", "subparagraph" : "@Paragraph@.\\arabic{subparagraph}"}
"subsection" : "\\arabic{section}.\\arabic{subsection}", "subsubsection" : "\\arabic{section}.\\arabic{subsection}.\\arabic{subsubsection}", "paragraph" : "\\arabic{section}.\\arabic{subsection}.\\arabic{subsubsection}.\\arabic{paragraph}", "subparagraph" : "\\arabic{section}.\\arabic{subsection}.\\arabic{subsu...
def convert(lines): " Convert to new format." re_Comment = re.compile(r'^(\s*)#') re_Empty = re.compile(r'^(\s*)$') re_Format = re.compile(r'^(\s*)(Format)(\s+)(\S+)', re.IGNORECASE) re_Preamble = re.compile(r'^(\s*)Preamble', re.IGNORECASE) re_EndPreamble = re.compile(r'^(\s*)EndPreamble', re.IGNORECASE) re_MaxCounter...
i = i + 1
def convert_ertbackslash(lines, i, ert): for c in ert: if c == '\\': lines[i] = lines[i] + '\\backslash ' lines.insert(i, '') i = i + 1 else: lines[i] = lines[i] + c return i
if pb_top !=-1 or line_top != -1 or vspace_bot != -1:
if pb_top !=-1 or line_top != -1 or vspace_top != -1:
def convert_breaks(file): i = 0 while 1: i = find_token(file.body, "\\begin_layout", i) if i == -1: return i = i + 1 line_top = find(file.body[i],"\\line_top") line_bot = find(file.body[i],"\\line_bottom") pb_top = find(file.body[i],"\\pagebreak_top") pb_bot = find(file.body[i],"\\pagebreak_bottom") vspace_...
if pb_top !=-1 or line_top != -1 or vspace_bot != -1:
if pb_bot !=-1 or line_bot != -1 or vspace_bot != -1:
def convert_breaks(file): i = 0 while 1: i = find_token(file.body, "\\begin_layout", i) if i == -1: return i = i + 1 line_top = find(file.body[i],"\\line_top") line_bot = find(file.body[i],"\\line_bottom") pb_top = find(file.body[i],"\\pagebreak_top") pb_bot = find(file.body[i],"\\pagebreak_bottom") vspace_...
packages = {'a4':'none', 'a4wide':'a4', 'widemarginsa4':'a4wide'}
packages = {'default':'none','a4':'none', 'a4wide':'a4', 'widemarginsa4':'a4wide'}
def convert_paperpackage(file): i = find_token(file.header, "\\paperpackage", 0) if i == -1: file.warning("Malformed lyx file: Missing '\\paperpackage'.") return packages = {'a4':'none', 'a4wide':'a4', 'widemarginsa4':'a4wide'} paperpackage = split(file.header[i])[1] file.header[i] = replace(file.header[i], paperpacka...
copyfileobj(tmp, open(file,"wb"))
copyfileobj(tmp, open(file,"wb"), 1)
def crop_files(pnmcrop, basename): t = pipes.Template() t.append("%s -left" % pnmcrop, '--') t.append("%s -right" % pnmcrop, '--') for file in glob.glob("%s*.ppm" % basename): tmp = mkstemp() new = t.open(file, "r") copyfileobj(new, tmp) if not new.close(): copyfileobj(tmp, open(file,"wb"))
if (dtl_tools):
if (dtl_tools == 'true'):
def checkLatex(dtl_tools): ''' Check latex, return lyx_check_config ''' if (dtl_tools): # Windows only: DraftDVI converter_entry = r'''\converter latex dvi2 "%%" "latex"
if (dtl_tools):
if (dtl_tools == 'true'):
def checkFormatEntries(dtl_tools): ''' Check all formats (\Format entries) ''' checkViewer('a Tgif viewer and editor', ['tgif'], rc_entry = [r'\Format tgif obj Tgif "" "%%" "%%" "vector"']) # checkViewer('a FIG viewer and editor', ['xfig'], rc_entry = [r'\Format fig fig FIG ...
break
continue
def read(self): """Reads a file into the self.header and self.body parts, from self.input.""" preamble = 0
self.body.append(string.split(line)[0])
self.body.append(line)
def read(self): """Reads a file into the self.header and self.body parts, from self.input.""" preamble = 0
paragraph_bellow = ['','\\begin_layout Standard','','']
paragraph_below = ['','\\begin_layout Standard','','']
def convert_breaks(file): i = 0 while 1: i = find_token(file.body, "\\begin_layout", i) if i == -1: return i = i + 1 line_top = find(file.body[i],"\\line_top") line_bot = find(file.body[i],"\\line_bottom") pb_top = find(file.body[i],"\\pagebreak_top") pb_bot = find(file.body[i],"\\pagebreak_bottom") vspace_...
paragraph_bellow.extend(['\\lyxline ',''])
paragraph_below.extend(['\\lyxline ',''])
def convert_breaks(file): i = 0 while 1: i = find_token(file.body, "\\begin_layout", i) if i == -1: return i = i + 1 line_top = find(file.body[i],"\\line_top") line_bot = find(file.body[i],"\\line_bottom") pb_top = find(file.body[i],"\\pagebreak_top") pb_bot = find(file.body[i],"\\pagebreak_bottom") vspace_...
paragraph_bellow.extend(['\\begin_inset VSpace ' + vspace_bot_value,'\\end_inset','',''])
paragraph_below.extend(['\\begin_inset VSpace ' + vspace_bot_value,'\\end_inset','',''])
def convert_breaks(file): i = 0 while 1: i = find_token(file.body, "\\begin_layout", i) if i == -1: return i = i + 1 line_top = find(file.body[i],"\\line_top") line_bot = find(file.body[i],"\\line_bottom") pb_top = find(file.body[i],"\\pagebreak_top") pb_bot = find(file.body[i],"\\pagebreak_bottom") vspace_...
paragraph_bellow.extend(['\\newpage ','']) paragraph_bellow.extend(['\\end_layout',''])
paragraph_below.extend(['\\newpage ','']) paragraph_below.extend(['\\end_layout',''])
def convert_breaks(file): i = 0 while 1: i = find_token(file.body, "\\begin_layout", i) if i == -1: return i = i + 1 line_top = find(file.body[i],"\\line_top") line_bot = find(file.body[i],"\\line_bottom") pb_top = find(file.body[i],"\\pagebreak_top") pb_bot = find(file.body[i],"\\pagebreak_bottom") vspace_...
file.body[k + 1: k + 1] = paragraph_bellow
file.body[k + 1: k + 1] = paragraph_below
def convert_breaks(file): i = 0 while 1: i = find_token(file.body, "\\begin_layout", i) if i == -1: return i = i + 1 line_top = find(file.body[i],"\\line_top") line_bot = find(file.body[i],"\\line_bottom") pb_top = find(file.body[i],"\\pagebreak_top") pb_bot = find(file.body[i],"\\pagebreak_bottom") vspace_...
revert_valignment_middle, revert_breaks, convert_frameless_box]],
revert_valignment_middle, revert_breaks, convert_frameless_box, remove_branches]],
def remove_quotestimes(file): i = find_token(file.header, '\\quotes_times', 0) if i == -1: return del file.header[i]
checkProg('a LaTeX -> LyX converter', ['tex2lyx -f $$i $$o', \ 'tex2lyx' + version_suffix + ' -f $$i $$o' ], rc_entry = [ r'\converter latex lyx "%%" ""' ])
checkProg('a LaTeX/Noweb -> LyX converter', ['tex2lyx', 'tex2lyx' + version_suffix], rc_entry = [r'''\converter latex lyx "%% -f $$i $$o" "" \converter literate lyx "%% -n -f $$i $$o" ""'''])
def checkConverterEntries(): ''' Check all converters (\converter entries) ''' checkProg('the pdflatex program', ['pdflatex $$i'], rc_entry = [ r'\converter pdflatex pdf2 "%%" "latex"' ]) ''' If we're running LyX in-place then tex2lyx will be found in ../src/tex2lyx. Add this directory to the PATH temporarily ...
checkProg('a Noweb -> LyX converter', ['noweb2lyx' + version_suffix + ' $$i $$o'], path = ['./reLyX'], rc_entry = [ r'\converter literate lyx "%%" ""' ])
def checkConverterEntries(): ''' Check all converters (\converter entries) ''' checkProg('the pdflatex program', ['pdflatex $$i'], rc_entry = [ r'\converter pdflatex pdf2 "%%" "latex"' ]) ''' If we're running LyX in-place then tex2lyx will be found in ../src/tex2lyx. Add this directory to the PATH temporarily ...
checkProg('an LaTeX -> OpenOffice.org LaTeX converter', ['oolatex $$i', 'oolatex.sh $$i'],
checkProg('a LaTeX -> OpenOffice.org converter', ['oolatex $$i', 'oolatex.sh $$i'],
def checkConverterEntries(): ''' Check all converters (\converter entries) ''' checkProg('the pdflatex program', ['pdflatex $$i'], rc_entry = [ r'\converter pdflatex pdf2 "%%" "latex"' ]) ''' If we're running LyX in-place then tex2lyx will be found in ../src/tex2lyx. Add this directory to the PATH temporarily ...
subcaptionText = get_value(lines, "subcaption", i+1, j) if subcaptionText != "": subcaptionText = '"'+subcaptionText+'"'
subcaptionText = "" subcaptionLine = find_token(lines, "subcaption", i+1, j) if subcaptionLine != -1: subcaptionText = lines[subcaptionLine][11:] if subcaptionText != "": subcaptionText = '"'+subcaptionText+'"'
def remove_figinset(lines): i = 0 while 1: i = find_token(lines, "\\begin_inset Figure", i) if i == -1: break j = find_end_of_inset(lines, i) if ( len(string.split(lines[i])) > 2 ): lyxwidth = string.split(lines[i])[3]+"pt" lyxheight = string.split(lines[i])[4]+"pt" else: lyxwidth = "" lyxheight = "" filename = get_v...
file.preamble[0:0] = conv[paperpackage]
file.preamble[0:0] = [conv[paperpackage]]
def remove_paperpackage(file): i = find_token(file.header, '\\paperpackage', 0) if i == -1: return paperpackage = split(file.header[i])[1] if paperpackage in ("a4", "a4wide", "widemarginsa4"): conv = {"a4":"\\usepackage{a4}","a4wide": "\\usepackage{a4wide}", "widemarginsa4": "\\usepackage[widemargins]{a4}"} # for co...
rc_entry = [r'\Format tgif obj Tgif "" "%%" "%%" ""'])
rc_entry = [r'\Format tgif obj Tgif "" "%%" "%%" "vector"'])
def checkFormatEntries(): ''' Check all formats (\Format entries) ''' checkViewer('a Tgif viewer and editor', ['tgif'], rc_entry = [r'\Format tgif obj Tgif "" "%%" "%%" ""']) # checkViewer('a FIG viewer and editor', ['xfig'], rc_entry = [r'\Format fig fig FIG ""...
rc_entry = [r'\Format fig fig FIG "" "%%" "%%" ""'])
rc_entry = [r'\Format fig fig FIG "" "%%" "%%" "vector"'])
def checkFormatEntries(): ''' Check all formats (\Format entries) ''' checkViewer('a Tgif viewer and editor', ['tgif'], rc_entry = [r'\Format tgif obj Tgif "" "%%" "%%" ""']) # checkViewer('a FIG viewer and editor', ['xfig'], rc_entry = [r'\Format fig fig FIG ""...
rc_entry = [r'\Format agr agr Grace "" "%%" "%%" ""'])
rc_entry = [r'\Format agr agr Grace "" "%%" "%%" "vector"'])
def checkFormatEntries(): ''' Check all formats (\Format entries) ''' checkViewer('a Tgif viewer and editor', ['tgif'], rc_entry = [r'\Format tgif obj Tgif "" "%%" "%%" ""']) # checkViewer('a FIG viewer and editor', ['xfig'], rc_entry = [r'\Format fig fig FIG ""...
rc_entry = [r'''\Format eps eps EPS "" "%%" "" "" \Format ps ps Postscript t "%%" "" "document"'''])
rc_entry = [r'''\Format eps eps EPS "" "%%" "" "vector" \Format ps ps Postscript t "%%" "" "document,vector"'''])
def checkFormatEntries(): ''' Check all formats (\Format entries) ''' checkViewer('a Tgif viewer and editor', ['tgif'], rc_entry = [r'\Format tgif obj Tgif "" "%%" "%%" ""']) # checkViewer('a FIG viewer and editor', ['xfig'], rc_entry = [r'\Format fig fig FIG ""...
rc_entry = [r'''\Format pdf pdf "PDF (ps2pdf)" P "%%" "" "document" \Format pdf2 pdf "PDF (pdflatex)" F "%%" "" "document" \Format pdf3 pdf "PDF (dvipdfm)" m "%%" "" "document"'''])
rc_entry = [r'''\Format pdf pdf "PDF (ps2pdf)" P "%%" "" "document,vector" \Format pdf2 pdf "PDF (pdflatex)" F "%%" "" "document,vector" \Format pdf3 pdf "PDF (dvipdfm)" m "%%" "" "document,vector"'''])
def checkFormatEntries(): ''' Check all formats (\Format entries) ''' checkViewer('a Tgif viewer and editor', ['tgif'], rc_entry = [r'\Format tgif obj Tgif "" "%%" "%%" ""']) # checkViewer('a FIG viewer and editor', ['xfig'], rc_entry = [r'\Format fig fig FIG ""...
rc_entry = [r'\Format dvi dvi DVI D "%%" "" "document"'])
rc_entry = [r'\Format dvi dvi DVI D "%%" "" "document,vector"'])
def checkFormatEntries(): ''' Check all formats (\Format entries) ''' checkViewer('a Tgif viewer and editor', ['tgif'], rc_entry = [r'\Format tgif obj Tgif "" "%%" "%%" ""']) # checkViewer('a FIG viewer and editor', ['xfig'], rc_entry = [r'\Format fig fig FIG ""...
addToRC(r'\Format dvi2 dvi DraftDVI "" "" "document"')
addToRC(r'\Format dvi2 dvi DraftDVI "" "" "document,vector"')
def checkFormatEntries(): ''' Check all formats (\Format entries) ''' checkViewer('a Tgif viewer and editor', ['tgif'], rc_entry = [r'\Format tgif obj Tgif "" "%%" "%%" ""']) # checkViewer('a FIG viewer and editor', ['xfig'], rc_entry = [r'\Format fig fig FIG ""...
\Format rtf rtf "Rich Text Format" "" "" "" "document" \Format sxw sxw "OpenOffice.Org Writer" O "" "" "document" \Format wmf wmf "Windows Meta File" "" "" "" "" \Format word doc "MS Word" W "" "" "document"
\Format rtf rtf "Rich Text Format" "" "" "" "document,vector" \Format sxw sxw "OpenOffice.Org Writer" O "" "" "document,vector" \Format wmf wmf "Windows Meta File" "" "" "" "vector" \Format word doc "MS Word" W "" "" "document,vector"
def checkFormatEntries(): ''' Check all formats (\Format entries) ''' checkViewer('a Tgif viewer and editor', ['tgif'], rc_entry = [r'\Format tgif obj Tgif "" "%%" "%%" ""']) # checkViewer('a FIG viewer and editor', ['xfig'], rc_entry = [r'\Format fig fig FIG ""...
addToRC(r'\cygwin_path_fix_needed true')
cygwin_path_fix = 'true'
def checkCygwinPath(srcdir): ''' Adjust PATH for Win32 (Cygwin) ''' if sys.platform == 'cygwin': from tempfile import mkstemp fd, tmpfname = mkstemp(suffix='.ltx', dir='/tmp') os.write(fd, r'''
values[key] = val.strip("'\n")
val = val.strip() values[key] = val.strip("'")
def checkLatexConfig(check_config, bool_docbook, bool_linuxdoc): ''' Explore the LaTeX configuration ''' print 'checking LaTeX configuration... ', # First, remove the files that we want to re-create removeFiles(['textclass.lst', 'packages.lst', 'chkconfig.sed']) # if not check_config: print ' default values' print '+ch...
checkCygwinPath(srcdir)
cygwin_path_fix = checkCygwinPath(srcdir)
def removeTempFiles(): # Final clean-up if not lyx_keep_temps: removeFiles(['chkconfig.sed', 'chkconfig.vars', \ 'wrap_chkconfig.ltx', 'wrap_chkconfig.log', \ 'chklayouts.tex', 'missfont.log', 'chklatex.ltx', 'chklatex.log'])
def addToConfig(lines, newline=2):
def addToConfig(lines, desc=''):
def addToConfig(lines, newline=2): ''' utility function: shortcut for appending lines to outfile add newline at the end of lines. ''' global config_content if lines.strip() != '': config_content += lines + '\n'*newline
config_content += lines + '\n'*newline
if desc != '': config_content += desc + '\n' config_content += lines + '\n\n'
def addToConfig(lines, newline=2): ''' utility function: shortcut for appending lines to outfile add newline at the end of lines. ''' global config_content if lines.strip() != '': config_content += lines + '\n'*newline
result[header[1]] = True
result[header[1]] = 1
def configString(lines, desc=''): text = '' if lines.strip() != '': if desc != '': text += '/* ' + desc + ' */\n' text += lines + '\n\n' return text
result[header[1]] = False
result[header[1]] = 0
def configString(lines, desc=''): text = '' if lines.strip() != '': if desc != '': text += '/* ' + desc + ' */\n' text += lines + '\n\n' return text
result[func[1]] = True
result[func[1]] = 1
cont += configString('/* #undef %s */' % header[1], desc = description)
result[func[1]] = False
result[func[1]] = 0
cont += configString('/* #undef %s */' % header[1], desc = description)
result[t[1]] = True
result[t[1]] = 1
cont += configString('/* #undef %s */' % func[1], desc = description)
result[t[1]] = False
result[t[1]] = 0
cont += configString('/* #undef %s */' % func[1], desc = description)
result[lib[1]] = False
result[lib[1]] = 0
cont += configString('/* #undef %s */' % t[1], desc = description)
result[lib[1]] = True
result[lib[1]] = 1
cont += configString('/* #undef %s */' % t[1], desc = description)
result[test[1]] = True
result[test[1]] = 1
cont += configString('/* #undef %s */' % lib[1], desc = description)
result[test[1]] = False
result[test[1]] = 0
cont += configString('/* #undef %s */' % lib[1], desc = description)
version_suffix = op[23:]
version_suffix = op[22:]
def cmdOutput(cmd): '''utility function: run a command and get its output as a string cmd: command to run ''' fout = os.popen(cmd) output = fout.read() fout.close() return output.strip()
removeFiles(['chkltex.ltx', 'chklatex.log'])
removeFiles(['chklatex.ltx', 'chklatex.log'])
def checkProg(description, progs, rc_entry = [], path = [] ): ''' This function will search a program in $PATH plus given path If found, return directory and program name (not the options). description: description of the program progs: check programs, for each prog, the first word is used for searching but the whole...
rc_entry = [ r'\converter literate lyx "%%" ""' ]) checkProg('a Noweb -> LaTeX converter', ['noweave' + version_suffix + ' -delay -index $$i > $$o'], path = ['./reLyX'], rc_entry = [ r'\converter literate latex "%%" ""' ])
rc_entry = [ r'\converter literate lyx "%%" ""' ]) checkProg('a Noweb -> LaTeX converter', ['noweave -delay -index $$i > $$o'], rc_entry = [ r'\converter literate latex "%%" ""' ])
def checkProg(description, progs, rc_entry = [], path = [] ): ''' This function will search a program in $PATH plus given path If found, return directory and program name (not the options). description: description of the program progs: check programs, for each prog, the first word is used for searching but the whole...
cl = open('chklayouts.tex', 'w')
def checkProg(description, progs, rc_entry = [], path = [] ): ''' This function will search a program in $PATH plus given path If found, return directory and program name (not the options). description: description of the program progs: check programs, for each prog, the first word is used for searching but the whole...
cl.write( "\\TestDocClass{%s}{%s}\n" % \ ( classname, line[1:].strip() ) )
testclasses.append("\\TestDocClass{%s}{%s}" % (classname, line[1:].strip()))
def checkProg(description, progs, rc_entry = [], path = [] ): ''' This function will search a program in $PATH plus given path If found, return directory and program name (not the options). description: description of the program progs: check programs, for each prog, the first word is used for searching but the whole...
print "Checking whether TeX allows spaces in file names... ",
def checkProg(description, progs, rc_entry = [], path = [] ): ''' This function will search a program in $PATH plus given path If found, return directory and program name (not the options). description: description of the program progs: check programs, for each prog, the first word is used for searching but the whole...
if not lyx_check_config:
if lyx_check_config: print "Checking whether TeX allows spaces in file names... ",
def checkProg(description, progs, rc_entry = [], path = [] ): ''' This function will search a program in $PATH plus given path If found, return directory and program name (not the options). description: description of the program progs: check programs, for each prog, the first word is used for searching but the whole...
if ''.join(cmdOutput('latex -interaction=nonstopmode "a b"')).find('working') != -1:
if ''.join(cmdOutput(LATEX + ' -interaction=nonstopmode "a b"')).find('working') != -1:
def checkProg(description, progs, rc_entry = [], path = [] ): ''' This function will search a program in $PATH plus given path If found, return directory and program name (not the options). description: description of the program progs: check programs, for each prog, the first word is used for searching but the whole...
path: additional path rc_entry: entry to outfile, can be emtpy, one pattern (%% for chosen prog or 'none'), or one for each prog and 'none'. NOTE: if you do not want 'none' entry to be added to the RC file, specify an entry for each prog and use '' for 'none' entry. FIXME: under windows, we should check registry ins...
path: additional pathes rc_entry: entry to outfile, can be 1. emtpy: no rc entry will be added 2. one pattern: %% will be replaced by the first found program, or 'none' is no program is found. 3. several patterns for each prog and 'none'. This is used when different programs have different usages. If you do not want '...
def checkProg(description, progs, rc_entry = [], path = [] ): ''' This function will search a program in $PATH plus given path If found, return directory and program name (not the options). description: description of the program progs: check programs, for each prog, the first word is used for searching but the whole...
checkProg('a Postscript previewer', ['gsview32', 'gv', 'ghostview -swap', 'kghostview'],
checkProg('a Postscript previewer', ['gv', 'ghostview -swap', 'kghostview'],
def checkFormatEntries(): ''' Check all formats (\Format entries) ''' checkProg('a Tgif viewer and editor', ['tgif'], rc_entry = [ r'\Format tgif obj Tgif "" "%%" "%%"']) # checkProg('a FIG viewer and editor', ['xfig'], rc_entry = [ r'\Format fig fig FIG "" "%%"...
checkProg('a PDF previewer', ['acrobat', 'acrord32', 'gsview32', \ 'acroread', 'gv', 'ghostview', 'xpdf', 'kpdf', 'kghostview'],
checkProg('a PDF previewer', ['acrobat', 'acroread', 'gv', 'ghostview', \ 'xpdf', 'kpdf', 'kghostview'],
def checkFormatEntries(): ''' Check all formats (\Format entries) ''' checkProg('a Tgif viewer and editor', ['tgif'], rc_entry = [ r'\Format tgif obj Tgif "" "%%" "%%"']) # checkProg('a FIG viewer and editor', ['xfig'], rc_entry = [ r'\Format fig fig FIG "" "%%"...
checkProg('a DVI previewer', ['xdvi', 'windvi', 'yap', 'kdvi'],
checkProg('a DVI previewer', ['xdvi', 'kdvi'],
def checkFormatEntries(): ''' Check all formats (\Format entries) ''' checkProg('a Tgif viewer and editor', ['tgif'], rc_entry = [ r'\Format tgif obj Tgif "" "%%" "%%"']) # checkProg('a FIG viewer and editor', ['xfig'], rc_entry = [ r'\Format fig fig FIG "" "%%"...
print 'Warning: Can not find an appropriate boost library in %s.' % path print 'Allowed versions are ', ', '.join(versions)
if isDebug: print 'Failed to find the debug version of boost', ' or '.join(versions) else: print 'Failed to find the release version of boost', ' or '.join(versions)
def checkBoostLibraries(conf, libs, lib_paths, inc_paths, versions, isDebug): ''' look for boost libraries libs: library names lib_paths: try these paths for boost libraries inc_paths: try these paths for boost headers versions: supported boost versions isDebug: if true, use debug libraries ''' conf.Message('Checki...
""" % argv[0]
""" % os.path.basename(argv[0])
def main(argv): print """# This is a Makefile for the TOC.lyx files.
lang = lang_pattern.match(os.path.basename(file))
file = os.path.basename(file) lang = lang_pattern.match(file)
def main(argv): print """# This is a Makefile for the TOC.lyx files.
print 'TOC.lyx:', ('.lyx ' + srcdir + '/').join(possible_documents) + '.lyx' print '\tpython %s/doc_toc.py' % srcdir
print 'TOC.lyx: $(srcdir)/' + '.lyx $(srcdir)/'.join(possible_documents) + '.lyx' print '\tpython $(srcdir)/doc_toc.py'
def main(argv): print """# This is a Makefile for the TOC.lyx files.
if srcdir + '/' + toc_name in languages[lang]: languages[lang].remove(srcdir + '/' + toc_name)
def main(argv): print """# This is a Makefile for the TOC.lyx files.
print toc_name + ':', ' '.join(languages[lang]) print '\tpython %s/doc_toc.py %s' % (srcdir, lang)
print toc_name + ': $(srcdir)/' + ' $(srcdir)/'.join(languages[lang]) print '\tpython $(srcdir)/doc_toc.py %s' % lang
def main(argv): print """# This is a Makefile for the TOC.lyx files.
print 'TOCs =', ' '.join(tocs)
print 'tocfiles =', ' '.join(tocs)
def main(argv): print """# This is a Makefile for the TOC.lyx files.
if not option == None:
if option != None:
def convert_bibitem(document): """ Convert
import SCons.Node def processLang(env, folder): """ Process translations (.po files) in a po/ dir This is copied from KDE knetstats-1.5/admin/kde.py FIXME: imcomplete """ import glob dir=SCons.Node.FS.default_fs.Dir(folder).srcnode() fld=dir.srcnode() tmptransfiles = glob.glob(str(fld)+'/*.po') transfiles=[] if env.h...
def checkMsgFmt(conf): ''' check the existence of command msgfmt ''' conf.Message('Checking for gettext command msgfmt...') res = conf.TryAction('msgfmt --help') conf.Result(res[0]) if res[0]: return 'msgfmt' else: return None
def checkBoostLibraries(conf, lib, pathes): ''' look for boost libraries ''' conf.Message('Checking for boost library %s... ' % lib) for path in pathes: # direct form: e.g. libboost_iostreams.a if os.path.isfile(os.path.join(path, 'lib%s.a' % lib)): conf.Result('yes') return (path, lib) # check things like libboost_ios...
config_content += desc + '\n'
config_content += '/* ' + desc + ' */\n'
def addToConfig(lines, desc=''): ''' utility function: shortcut for appending lines to outfile add newline at the end of lines. ''' global config_content if lines.strip() != '': if desc != '': config_content += desc + '\n' config_content += lines + '\n\n'
extern size_t iconv(iconv_t cd, const char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
#ifdef __cplusplus
def convert_vspace(file):
def get_par_params(lines, i): par_params = ('added_space_bottom', 'added_space_top', 'align', 'labelwidthstring', 'line_bottom', 'line_top', 'noindent', 'pagebreak_bottom', 'pagebreak_top', 'paragraph_spacing', 'start_of_appendix') params = '' while lines[i][:1] == '\\' and split(lines[i][1:])[0] in par_params: param...
def convert_vspace(file): # Get default spaceamount i = find_token(file.header, '\\defskip', 0) if i == -1: defskipamount = 'medskip' else: defskipamount = split(file.header[i])[1] # Convert the insets i = 0 while 1: i = find_token(file.body, '\\begin_inset VSpace', i) if i == -1: return spaceamount = split(file.body...
defskipamount = split(file.header[i])[1]
defskipamount = split(file.header[i])[1] keys = {"\\begin_inset" : "vspace", "\\lyxline" : "lyxline", "\\newpage" : "newpage"} keywords_top = {"vspace" : "\\added_space_top", "lyxline" : "\\line_top", "newpage" : "\\pagebreak_top"} keywords_bot = {"vspace" : "\\added_space_bottom", "lyxline" : "\\line_bottom", "newpag...
def convert_vspace(file): # Get default spaceamount i = find_token(file.header, '\\defskip', 0) if i == -1: defskipamount = 'medskip' else: defskipamount = split(file.header[i])[1] # Convert the insets i = 0 while 1: i = find_token(file.body, '\\begin_inset VSpace', i) if i == -1: return spaceamount = split(file.body...
i = find_token(file.body, '\\begin_inset VSpace', i) if i == -1: return spaceamount = split(file.body[i])[2] paragraph_start = 1 start = get_paragraph(file.body, i) + 1 for k in range(start, i): if is_nonempty_line(file.body[k]): paragraph_start = 0 break paragraph_end = 1 j = find_end_of_inset(file.body, i) if j == ...
i = find_tokens(file.body, tokens, i) if i == -1: return lines = list() insets = list() lines.append(split(file.body[i])) insets.append(keys[lines[0][0]]) paragraph_start = 1 start = get_paragraph(file.body, i) + 1 params = get_par_params(file.body, start) while file.body[start][:1] == '\\' and split(file.body[star...
def convert_vspace(file): # Get default spaceamount i = find_token(file.header, '\\defskip', 0) if i == -1: defskipamount = 'medskip' else: defskipamount = split(file.header[i])[1] # Convert the insets i = 0 while 1: i = find_token(file.body, '\\begin_inset VSpace', i) if i == -1: return spaceamount = split(file.body...
revert_valignment_middle, convert_vspace, convert_frameless_box]],
revert_valignment_middle, revert_breaks, convert_frameless_box]],
def remove_paperpackage(file): i = find_token(file.header, '\\paperpackage', 0) if i == -1: return paperpackage = split(file.header[i])[1] if paperpackage in ("a4", "a4wide", "widemarginsa4"): conv = {"a4":"\\usepackage{a4}","a4wide": "\\usepackage{a4wide}", "widemarginsa4": "\\usepackage[widemargins]{a4}"} # for co...
return string.split(lines[i])[1]
if len(string.split(lines[i])) > 1: return string.split(lines[i])[1] else: return ""
def get_value(lines, token, start, end = 0): i = find_token2(lines, token, start, end) if i == -1: return "" return string.split(lines[i])[1]
lines[j-1:j-1] += ['\\begin_inset ERT', 'status ' + params['collapsed'],
lines[j-1:j-1] = ['\\begin_inset ERT', 'status ' + params['collapsed'],
def convert_frameless_box(lines, opt): pos = ['t', 'c', 'b'] inner_pos = ['c', 't', 'b', 's'] i = 0 while 1: i = find_token(lines, '\\begin_inset Frameless', i) if i == -1: return j = find_end_of_inset(lines, i) if j == -1: opt.warning("Malformed LyX file: Missing '\\end_inset'\n") i = i + 1 continue del lines[i] # Ga...
lines[i:i+1] = ["\\begin_inset Note", "collapsed true", "", "\layout Standard", ""]
txt = string.lstrip(lines[i][18:]) new = ["\\begin_inset Note", "collapsed true", ""] if len(txt) > 0: new = new + ["\layout Standard", "", txt] j = find_token(lines, "\\end_inset", i) if j == -1: break for k in range(i+1, j): new = new + ["\layout Standard", ""] tmp = string.split(lines[k], '\\') new = new + [tmp[0]] ...
def change_infoinset(lines): i = 0 while 1: i = find_token(lines, "\\begin_inset Info", i) if i == -1: break lines[i:i+1] = ["\\begin_inset Note", "collapsed true", "", "\layout Standard", ""] i = i+5
checkViewer('a Tif viewer and editor', ['tgif'],
checkViewer('a Tgif viewer and editor', ['tgif'],
def checkFormatEntries(): ''' Check all formats (\Format entries) ''' checkViewer('a Tif viewer and editor', ['tgif'], rc_entry = [r'\Format tgif obj Tgif "" "%%" "%%" ""']) # checkViewer('a FIG viewer and editor', ['xfig'], rc_entry = [r'\Format fig fig FIG "" ...
begin_layout = "\\layout"
i = find_token(lines, '\\layout', 0)
def add_end_layout(lines): begin_layout = "\\layout" i = find_token(lines, begin_layout, 0) if i == -1: write(stderr, "lyx2lyx: File with no paragraphs. ") lines[0:len(lines)] = [] return i = i + 1 while 1: i = find_tokens(lines, ["\\begin_inset", "\\end_inset", "\\layout", "\\begin_deeper", "\\end_deeper", "\\the_en...
i = find_token(lines, begin_layout, 0)
def add_end_layout(lines): begin_layout = "\\layout" i = find_token(lines, begin_layout, 0) if i == -1: write(stderr, "lyx2lyx: File with no paragraphs. ") lines[0:len(lines)] = [] return i = i + 1 while 1: i = find_tokens(lines, ["\\begin_inset", "\\end_inset", "\\layout", "\\begin_deeper", "\\end_deeper", "\\the_en...
write(stderr, "lyx2lyx: File with no paragraphs. ") lines[0:len(lines)] = []
def add_end_layout(lines): begin_layout = "\\layout" i = find_token(lines, begin_layout, 0) if i == -1: write(stderr, "lyx2lyx: File with no paragraphs. ") lines[0:len(lines)] = [] return i = i + 1 while 1: i = find_tokens(lines, ["\\begin_inset", "\\end_inset", "\\layout", "\\begin_deeper", "\\end_deeper", "\\the_en...
struct_stack = ["\\layout"]
def add_end_layout(lines): begin_layout = "\\layout" i = find_token(lines, begin_layout, 0) if i == -1: write(stderr, "lyx2lyx: File with no paragraphs. ") lines[0:len(lines)] = [] return i = i + 1 while 1: i = find_tokens(lines, ["\\begin_inset", "\\end_inset", "\\layout", "\\begin_deeper", "\\end_deeper", "\\the_en...
lines[i:i] = ["\\end_layout"] i = i + 1 i = find_token(lines, begin_layout, i) if i == -1: return i = i + 1
token = split(lines[i])[0] if token == "\\begin_inset": struct_stack.append(token) i = i + 1 continue if token == "\\end_inset": tail = struct_stack.pop() if tail == "\\layout": lines.insert(i,"\\end_layout") i = i + 1 struct_stack.pop() i = i + 1 continue if token == "\\layout": tail = struct_stack.pop() if tail =...
def add_end_layout(lines): begin_layout = "\\layout" i = find_token(lines, begin_layout, 0) if i == -1: write(stderr, "lyx2lyx: File with no paragraphs. ") lines[0:len(lines)] = [] return i = i + 1 while 1: i = find_tokens(lines, ["\\begin_inset", "\\end_inset", "\\layout", "\\begin_deeper", "\\end_deeper", "\\the_en...
metrics_re = re.compile("\[([0-9]+) depth=(-?[0-9]+) height=(-?[0-9]+)")
page_re = re.compile("\[([0-9]+)[^]]"); metrics_re = re.compile("depth=(-?[0-9]+) height=(-?[0-9]+)")
def extract_metrics_info(dvipng_stdout, metrics_file): metrics = open(metrics_file, 'w') metrics_re = re.compile("\[([0-9]+) depth=(-?[0-9]+) height=(-?[0-9]+)") success = 0 pos = 0 while 1: match = metrics_re.search(dvipng_stdout, pos) if match == None: break success = 1 # Calculate the 'ascent fraction'. descent = ...
descent = string.atof(match.group(2)) ascent = string.atof(match.group(3))
descent = string.atof(match.group(1)) ascent = string.atof(match.group(2))
def extract_metrics_info(dvipng_stdout, metrics_file): metrics = open(metrics_file, 'w') metrics_re = re.compile("\[([0-9]+) depth=(-?[0-9]+) height=(-?[0-9]+)") success = 0 pos = 0 while 1: match = metrics_re.search(dvipng_stdout, pos) if match == None: break success = 1 # Calculate the 'ascent fraction'. descent = ...
metrics.write("Snippet %s %f\n" % (match.group(1), frac)) pos = match.end(3) + 2
metrics.write("Snippet %s %f\n" % (page, frac)) pos = match.end() + 2
def extract_metrics_info(dvipng_stdout, metrics_file): metrics = open(metrics_file, 'w') metrics_re = re.compile("\[([0-9]+) depth=(-?[0-9]+) height=(-?[0-9]+)") success = 0 pos = 0 while 1: match = metrics_re.search(dvipng_stdout, pos) if match == None: break success = 1 # Calculate the 'ascent fraction'. descent = ...
files = filter(lambda x: x not in exclude, glob.glob1(dir, pattern)) + include
files = filter(lambda x: x not in exclude + include, glob.glob1(dir, pattern)) + include
def globSource(dir, pattern, build_dir=None, exclude=[], include=[]): ''' glob files, in dir and use build_dir as returned path name ''' files = filter(lambda x: x not in exclude, glob.glob1(dir, pattern)) + include if build_dir is None: return files else: return ['%s/%s' % (build_dir, x) for x in files]
while file.body[i + 1][:1] == '\\':
while file.body[i + 1][:1] == '\\' and split(file.body[i + 1][1:])[0] in par_params:
def convert_breaks(file): i = 0 while 1: i = find_token(file.body, "\\begin_layout", i) if i == -1: return i = i + 1 # Merge all paragraph parameters into a single line while file.body[i + 1][:1] == '\\': file.body[i] = file.body[i + 1] + ' ' + file.body[i] del file.body[i+1] line_top = find(file.body[i],"\\line_to...