diff --git a/src/diana/sgfParser/node.py b/src/diana/sgfParser/node.py --- a/src/diana/sgfParser/node.py +++ b/src/diana/sgfParser/node.py @@ -1,4 +1,5 @@ from collections import deque +import logging as log from . import skipWhitespace, ParserWarning from .property import Property, GAME_INFO @@ -23,8 +24,7 @@ class Node: while Property.fits(s,i): i,x=Property.create(s,i) if x.name in res.properties: - # !! raise or log or ignore - raise ParserWarning('duplicate "{0}" property in a node. second value ignored'.format(x.name),s,i) + log.warning(ParserWarning('duplicate "{0}" property in a node. second value ignored'.format(x.name),s,i)) else: res.properties[x.name]=x i=skipWhitespace(s,i) diff --git a/src/diana/sgfParser/property.py b/src/diana/sgfParser/property.py --- a/src/diana/sgfParser/property.py +++ b/src/diana/sgfParser/property.py @@ -1,4 +1,5 @@ import re +import logging as log from .propValues import choose, singleton, listOf, compose, number, real, double, color, text, empty, anything, point, move, stone from . import skipWhitespace, ParserError @@ -24,7 +25,12 @@ class Property: res=Property() i,res.name=Property.ident(s,start) i=skipWhitespace(s,i) - i,x=Property.createValue(s,i,res.name) + try: + i,x=Property.createValue(s,i,res.name) + except ParserError as e: # malformed value + log.warning(e) + i,x=choose(listOf(anything), singleton(anything))(s,i) + res.name="_"+res.name res.value=x i=skipWhitespace(s,i) return (i,res)