]> git.lyx.org Git - lyx.git/blob - lib/scripts/fen2ascii.py
fix typo that put too many include paths for most people
[lyx.git] / lib / scripts / fen2ascii.py
1 #!/usr/bin/python
2 #
3 # Copyright (C) 2001 The LyX Team.
4 #
5 # This file is distributed under the GPL license.
6 #
7 # This script will convert a chess position in the FEN
8 # format to an ascii representation of the position.
9 #
10
11 import sys,string,os
12
13 os.close(0)
14 os.close(1)
15 sys.stdin = open(sys.argv[1],"r")
16 sys.stdout = open(sys.argv[2],"w")
17
18 line = sys.stdin.readline()
19 if line[-1] == '\n':
20     line = line[:-1]
21
22 line=string.split(line,' ')[0]
23 comp=string.split(line,'/')
24
25 cont=1
26 margin= " "*6
27
28 print margin+'   +'+"-"*15+'+'
29 for i in range(8):
30
31     cont = cont + 1
32     tmp=""
33     for j in comp[i]:
34         if j>='0' and j <= '9':
35             for k in range(int(j)):
36                 cont = cont + 1
37                 x, mod = divmod(cont,2)
38                 if mod : tmp = tmp + '| '
39                 else : tmp = tmp + '|*'
40         else :
41             tmp = tmp + '|' + j
42             cont = cont + 1
43
44     row = 8 - i
45     print margin, row, tmp+"|"
46
47 print margin+'   +'+"-"*15+'+'
48 print margin+'    a b c d e f g h '