Call python with the -tt switch to make mixed tab/space indentation an error

* src/support/os.[Ch]
	(python): new function, return the python command

	* lib/lyx2lyx/lyx_1_5.py
	(revert_font_settings): replace tabs with spaces

The rest is simply s/python/python -tt/ and
s/"python"/lyx::support::os::python()/ where appropriate.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@14270 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Georg Baum 2006-06-30 13:54:01 +00:00
parent 96a7b5d0af
commit 4ae87a3bb8
29 changed files with 86 additions and 61 deletions

View File

@ -1,4 +1,4 @@
#! /usr/bin/env python
#! /usr/bin/env python -tt
#
# file configure.py
# This file is part of LyX, the document processor.
@ -183,7 +183,7 @@ def checkLatex():
checkProg('DTL to DVI converter', ['dt2dv']) != ['', '']):
# Windows only: DraftDVI
converter_entry = r'''\converter latex dvi2 "%%" "latex"
\converter dvi2 dvi "python $$s/scripts/clean_dvi.py $$i $$o" ""'''
\converter dvi2 dvi "python -tt $$s/scripts/clean_dvi.py $$i $$o" ""'''
else:
converter_entry = r'\converter latex dvi "%%" "latex"'
path, LATEX = checkProg('a Latex2e program', ['pplatex $$i', 'latex $$i', 'latex2e $$i'],
@ -343,7 +343,7 @@ def checkConverterEntries():
#
path, dvipng = checkProg('dvipng', ['dvipng'])
if dvipng == "dvipng":
addToRC(r'\converter lyxpreview png "python $$s/scripts/lyxpreview2bitmap.py" ""')
addToRC(r'\converter lyxpreview png "python -tt $$s/scripts/lyxpreview2bitmap.py" ""')
else:
addToRC(r'\converter lyxpreview png "" ""')
#
@ -387,13 +387,13 @@ def checkConverterEntries():
# checkProg('Image converter', ['convert $$i $$o'])
#
# Entried that do not need checkProg
addToRC(r'''\converter lyxpreview ppm "python $$s/scripts/lyxpreview2bitmap.py" ""
addToRC(r'''\converter lyxpreview ppm "python -tt $$s/scripts/lyxpreview2bitmap.py" ""
\converter date dateout "date +%d-%m-%Y > $$o" ""
\converter docbook docbook-xml "cp $$i $$o" "xml"
\converter fen asciichess "python $$s/scripts/fen2ascii.py $$i $$o" ""
\converter fig pdftex "python $$s/scripts/fig2pdftex.py $$i $$o" ""
\converter fig pstex "python $$s/scripts/fig2pstex.py $$i $$o" ""
\converter lyx lyx13x "python $$s/lyx2lyx/lyx2lyx -t 221 $$i > $$o" ""
\converter fen asciichess "python -tt $$s/scripts/fen2ascii.py $$i $$o" ""
\converter fig pdftex "python -tt $$s/scripts/fig2pdftex.py $$i $$o" ""
\converter fig pstex "python -tt $$s/scripts/fig2pstex.py $$i $$o" ""
\converter lyx lyx13x "python -tt $$s/lyx2lyx/lyx2lyx -t 221 $$i > $$o" ""
''')
@ -456,9 +456,9 @@ def checkOtherEntries():
\print_spool_command "lpr"''',
''])
# Add the rest of the entries (no checkProg is required)
addToRC(r'''\copier fig "python $$s/scripts/fig_copy.py $$i $$o"
\copier pstex "python $$s/scripts/tex_copy.py $$i $$o $$l"
\copier pdftex "python $$s/scripts/tex_copy.py $$i $$o $$l"
addToRC(r'''\copier fig "python -tt $$s/scripts/fig_copy.py $$i $$o"
\copier pstex "python -tt $$s/scripts/tex_copy.py $$i $$o $$l"
\copier pdftex "python -tt $$s/scripts/tex_copy.py $$i $$o $$l"
''')

View File

