mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-26 11:16:55 +00:00
Replace TeXFiles.sh by TeXFiles.py
* src/frontends/controllers/tex_helpers.C: call TeXFiles.py * lib/scripts/TeXFiles.py: add * lib/scripts/TeXFiles.sh: remove * lib/scripts/convertDefault.py: add encoding line * lib/Makefile.am git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@14238 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
913a4129aa
commit
f58609c765
@ -878,7 +878,7 @@ scriptsdir = $(pkgdatadir)/scripts
|
|||||||
# get appended to the names. So we use dist_scripts_DATA and chmod manually
|
# get appended to the names. So we use dist_scripts_DATA and chmod manually
|
||||||
# in install-data-hook.
|
# in install-data-hook.
|
||||||
dist_scripts_DATA = \
|
dist_scripts_DATA = \
|
||||||
scripts/TeXFiles.sh \
|
scripts/TeXFiles.py \
|
||||||
scripts/clean_dvi.py \
|
scripts/clean_dvi.py \
|
||||||
scripts/convertDefault.py \
|
scripts/convertDefault.py \
|
||||||
scripts/fen2ascii.py \
|
scripts/fen2ascii.py \
|
||||||
|
116
lib/scripts/TeXFiles.py
Executable file
116
lib/scripts/TeXFiles.py
Executable file
@ -0,0 +1,116 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
# -*- coding: iso-8859-15 -*-
|
||||||
|
|
||||||
|
# file TeXFiles.py
|
||||||
|
# This file is part of LyX, the document processor.
|
||||||
|
# Licence details can be found in the file COPYING.
|
||||||
|
|
||||||
|
# \author Herbert Voß
|
||||||
|
# \author Jean-Marc Lasgouttes
|
||||||
|
# \author Jürgen Spitzmüller
|
||||||
|
# \author Bo Peng
|
||||||
|
|
||||||
|
# Full author contact details are available in file CREDITS.
|
||||||
|
|
||||||
|
# all files -> without option
|
||||||
|
# TeX class files -> option cls
|
||||||
|
# TeX style files -> option sty
|
||||||
|
# bibtex style files -> option bst
|
||||||
|
# bibtex database files -> option bib
|
||||||
|
#
|
||||||
|
# with the help
|
||||||
|
# of kpsewhich and creates a
|
||||||
|
# bstFiles.lst, clsFiles.lst, styFiles.lst, bibFiles.lst
|
||||||
|
# without any parameter all files are created.
|
||||||
|
#
|
||||||
|
# Herbert Voss <voss@perce.org>
|
||||||
|
#
|
||||||
|
# Updates from Jean-Marc Lasgouttes.
|
||||||
|
#
|
||||||
|
# bib support added by Juergen Spitzmueller (v0.3)
|
||||||
|
#
|
||||||
|
# translated to python by Bo Peng, so that the script only
|
||||||
|
# relies on python and kpsewhich (no shell command is used).
|
||||||
|
#
|
||||||
|
|
||||||
|
import os, sys, re
|
||||||
|
|
||||||
|
cls_stylefile = 'clsFiles.lst'
|
||||||
|
sty_stylefile = 'styFiles.lst'
|
||||||
|
bst_stylefile = 'bstFiles.lst'
|
||||||
|
bib_files = 'bibFiles.lst'
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
# processing command line options
|
||||||
|
if len(sys.argv) > 1:
|
||||||
|
if sys.argv[1] in ['--help', '-help']:
|
||||||
|
print '''Usage: TeXFiles.py [-version | cls | sty | bst | bib ]
|
||||||
|
Default is without any Parameters,
|
||||||
|
so that all files will be created'''
|
||||||
|
sye.exit(0)
|
||||||
|
else:
|
||||||
|
types = sys.argv[1:]
|
||||||
|
for type in types:
|
||||||
|
if type not in ['cls', 'sty', 'bst', 'bib']:
|
||||||
|
print 'ERROR: unknown type', type
|
||||||
|
sys.exit(1)
|
||||||
|
else:
|
||||||
|
# if no parameter is specified, assume all
|
||||||
|
types = ['cls', 'sty', 'bst', 'bib']
|
||||||
|
|
||||||
|
#
|
||||||
|
# MS-DOS and MS-Windows define $COMSPEC or $ComSpec and use `;' to separate
|
||||||
|
# directories in path lists whereas Unix uses `:'. Make an exception for
|
||||||
|
# Cygwin, where we could have either teTeX (using `:') or MikTeX (using `;').
|
||||||
|
# Create a variable that holds the right character to be used by the scripts.
|
||||||
|
path_sep = os.pathsep
|
||||||
|
if sys.platform == 'cygwin':
|
||||||
|
# MikTeX's kpsewhich says "kpathsea emulation version x.x.x", whereas
|
||||||
|
# teTeX's simply "kpathsea version x.x.x".
|
||||||
|
if 'emulation' in cmdOutput('kpsewhich --version'):
|
||||||
|
path_sep = ';'
|
||||||
|
else:
|
||||||
|
path_sep = ':'
|
||||||
|
|
||||||
|
# process each file type
|
||||||
|
for type in types:
|
||||||
|
print "Indexing files of type", type
|
||||||
|
if type == 'cls':
|
||||||
|
outfile = cls_stylefile
|
||||||
|
kpsetype = '.tex'
|
||||||
|
elif type == 'sty':
|
||||||
|
outfile = sty_stylefile
|
||||||
|
kpsetype = '.tex'
|
||||||
|
elif type == 'bst':
|
||||||
|
outfile = bst_stylefile
|
||||||
|
kpsetype = '.bst'
|
||||||
|
elif type == 'bib':
|
||||||
|
outfile = bib_files
|
||||||
|
kpsetype = '.bib'
|
||||||
|
|
||||||
|
dirs = cmdOutput('kpsewhich --show-path=' + kpsetype).replace('!!', '').strip()
|
||||||
|
# remove excessive //
|
||||||
|
dirs = re.sub('//+', '/', dirs)
|
||||||
|
|
||||||
|
file_ext = '.' + type
|
||||||
|
out = open(outfile, 'w')
|
||||||
|
for dir in dirs.split(path_sep):
|
||||||
|
# for each valid directory
|
||||||
|
if os.path.isdir(dir):
|
||||||
|
# walk down the file hierarchy
|
||||||
|
for root,path,files in os.walk(dir):
|
||||||
|
# check file type
|
||||||
|
for file in files:
|
||||||
|
if len(file) > 4 and file[-4:] == file_ext:
|
||||||
|
# force the use of / since miktex uses / even under windows
|
||||||
|
print >> out, root.replace('\\', '/') + '/' + file
|
||||||
|
out.close()
|
||||||
|
|
@ -1,100 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
# file TeXFiles.sh
|
|
||||||
# This file is part of LyX, the document processor.
|
|
||||||
# Licence details can be found in the file COPYING.
|
|
||||||
|
|
||||||
# author Herbert Voß
|
|
||||||
# author Jean-Marc Lasgouttes
|
|
||||||
# author Jürgen Spitzmüller
|
|
||||||
|
|
||||||
# Full author contact details are available in file CREDITS.
|
|
||||||
|
|
||||||
# all files -> without option
|
|
||||||
# TeX class files -> option cls
|
|
||||||
# TeX style files -> option sty
|
|
||||||
# bibtex style files -> option bst
|
|
||||||
# bibtex database files -> option bib
|
|
||||||
#
|
|
||||||
# with the help
|
|
||||||
# of kpsewhich and creates a
|
|
||||||
# bstFiles.lst, clsFiles.lst, styFiles.lst, bibFiles.lst
|
|
||||||
# without any parameter all files are created.
|
|
||||||
#
|
|
||||||
# Herbert Voss <voss@perce.org>
|
|
||||||
#
|
|
||||||
# Updates from Jean-Marc Lasgouttes.
|
|
||||||
#
|
|
||||||
# bib support added by Juergen Spitzmueller (v0.3)
|
|
||||||
#
|
|
||||||
CLS_STYLEFILE=clsFiles.lst
|
|
||||||
STY_STYLEFILE=styFiles.lst
|
|
||||||
BST_STYLEFILE=bstFiles.lst
|
|
||||||
BIB_FILES=bibFiles.lst
|
|
||||||
version='$Id: TeXFiles.sh,v 0.3 2003-02-14'
|
|
||||||
progname=`echo $0 | sed 's%.*/%%'`
|
|
||||||
usage="Usage: TeXFiles.sh [-version | cls | sty | bst | bib ]
|
|
||||||
Default is without any Parameters,
|
|
||||||
so that all files will be created"
|
|
||||||
|
|
||||||
types=$1
|
|
||||||
test -z "$types" && types="cls sty bst bib"
|
|
||||||
|
|
||||||
#
|
|
||||||
# MS-DOS and MS-Windows define $COMSPEC or $ComSpec and use `;' to separate
|
|
||||||
# directories in path lists whereas Unix uses `:'. Make an exception for
|
|
||||||
# Cygwin, where we could have either teTeX (using `:') or MikTeX (using `;').
|
|
||||||
# Create a variable that holds the right character to be used by the scripts.
|
|
||||||
DOSISH=no
|
|
||||||
case `uname -s` in
|
|
||||||
CYGWIN*|Cygwin*|cygwin*)
|
|
||||||
# MikTeX's kpsewhich says "kpathsea emulation version x.x.x", whereas
|
|
||||||
# teTeX's simply "kpathsea version x.x.x".
|
|
||||||
if kpsewhich --version | grep emulation >/dev/null 2>&1; then DOSISH=yes; fi
|
|
||||||
;;
|
|
||||||
*) if test -n "$COMSPEC" || test -n "$ComSpec"; then DOSISH=yes; fi
|
|
||||||
esac
|
|
||||||
if test "$DOSISH" = "no"; then SEP=':'; else SEP=';'; fi
|
|
||||||
|
|
||||||
#
|
|
||||||
# A copy of some stuff from mktex.opt, so we can run in the presence of
|
|
||||||
# terminally damaged ls-R files.
|
|
||||||
#
|
|
||||||
if test "x$1" = x--help || test "x$1" = x-help; then
|
|
||||||
echo "$usage"
|
|
||||||
exit 0
|
|
||||||
elif test "x$1" = x--version || test "x$1" = x-version; then
|
|
||||||
echo "`basename $0` $version"
|
|
||||||
kpsewhich --version
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
for type in $types ; do
|
|
||||||
echo "Indexing files of type $type"
|
|
||||||
case $type in
|
|
||||||
cls) outfile=$CLS_STYLEFILE
|
|
||||||
kpsetype=.tex;;
|
|
||||||
sty) outfile=$STY_STYLEFILE
|
|
||||||
kpsetype=.tex;;
|
|
||||||
bst) outfile=$BST_STYLEFILE
|
|
||||||
kpsetype=.bst;;
|
|
||||||
bib) outfile=$BIB_FILES
|
|
||||||
kpsetype=.bib;;
|
|
||||||
*) echo "ERROR: unknown type $type"
|
|
||||||
exit 1;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
rm -f $outfile
|
|
||||||
touch $outfile
|
|
||||||
|
|
||||||
dirs=`kpsewhich --show-path=$kpsetype 2>/dev/null | tr "$SEP" " " | sed -e 's%/\{2,\}%/%g' -e 's%!!%%g'`
|
|
||||||
|
|
||||||
for dir in $dirs ; do
|
|
||||||
find $dir -follow -name "*.$type" >>$outfile 2>/dev/null
|
|
||||||
done
|
|
||||||
|
|
||||||
done
|
|
||||||
#echo "list saved in $STYLEFILE"
|
|
||||||
#echo `wc -l $CLS_STYLEFILE` # only for information
|
|
||||||
#
|
|
||||||
# this is the end my friends ... Jim Morrison and the Doors in "The End"
|
|
@ -1,4 +1,5 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
# -*- coding: iso-8859-15 -*-
|
||||||
|
|
||||||
# file convertDefault.py
|
# file convertDefault.py
|
||||||
# This file is part of LyX, the document processor.
|
# This file is part of LyX, the document processor.
|
||||||
@ -21,4 +22,3 @@ if os.system(r'convert -depth 8 "%s" "%s"' % (sys.argv[1], sys.argv[2])) != 0:
|
|||||||
print >> sys.stderr, sys.argv[0], 'ERROR'
|
print >> sys.stderr, sys.argv[0], 'ERROR'
|
||||||
print >> sys.stderr, 'Execution of "convert" failed.'
|
print >> sys.stderr, 'Execution of "convert" failed.'
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
@ -52,11 +52,8 @@ void rescanTexStyles()
|
|||||||
Path p(package().user_support());
|
Path p(package().user_support());
|
||||||
Systemcall one;
|
Systemcall one;
|
||||||
one.startscript(Systemcall::Wait,
|
one.startscript(Systemcall::Wait,
|
||||||
"sh " +
|
"python " +
|
||||||
quoteName(libFileSearch("scripts", "TeXFiles.sh")));
|
quoteName(libFileSearch("scripts", "TeXFiles.py")));
|
||||||
// To be changed to
|
|
||||||
// "python " +
|
|
||||||
// quoteName(libFileSearch("scripts", "TeXFiles.py")));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user