summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/scripts/latex-make/gensubfig.py
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2014-10-11 22:30:33 +0000
committerKarl Berry <karl@freefriends.org>2014-10-11 22:30:33 +0000
commit4888499385c44655bec69496f0e01649d7636627 (patch)
treeb4530c653b64a9b165768c4423d6bcf0dd192c31 /Master/texmf-dist/scripts/latex-make/gensubfig.py
parent9406c7d3ffc09ac95d52d72e53d84e010a0a747d (diff)
latex-make (11oct14)
git-svn-id: svn://tug.org/texlive/trunk@35357 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/scripts/latex-make/gensubfig.py')
-rwxr-xr-xMaster/texmf-dist/scripts/latex-make/gensubfig.py63
1 files changed, 63 insertions, 0 deletions
diff --git a/Master/texmf-dist/scripts/latex-make/gensubfig.py b/Master/texmf-dist/scripts/latex-make/gensubfig.py
new file mode 100755
index 00000000000..a6fcd5d5677
--- /dev/null
+++ b/Master/texmf-dist/scripts/latex-make/gensubfig.py
@@ -0,0 +1,63 @@
+#!/usr/bin/env python
+#coding=utf8
+
+"""
+
+Arguments passes :
+ - fichier image (image.fig ou image.svg)
+ - -s fichier subfig (image.subfig)
+ - -p chemin du script pour generer les sous-images (svgdepth.py ou figdepth.py)
+
+Sortie standard :
+ - makefile pour creer les sous-images (au format .fig ou .svg), et pour les supprimer
+
+"""
+
+from optparse import OptionParser
+import os.path
+
+def main():
+ parser = OptionParser(usage='usage: %prog [options] svg file', description='Creates a\
+Makefile generating subfigures using figdepth.py or svgdepth.py')
+ parser.add_option("-s", "--subfig", dest="subfig", help="subfig file")
+ parser.add_option("-p", "--depth", dest="depth", help="full path of depth script")
+ (options, args) = parser.parse_args()
+ if len(args) < 1:
+ parser.error("incorrect number of arguments")
+ if not options.subfig:
+ parser.error("no subfig file specified")
+ if not options.depth:
+ parser.error("no depth script specified")
+
+ (root, ext) = os.path.splitext(args[0])
+ sf_name = options.subfig
+ ds_name = options.depth
+ varname = '%s_FIGS' % root.upper()
+
+ subfigs = []
+ for line in open(options.subfig, 'r'):
+ t = line.find('#') # looking for comments
+ if t > -1: line = line[0:t] # remove comments...
+ line = line.strip() #remove blank chars
+ if line == '': continue
+ subfigs.append(line)
+
+ count = 1
+ for subfig in subfigs:
+ print "%s_%d%s: %s%s %s" % (root, count, ext, root, ext, sf_name)
+ print "\t%s %s" % (ds_name, subfig)
+ print ""
+ count += 1
+ print "%s := $(foreach n, " % varname,
+ count = 1
+ for subfig in subfigs:
+ print '%d ' % count,
+ count += 1
+ print ", %s_$(n)%s)" % (root, ext)
+ print "FILES_TO_DISTCLEAN += $(%s)" % varname
+ print "FIGS2CREATE_LIST += $(%s)" % varname
+ print "$(TEMPORAIRE): $(%s)" % varname
+ print "$(TEMPORAIRE): $(%s)" % varname
+
+if __name__ == "__main__":
+ main()