summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/scripts/latex-make/figdepth.py
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/scripts/latex-make/figdepth.py')
-rwxr-xr-xMaster/texmf-dist/scripts/latex-make/figdepth.py51
1 files changed, 51 insertions, 0 deletions
diff --git a/Master/texmf-dist/scripts/latex-make/figdepth.py b/Master/texmf-dist/scripts/latex-make/figdepth.py
new file mode 100755
index 00000000000..7782d0b29e6
--- /dev/null
+++ b/Master/texmf-dist/scripts/latex-make/figdepth.py
@@ -0,0 +1,51 @@
+#!/usr/bin/env python
+#coding=utf8
+
+"""
+
+stdin : the original xfig file
+stdout : the output xfig file
+args : all depths we want to keep
+
+"""
+
+import optparse
+import os.path
+import sys
+
+def main():
+ parser = optparse.OptionParser()
+ (options, args) = parser.parse_args()
+
+ depths_to_keep = set()
+ for arg in args:
+ depths_to_keep.add(arg)
+
+ comment = ''
+ display = True
+ def show(depth, line):
+ if depth in depths_to_keep:
+ print comment+line,
+ return True
+ else:
+ return False
+ for line in sys.stdin:
+ if line[0] == '#':
+ comment += line
+ continue
+ if line[0] in "\t ":
+ if display:
+ print line
+ else:
+ Fld = line.split(' ', 9999)
+ if not Fld[0] or Fld[0] not in ('1', '2', '3', '4', '5'):
+ print comment+line
+ display = True
+ elif Fld[0] == '4':
+ display = show(Fld[3], line)
+ else:
+ display = show(Fld[6], line)
+ comment = ''
+
+if __name__ == "__main__":
+ main()