diff --git a/src/diana/sgfparser/__init__.py b/src/diana/sgfparser/__init__.py --- a/src/diana/sgfparser/__init__.py +++ b/src/diana/sgfparser/__init__.py @@ -1,4 +1,9 @@ def skip_whitespace(s, start): + """Find the first non-whitespace character in a string. + + :param str s: an input string + :param int start: an index where the search starts + :return: index of the first non-whitespace character or len(s)""" i = start while i < len(s) and s[i].isspace(): i += 1 @@ -7,6 +12,12 @@ def skip_whitespace(s, start): def str_row_col(s, i): + """Translate a string index i to a row and col number. + + :param str s: an input string + :param int i: an index pointing into s + :return: a string position as (row, col) + :rtype: (int, int)""" k = 0 (r, c) = (0, 0) for (r, line) in enumerate(s.splitlines(True)):