Am Dienstag, 27. Juni 2006 17:59 schrieb Bo Peng:
> The danger comes from the editors. There are times that you do not
> know what an editor will put, tab or space, so it is safer to always
> use space. For example, if you use vi to edit a .py file with spaces,
> and allow it to indent for you (without expandtab flag on), it will
> most likely use tab for indent. The source code will look right, but
> fail to run. The other case around is also valid. With vi, you can at
> least configure it, this is not the case for other less capable
> editors.
So we have a problem if we use spaces only, and a similar one if we use
tabs. Nothing is gained here by the spaces only approach.
You have not convinced me that the spaces indenting is better, but I'll
shut up now.
Anyway, I think we should call python with the -tt flag. The attached
patch does that, and is going in tomorrow unless I get objections.
Georg
Index: src/graphics/GraphicsConverter.C
===================================================================
--- src/graphics/GraphicsConverter.C (Revision 14261)
+++ src/graphics/GraphicsConverter.C (Arbeitskopie)
@@ -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 & fro
// 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 & fro
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 & fro
// 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 & fr
/*
A typical script looks like:
-#!/usr/bin/env python
+#!/usr/bin/env python -tt
import os, sys
def unlinkNoThrow(file):
Index: src/converter.C
===================================================================
--- src/converter.C (Revision 14261)
+++ src/converter.C (Arbeitskopie)
@@ -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 *
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) +
Index: src/buffer.C
===================================================================
--- src/buffer.C (Revision 14261)
+++ src/buffer.C (Arbeitskopie)
@@ -643,7 +643,7 @@ bool Buffer::readFile(LyXLex & lex, stri
return false;
}
ostringstream command;
- command << "python " << quoteName(lyx2lyx)
+ command << os::python() << ' ' << quoteName(lyx2lyx)
<< " -t " << convert<string>(LYX_FORMAT)
<< " -o " << quoteName(tmpfile) << ' '
<< quoteName(filename);
Index: src/frontends/controllers/tex_helpers.C
===================================================================
--- src/frontends/controllers/tex_helpers.C (Revision 14261)
+++ src/frontends/controllers/tex_helpers.C (Arbeitskopie)
@@ -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")));
}
Index: src/support/os.h
===================================================================
--- src/support/os.h (Revision 14261)
+++ src/support/os.h (Arbeitskopie)
@@ -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);
Index: src/support/package.C.in
===================================================================
--- src/support/package.C.in (Revision 14261)
+++ src/support/package.C.in (Arbeitskopie)
@@ -152,7 +152,7 @@ Package::Package(string const & command_
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]
Index: src/support/os.C
===================================================================
--- src/support/os.C (Revision 14261)
+++ src/support/os.C (Arbeitskopie)
@@ -17,3 +17,17 @@
#else
#include "os_unix.C"
#endif
+
+namespace lyx {
+namespace support {
+namespace os {
+
+std::string const python()
+{
+ static std::string const command("python -tt");
+ return command;
+}
+
+}
+}
+}
Index: src/lyxtextclass.C
===================================================================
--- src/lyxtextclass.C (Revision 14261)
+++ src/lyxtextclass.C (Arbeitskopie)
@@ -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 & filena
}
std::ostringstream command;
- command << "python " << quoteName(script)
+ command << lyx::support::os::python() << ' ' << quoteName(script)
<< ' ' << quoteName(filename)
<< ' ' << quoteName(tempfile);
string const command_str = command.str();
Index: lib/scripts/tex_copy.py
===================================================================
--- lib/scripts/tex_copy.py (Revision 14261)
+++ lib/scripts/tex_copy.py (Arbeitskopie)
@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#! /usr/bin/env python -tt
# -*- coding: iso-8859-1 -*-
# file tex_copy.py
Index: lib/scripts/layout2layout.py
===================================================================
--- lib/scripts/layout2layout.py (Revision 14261)
+++ lib/scripts/layout2layout.py (Arbeitskopie)
@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#! /usr/bin/env python -tt
# -*- coding: iso-8859-1 -*-
# file layout2layout.py
Index: lib/scripts/lyxpreview2bitmap.py
===================================================================
--- lib/scripts/lyxpreview2bitmap.py (Revision 14261)
+++ lib/scripts/lyxpreview2bitmap.py (Arbeitskopie)
@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#! /usr/bin/env python -tt
# -*- coding: iso-8859-1 -*-
# file lyxpreview2bitmap.py
Index: lib/scripts/lyxpreview_tools.py
===================================================================
--- lib/scripts/lyxpreview_tools.py (Revision 14261)
+++ lib/scripts/lyxpreview_tools.py (Arbeitskopie)
@@ -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.
Index: lib/scripts/fig_copy.py
===================================================================
--- lib/scripts/fig_copy.py (Revision 14261)
+++ lib/scripts/fig_copy.py (Arbeitskopie)
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python -tt
# -*- coding: iso-8859-15 -*-
# file fig_copy.py
Index: lib/scripts/legacy_lyxpreview2ppm.py
===================================================================
--- lib/scripts/legacy_lyxpreview2ppm.py (Revision 14261)
+++ lib/scripts/legacy_lyxpreview2ppm.py (Arbeitskopie)
@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#! /usr/bin/env python -tt
# -*- coding: iso-8859-1 -*-
# file legacy_lyxpreview2ppm.py
Index: lib/scripts/fen2ascii.py
===================================================================
--- lib/scripts/fen2ascii.py (Revision 14261)
+++ lib/scripts/fen2ascii.py (Arbeitskopie)
@@ -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.
Index: lib/scripts/TeXFiles.py
===================================================================
--- lib/scripts/TeXFiles.py (Revision 14261)
+++ lib/scripts/TeXFiles.py (Arbeitskopie)
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python -tt
# -*- coding: iso-8859-15 -*-
# file TeXFiles.py
Index: lib/scripts/clean_dvi.py
===================================================================
--- lib/scripts/clean_dvi.py (Revision 14261)
+++ lib/scripts/clean_dvi.py (Arbeitskopie)
@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#! /usr/bin/env python -tt
'''
file clean_dvi.py
Index: lib/scripts/convertDefault.py
===================================================================
--- lib/scripts/convertDefault.py (Revision 14261)
+++ lib/scripts/convertDefault.py (Arbeitskopie)
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python -tt
# -*- coding: iso-8859-15 -*-
# file convertDefault.py
Index: lib/lyx2lyx/lyx2lyx
===================================================================
--- lib/lyx2lyx/lyx2lyx (Revision 14261)
+++ lib/lyx2lyx/lyx2lyx (Arbeitskopie)
@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#! /usr/bin/env python -tt
# -*- coding: iso-8859-1 -*-
# Copyright (C) 2002-2004 José Matos <[EMAIL PROTECTED]>
#
Index: lib/lyx2lyx/lyx_1_5.py
===================================================================
--- lib/lyx2lyx/lyx_1_5.py (Revision 14261)
+++ lib/lyx2lyx/lyx_1_5.py (Arbeitskopie)
@@ -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':
Index: lib/doc/depend.py
===================================================================
--- lib/doc/depend.py (Revision 14261)
+++ lib/doc/depend.py (Arbeitskopie)
@@ -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 <[EMAIL PROTECTED]>
Index: lib/doc/doc_toc.py
===================================================================
--- lib/doc/doc_toc.py (Revision 14261)
+++ lib/doc/doc_toc.py (Arbeitskopie)
@@ -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 <[EMAIL PROTECTED]>