@ -5,60 +5,60 @@
# TOCs target, which prints all the TOC files.
TOC.lyx: $(srcdir)/Intro.lyx $(srcdir)/FAQ.lyx $(srcdir)/Tutorial.lyx $(srcdir)/UserGuide.lyx $(srcdir)/Extended.lyx $(srcdir)/Customization.lyx
PYTHONPATH=$(top_builddir)/lib/lyx2lyx python $(srcdir)/doc_toc.py
PYTHONPATH=$(top_builddir)/lib/lyx2lyx python -tt $(srcdir)/doc_toc.py
cs_TOC.lyx: $(srcdir)/cs_Tutorial.lyx
PYTHONPATH=$(top_builddir)/lib/lyx2lyx python $(srcdir)/doc_toc.py cs
PYTHONPATH=$(top_builddir)/lib/lyx2lyx python -tt $(srcdir)/doc_toc.py cs
da_TOC.lyx: $(srcdir)/da_Intro.lyx
PYTHONPATH=$(top_builddir)/lib/lyx2lyx python $(srcdir)/doc_toc.py da
PYTHONPATH=$(top_builddir)/lib/lyx2lyx python -tt $(srcdir)/doc_toc.py da
de_TOC.lyx: $(srcdir)/de_Customization.lyx $(srcdir)/de_Extended.lyx $(srcdir)/de_FAQ.lyx $(srcdir)/de_Intro.lyx $(srcdir)/de_Tutorial.lyx $(srcdir)/de_UserGuide.lyx
PYTHONPATH=$(top_builddir)/lib/lyx2lyx python $(srcdir)/doc_toc.py de
PYTHONPATH=$(top_builddir)/lib/lyx2lyx python -tt $(srcdir)/doc_toc.py de
es_TOC.lyx: $(srcdir)/es_Intro.lyx $(srcdir)/es_Tutorial.lyx
PYTHONPATH=$(top_builddir)/lib/lyx2lyx python $(srcdir)/doc_toc.py es
PYTHONPATH=$(top_builddir)/lib/lyx2lyx python -tt $(srcdir)/doc_toc.py es
eu_TOC.lyx: $(srcdir)/eu_Customization.lyx $(srcdir)/eu_Extended.lyx $(srcdir)/eu_FAQ.lyx $(srcdir)/eu_Intro.lyx $(srcdir)/eu_Tutorial.lyx $(srcdir)/eu_UserGuide.lyx
PYTHONPATH=$(top_builddir)/lib/lyx2lyx python $(srcdir)/doc_toc.py eu
PYTHONPATH=$(top_builddir)/lib/lyx2lyx python -tt $(srcdir)/doc_toc.py eu
fr_TOC.lyx: $(srcdir)/fr_Customization.lyx $(srcdir)/fr_Extended.lyx $(srcdir)/fr_FAQ.lyx $(srcdir)/fr_Intro.lyx $(srcdir)/fr_Tutorial.lyx $(srcdir)/fr_UserGuide.lyx
PYTHONPATH=$(top_builddir)/lib/lyx2lyx python $(srcdir)/doc_toc.py fr
PYTHONPATH=$(top_builddir)/lib/lyx2lyx python -tt $(srcdir)/doc_toc.py fr
he_TOC.lyx: $(srcdir)/he_Intro.lyx $(srcdir)/he_Tutorial.lyx
PYTHONPATH=$(top_builddir)/lib/lyx2lyx python $(srcdir)/doc_toc.py he
PYTHONPATH=$(top_builddir)/lib/lyx2lyx python -tt $(srcdir)/doc_toc.py he
hu_TOC.lyx: $(srcdir)/hu_Intro.lyx
PYTHONPATH=$(top_builddir)/lib/lyx2lyx python $(srcdir)/doc_toc.py hu
PYTHONPATH=$(top_builddir)/lib/lyx2lyx python -tt $(srcdir)/doc_toc.py hu
it_TOC.lyx: $(srcdir)/it_Customization.lyx $(srcdir)/it_Intro.lyx $(srcdir)/it_Tutorial.lyx $(srcdir)/it_UserGuide.lyx
PYTHONPATH=$(top_builddir)/lib/lyx2lyx python $(srcdir)/doc_toc.py it
PYTHONPATH=$(top_builddir)/lib/lyx2lyx python -tt $(srcdir)/doc_toc.py it
nb_TOC.lyx: $(srcdir)/nb_Intro.lyx
PYTHONPATH=$(top_builddir)/lib/lyx2lyx python $(srcdir)/doc_toc.py nb
PYTHONPATH=$(top_builddir)/lib/lyx2lyx python -tt $(srcdir)/doc_toc.py nb
nl_TOC.lyx: $(srcdir)/nl_Intro.lyx $(srcdir)/nl_Tutorial.lyx
PYTHONPATH=$(top_builddir)/lib/lyx2lyx python $(srcdir)/doc_toc.py nl
PYTHONPATH=$(top_builddir)/lib/lyx2lyx python -tt $(srcdir)/doc_toc.py nl
pl_TOC.lyx: $(srcdir)/pl_Extended.lyx $(srcdir)/pl_Intro.lyx $(srcdir)/pl_Tutorial.lyx
PYTHONPATH=$(top_builddir)/lib/lyx2lyx python $(srcdir)/doc_toc.py pl
PYTHONPATH=$(top_builddir)/lib/lyx2lyx python -tt $(srcdir)/doc_toc.py pl
pt_TOC.lyx: $(srcdir)/pt_Intro.lyx $(srcdir)/pt_Tutorial.lyx
PYTHONPATH=$(top_builddir)/lib/lyx2lyx python $(srcdir)/doc_toc.py pt
PYTHONPATH=$(top_builddir)/lib/lyx2lyx python -tt $(srcdir)/doc_toc.py pt
ro_TOC.lyx: $(srcdir)/ro_Intro.lyx
PYTHONPATH=$(top_builddir)/lib/lyx2lyx python $(srcdir)/doc_toc.py ro
PYTHONPATH=$(top_builddir)/lib/lyx2lyx python -tt $(srcdir)/doc_toc.py ro
ru_TOC.lyx: $(srcdir)/ru_FAQ.lyx $(srcdir)/ru_Intro.lyx $(srcdir)/ru_Tutorial.lyx
PYTHONPATH=$(top_builddir)/lib/lyx2lyx python $(srcdir)/doc_toc.py ru
PYTHONPATH=$(top_builddir)/lib/lyx2lyx python -tt $(srcdir)/doc_toc.py ru
sk_TOC.lyx: $(srcdir)/sk_Tutorial.lyx $(srcdir)/sk_UserGuide.lyx
PYTHONPATH=$(top_builddir)/lib/lyx2lyx python $(srcdir)/doc_toc.py sk
PYTHONPATH=$(top_builddir)/lib/lyx2lyx python -tt $(srcdir)/doc_toc.py sk
sl_TOC.lyx: $(srcdir)/sl_Intro.lyx $(srcdir)/sl_Tutorial.lyx
PYTHONPATH=$(top_builddir)/lib/lyx2lyx python $(srcdir)/doc_toc.py sl
PYTHONPATH=$(top_builddir)/lib/lyx2lyx python -tt $(srcdir)/doc_toc.py sl
sv_TOC.lyx: $(srcdir)/sv_Intro.lyx $(srcdir)/sv_Tutorial.lyx
PYTHONPATH=$(top_builddir)/lib/lyx2lyx python $(srcdir)/doc_toc.py sv
PYTHONPATH=$(top_builddir)/lib/lyx2lyx python -tt $(srcdir)/doc_toc.py sv
tocfiles = TOC.lyx cs_TOC.lyx da_TOC.lyx de_TOC.lyx es_TOC.lyx eu_TOC.lyx fr_TOC.lyx he_TOC.lyx hu_TOC.lyx it_TOC.lyx nb_TOC.lyx nl_TOC.lyx pl_TOC.lyx pt_TOC.lyx ro_TOC.lyx ru_TOC.lyx sk_TOC.lyx sl_TOC.lyx sv_TOC.lyx

