mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-25 05:55:34 +00:00
* src/graphics/GraphicsConverter.C
(Converter::Impl::Impl): move block of python code to build_script (build_script): adjust formatting git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@14393 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
7afbc908eb
commit
34e73f7823
@ -162,15 +162,6 @@ Converter::Impl::Impl(string const & from_file, string const & to_file_base,
|
|||||||
|
|
||||||
// The conversion commands are stored in a stringstream
|
// The conversion commands are stored in a stringstream
|
||||||
ostringstream script;
|
ostringstream script;
|
||||||
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"
|
|
||||||
<< " try:\n"
|
|
||||||
<< " os.unlink(file)\n"
|
|
||||||
<< " except:\n"
|
|
||||||
<< " pass\n\n";
|
|
||||||
|
|
||||||
bool const success = build_script(from_file, to_file_base,
|
bool const success = build_script(from_file, to_file_base,
|
||||||
from_format, to_format, script);
|
from_format, to_format, script);
|
||||||
|
|
||||||
@ -341,6 +332,15 @@ bool build_script(string const & from_file,
|
|||||||
if (from_format.empty())
|
if (from_format.empty())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
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"
|
||||||
|
" try:\n"
|
||||||
|
" os.unlink(file)\n"
|
||||||
|
" except:\n"
|
||||||
|
" pass\n\n";
|
||||||
|
|
||||||
// we do not use ChangeExtension because this is a basename
|
// we do not use ChangeExtension because this is a basename
|
||||||
// which may nevertheless contain a '.'
|
// which may nevertheless contain a '.'
|
||||||
string const to_file = to_file_base + '.'
|
string const to_file = to_file_base + '.'
|
||||||
@ -410,18 +410,17 @@ bool build_script(string const & from_file,
|
|||||||
// If this occurs, move ${outfile}.0 to ${outfile}
|
// If this occurs, move ${outfile}.0 to ${outfile}
|
||||||
// and delete ${outfile}.? (ignore errors)
|
// and delete ${outfile}.? (ignore errors)
|
||||||
script << "if not os.path.isfile(outfile):\n"
|
script << "if not os.path.isfile(outfile):\n"
|
||||||
<< " if os.path.isfile(outfile + '.0'):\n"
|
" if os.path.isfile(outfile + '.0'):\n"
|
||||||
<< " os.rename(outfile + '.0', outfile)\n"
|
" os.rename(outfile + '.0', outfile)\n"
|
||||||
<< " import glob\n"
|
" import glob\n"
|
||||||
<< " for file in glob.glob(outfile + '.?'):\n"
|
" for file in glob.glob(outfile + '.?'):\n"
|
||||||
<< " unlinkNoThrow(file)\n"
|
" unlinkNoThrow(file)\n"
|
||||||
<< " else:\n"
|
" else:\n"
|
||||||
<< " sys.exit(1)\n\n";
|
" sys.exit(1)\n\n";
|
||||||
|
|
||||||
// Delete the infile, if it isn't the original, from_file.
|
// Delete the infile, if it isn't the original, from_file.
|
||||||
if (infile != from_file) {
|
if (infile != from_file)
|
||||||
script << "unlinkNoThrow(infile)\n\n";
|
script << "unlinkNoThrow(infile)\n\n";
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Move the final outfile to to_file
|
// Move the final outfile to to_file
|
||||||
|
Loading…
Reference in New Issue
Block a user