Files
@ 2a5d1585e748
Branch filter:
Location: Diana/src/sgfParser/__init__.py - annotation
2a5d1585e748
499 B
text/x-python
getting rid of last CRLF files
b66f5379b832 b66f5379b832 b66f5379b832 b66f5379b832 b66f5379b832 b66f5379b832 c6e20613189d 0ee71f3564f4 c6e20613189d 0ee71f3564f4 c6e20613189d c6e20613189d c6e20613189d c6e20613189d c6e20613189d c6e20613189d 0ee71f3564f4 0ee71f3564f4 b66f5379b832 c6e20613189d c6e20613189d c6e20613189d c6e20613189d c6e20613189d c6e20613189d 0ee71f3564f4 0ee71f3564f4 0ee71f3564f4 0ee71f3564f4 | def skipWhitespace(s,start):
i=start
while i<len(s) and s[i].isspace(): i+=1
return i
def strRowCol(s, i):
k=0
r,c=0,0
for (r,line) in enumerate(s.splitlines(True)):
c=i-k
if k+len(line)>i:
break
else:
k+=len(line)
return (r+1, c+1)
class ParserError(Exception):
def __init__(self,msg,s,i):
self.msg=msg
self.row,self.col=strRowCol(s, i)
def __str__(self):
return "{0} at row {1}, col {2}".format(self.msg,self.row,self.col)
class ParserWarning(ParserError):
pass
|