fixed obo

This commit is contained in:
FelixBrendel
2017-09-22 00:57:14 +02:00
parent 2bec0f59ac
commit c0f9352009
+9 -1
View File
@@ -4,11 +4,15 @@ filePath = sys.argv[1]
splitBoardAt = [0,50,100,150,200,250,300,350,400,450]
with open(filePath, 'r') as myfile:
sgfData = myfile.read().replace("\n", "").split(";")[1:-1]
sgfData = myfile.read().replace("\n", "").split(";")[1:]
sgfData[-1] = sgfData[-1][:-1]
header = sgfData[0]
moves = sgfData[1:]
# print(header)
# print(moves)
def get_tag_from_header(tag):
eventIdxStart = header.lower().find(tag.lower() + "[")
@@ -20,11 +24,14 @@ def get_tag_from_header(tag):
return ""
def extractCoordinatesFromMove(move):
try:
firstCoordinate = move[2]
secondCoordinate = ord(move[3])-96
if ord(move[2]) >= ord("i"):
firstCoordinate = chr(ord(firstCoordinate) + 1)
return firstCoordinate, secondCoordinate
except IndexError:
return -1,-1
def generateTitle():
out = parsedHeader["event"] + "\\\\"
@@ -88,6 +95,7 @@ for i in range(len(splitBoardAt)-1):
# new moves
for j in range(nextSplit-currentSplit):
firstCoordinate, secondCoordinate = extractCoordinatesFromMove(moves[currentSplit+j])
if not (firstCoordinate == -1 or secondCoordinate == -1):
outText += "\\move{%s}{%d} " % (firstCoordinate, parsedHeader["boardSize"] - secondCoordinate + 1)
if j % 5 == 4:
outText += "\n\t"