def interpret_FG(s, context): """Interpret an FG (figure) property value. Returns a pair (flags, string), or None. flags is an integer; see http://www.red-bean.com/sgf/properties.html#FG """ if s == b"": return None flags, name = sgf_grammar.parse_compose(s) return int(flags), interpret_simpletext(name, context)
def interpret_ARLN_list(values, context): """Interpret an AR (arrow) or LN (line) property value. Returns a list of pairs (point, point), where point is a pair (row, col) """ result = [] for s in values: p1, p2 = sgf_grammar.parse_compose(s) result.append((interpret_point(p1, context), interpret_point(p2, context))) return result
def interpret_LB_list(values, context): """Interpret an LB (label) property value. Returns a list of pairs ((row, col), string). """ result = [] for s in values: point, label = sgf_grammar.parse_compose(s) result.append( (interpret_point(point, context), interpret_simpletext(label, context))) return result
def interpret_AP(s, context): """Interpret an AP (application) property value. Returns a pair of strings (name, version number) Permits the version number to be missing (which is forbidden by the SGF spec), in which case the second returned value is an empty string. """ application, version = sgf_grammar.parse_compose(s) if version is None: version = b"" return (interpret_simpletext(application, context), interpret_simpletext(version, context))