View File

@ -1,4 +1,4 @@
#! /usr/bin/env python
#! /usr/bin/env python -tt
# -*- coding: iso-8859-1 -*-
# This file is part of the LyX Documentation
# Copyright (C) 2004 José Matos <jamatos@lyx.org>
@ -68,7 +68,7 @@ def main(argv):
# The default language is english and doesn't need any prefix
print 'TOC.lyx: $(srcdir)/' + '.lyx $(srcdir)/'.join(possible_documents) + '.lyx'
print '\tPYTHONPATH=$(top_builddir)/lib/lyx2lyx python $(srcdir)/doc_toc.py'
print '\tPYTHONPATH=$(top_builddir)/lib/lyx2lyx python -tt $(srcdir)/doc_toc.py'
print
tocs = ['TOC.lyx']
@ -82,7 +82,7 @@ def main(argv):
languages[lang].sort()
print toc_name + ': $(srcdir)/' + ' $(srcdir)/'.join(languages[lang])
print '\tPYTHONPATH=$(top_builddir)/lib/lyx2lyx python $(srcdir)/doc_toc.py %s' % lang
print '\tPYTHONPATH=$(top_builddir)/lib/lyx2lyx python -tt $(srcdir)/doc_toc.py %s' % lang
print
# Write meta-rule to call all the other rules

