-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdemo.py
More file actions
17 lines (15 loc) · 704 Bytes
/
demo.py
File metadata and controls
17 lines (15 loc) · 704 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
"""
*This section is semi-automatically generated by the [ReadMe-auto.py](./ReadMe-auto.py).*
Here is an example.
You can pass an SGF filepath to the `sgf_parse()` function. Please read [tree.py](sgfutil/tree.py) for the data types defined for this `SgfParser()` class.
"""
from sgfutil import SgfParserNative, SgfParser
parser = SgfParser()
parser.sgf_parse('demo/Eg-multiple-branches.sgf')
print(parser)
"""
Or you can use `SgfParseNative()` class instead. In this case, the parsed results are saved with native Python data structures (a combination of lists, tuples, etc.):
"""
parser = SgfParserNative()
parser.sgf_parse('(;CA[utf-8]SZ[19];B[ab](;W[cd]C[Good move])(;W[ef];B[gh]))')
print(parser)