On 9/08/2017 3:35 a.m., José Abílio Matos wrote:
On Thursday, 25 May 2017 01.31.05 WEST Andrew Parsloe wrote:

(Deep breath.) I think ext_copy.py is only half of a pair of scripts.

The other half is a "dummy exporter", something like

## dummy_export.py
## a minimal script used to 'export' the
## current document and excite the LyX
## copier mechanism into action

import sys

fin = open(sys.argv[1], 'r') # $$i
fout = open(sys.argv[2], 'w') # $$o

This code could simply be:

import shutils, sys

shutil.copy2(sys.argv[1], sys.argv[2])

Thank you for the suggestion José. (I am a rank amateur Pythonist.) However, testing produced an error until I realised that "import shutils" should be "import shutil", when it worked perfectly.

To give an example of use: if I want to copy the preview logs back from
the temp directory to the document directory or a subdirectory /LOGS of
it, I define a file format LOG (preview) with extension tmp. The copier is

python -tt $$s/scripts/ext_copy.py -e log -t LOGS $$i $$o

and under converters, from LyX to LOG (preview), enter

python -tt $$s/scripts/dummy_export.py $$i $$o

"Exporting" the current document to LOG (preview) format creates a file
<filename>.tmp in the temp directory (containing a single linefeed
character); ext_copy.py then springs into action and copies the preview
logs back to the /LOGS subdirectory of the document directory. Since I
use the LaTeX runs of the preview mechanism to perform various
non-standard tasks, the logs are often of great interest.

Using these two scripts together like this provides a fairly simple
mechanism for a user to rescue or preserve files from the temp
directory. Perhaps LyX developers might include something like
dummy_export.py, the "other half" of ext_copy.py, with LyX so that this
mechanism is available "out of the box"?

Probably this should be added to trac as to not to be forgotten.

Will do.



José Abílio

This email has been checked for viruses by Avast antivirus software.

Reply via email to