View File

@ -1,4 +1,4 @@
#! /usr/bin/env python
#! /usr/bin/env python -tt
# -*- coding: iso-8859-1 -*-
# This file is part of the LyX Documentation
# Copyright (C) 2004 José Matos <jamatos@lyx.org>

View File

@ -268,7 +268,7 @@ listerrors
<<listerrors>>=
\newline
#!/usr/bin/python
#!/usr/bin/python -tt
\newline
"""reformat noweb and compiler errors for LyX.
\newline

View File

@ -1,4 +1,4 @@
#! /usr/bin/env python
#! /usr/bin/env python -tt
# -*- coding: utf-8 -*-
'''

View File

@ -1,4 +1,4 @@
#! /usr/bin/env python
#! /usr/bin/env python -tt
# -*- coding: iso-8859-1 -*-
# Copyright (C) 2002-2004 José Matos <jamatos@lyx.org>
#

View File

@ -139,9 +139,9 @@ def revert_font_settings(file):
file.header.insert(insert_line, '\\fontscheme %s' % font_scheme)
if font_default_family != 'default':
file.preamble.append('\\renewcommand{\\familydefault}{\\%s}' % font_default_family)
if font_osf == 'true':
if font_osf == 'true':
file.warning("Ignoring `\\font_osf = true'")
return
return
font_scheme = 'default'
file.header.insert(insert_line, '\\fontscheme %s' % font_scheme)
if fonts['roman'] == 'cmr':

View File

@ -1,4 +1,4 @@
#! /usr/bin/env python
#! /usr/bin/env python -tt
# -*- coding: iso-8859-1 -*-
# Copyright (C) 2004 José Matos <jamatos@lyx.org>
#

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python -tt
# -*- coding: iso-8859-15 -*-
# file TeXFiles.py

View File

@ -1,4 +1,4 @@
#! /usr/bin/env python
#! /usr/bin/env python -tt
'''
file clean_dvi.py

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python -tt
# -*- coding: iso-8859-15 -*-
# file convertDefault.py

View File

@ -1,4 +1,4 @@
#! /usr/bin/env python
#! /usr/bin/env python -tt
# file fen2ascii.py
# This file is part of LyX, the document processor.

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python -tt
# -*- coding: iso-8859-15 -*-
# file fig2pdf.py

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python -tt
# -*- coding: iso-8859-15 -*-
# file fig2pstex.py

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python -tt
# -*- coding: iso-8859-15 -*-
# file fig_copy.py

View File

@ -1,4 +1,4 @@
#! /usr/bin/env python
#! /usr/bin/env python -tt
# -*- coding: iso-8859-1 -*-
# file layout2layout.py

View File

@ -1,4 +1,4 @@
#! /usr/bin/env python
#! /usr/bin/env python -tt
# -*- coding: iso-8859-1 -*-
# file legacy_lyxpreview2ppm.py

View File

@ -1,4 +1,4 @@
#! /usr/bin/env python
#! /usr/bin/env python -tt
# -*- coding: iso-8859-1 -*-
# file lyxpreview2bitmap.py

View File

@ -1,4 +1,4 @@
#! /usr/bin/env python
#! /usr/bin/env python -tt
# file lyxpreview_tools.py
# This file is part of LyX, the document processor.

View File

@ -1,4 +1,4 @@
#! /usr/bin/env python
#! /usr/bin/env python -tt
# -*- coding: iso-8859-1 -*-
# file tex_copy.py

View File

@ -643,7 +643,7 @@ bool Buffer::readFile(LyXLex & lex, string const & filename)
return false;
}
ostringstream command;
command << "python " << quoteName(lyx2lyx)
command << os::python() << ' ' << quoteName(lyx2lyx)
<< " -t " << convert<string>(LYX_FORMAT)
<< " -o " << quoteName(tmpfile) << ' '
<< quoteName(filename);

View File

@ -26,6 +26,7 @@
#include "support/filetools.h"
#include "support/lyxlib.h"
#include "support/os.h"
#include "support/path.h"
#include "support/systemcall.h"
@ -298,7 +299,7 @@ bool Converters::convert(Buffer const * buffer,
getExtension(from_file) :
formats.extension(from_format);
string const command =
"python " +
lyx::support::os::python() + ' ' +
quoteName(libFileSearch("scripts", "convertDefault.py")) +
' ' +
quoteName(from_ext + ':' + from_file) +

View File

@ -17,6 +17,7 @@
#include "support/filetools.h"
#include "support/lstrings.h"
#include "support/lyxalgo.h"
#include "support/os.h"
#include "support/package.h"
#include "support/path.h"
#include "support/systemcall.h"
@ -52,7 +53,7 @@ void rescanTexStyles()
Path p(package().user_support());
Systemcall one;
one.startscript(Systemcall::Wait,
"python " +
lyx::support::os::python() + ' ' +
quoteName(libFileSearch("scripts", "TeXFiles.py")));
}

View File

@ -21,6 +21,7 @@
#include "support/convert.h"
#include "support/lstrings.h"
#include "support/lyxlib.h"
#include "support/os.h"
#include <boost/bind.hpp>
@ -161,7 +162,7 @@ Converter::Impl::Impl(string const & from_file, string const & to_file_base,
// The conversion commands are stored in a stringstream
ostringstream script;
script << "#!/usr/bin/env python\n"
script << "#!/usr/bin/env python -tt\n"
<< "import os, sys\n\n"
<< "def unlinkNoThrow(file):\n"
<< " ''' remove a file, do not throw if an error occurs '''\n"
@ -175,7 +176,7 @@ Converter::Impl::Impl(string const & from_file, string const & to_file_base,
if (!success) {
script_command_ =
"python " +
support::os::python() + ' ' +
quoteName(libFileSearch("scripts", "convertDefault.py")) +
' ' +
quoteName((from_format.empty() ? "" : from_format + ':') + from_file) +
@ -214,7 +215,8 @@ Converter::Impl::Impl(string const & from_file, string const & to_file_base,
// We create a dummy command for ease of understanding of the
// list of forked processes.
// Note: 'sh ' is absolutely essential, or execvp will fail.
script_command_ = "python " + quoteName(script_file_) + ' ' +
script_command_ = support::os::python() + ' ' +
quoteName(script_file_) + ' ' +
quoteName(onlyFilename(from_file)) + ' ' +
quoteName(to_format);
}
@ -286,7 +288,7 @@ string const move_file(string const & from_file, string const & to_file)
/*
A typical script looks like:
#!/usr/bin/env python
#!/usr/bin/env python -tt
import os, sys
def unlinkNoThrow(file):

View File

@ -24,6 +24,8 @@
#include "support/lstrings.h"
#include "support/lyxlib.h"
#include "support/filetools.h"
#include "support/os.h"
#include <boost/filesystem/operations.hpp>
namespace fs = boost::filesystem;
@ -72,7 +74,7 @@ bool layout2layout(string const & filename, string const & tempfile)
}
std::ostringstream command;
command << "python " << quoteName(script)
command << lyx::support::os::python() << ' ' << quoteName(script)
<< ' ' << quoteName(filename)
<< ' ' << quoteName(tempfile);
string const command_str = command.str();

View File

@ -17,3 +17,19 @@
#else
#include "os_unix.C"
#endif
namespace lyx {
namespace support {
namespace os {
std::string const python()
{
// Use the -tt switch so that mixed tab/whitespace indentation is
// an error
static std::string const command("python -tt");
return command;
}
}
}
}

View File

@ -38,6 +38,9 @@ std::string current_root();
///
shell_type shell();
/// Name of the python interpreter
std::string const python();
/// Extract the path common to both @c p1 and @c p2. DBCS aware!
std::string::size_type common_path(std::string const & p1, std::string const & p2);

View File

@ -152,7 +152,7 @@ Package::Package(string const & command_line_arg0,
command_line_user_support_dir);
string const configure_script = addName(system_support(), "configure.py");
configure_command_ = "python " + quoteName(configure_script)
configure_command_ = os::python() + ' ' + quoteName(configure_script)
+ with_version_suffix();
lyxerr[Debug::INIT]