tex: POSUDEK4, submitted version - minor changes
[gostyle.git] / tex / style_fig_edit.py
blobde55799e1097c4b99c69a0e991ec741509236e1d
1 import re
2 import sys
4 texts = []
5 while True:
6 try:
7 texts += [sys.stdin.next()]
8 except StopIteration:
9 break
11 regexp = '"([^"]*)" ([123]) ([-\.0-9]*)'
13 min_sep = 0.035
15 def sep_column(col):
16 col.sort()
17 col.reverse()
18 last = None
19 col_new = []
20 for y, name in col:
21 if last != None:
22 if abs( y - last) < min_sep or y > last - min_sep:
23 y = last - min_sep
24 last = y
25 col_new += [(y,name)]
27 return col_new
29 def print_column(col, col_num):
30 col.sort()
31 col.reverse()
32 for y, name in col:
33 print '"%s" %s %s'%(name, str(col_num), str(y))
36 rex = re.compile(regexp)
37 cols = {}
38 for txt in texts:
39 m = rex.match( txt )
40 name, column, y = m.groups()
41 if column not in cols:
42 cols[column] = []
44 cols[column] += [(float(y), name)]
46 for col in cols:
47 sep = sep_column(cols[col])
49 # XXX
50 if col == str(1):
51 new_col = [sep[0] ]
52 for y, name in sep[1:9]:
53 new_col += [(y+0.04, name)]
54 for y, name in sep[9:]:
55 new_col += [(y+0.0909, name)]
57 sep = new_col
58 print_column(sep, col)