blob: 7782d0b29e63c13edd9f6551d5cdb8ede71746f0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
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()
|