tree-sitter-pgn 1.0.12__cp38-abi3-musllinux_1_2_aarch64.whl → 1.0.14__cp38-abi3-musllinux_1_2_aarch64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of tree-sitter-pgn might be problematic. Click here for more details.

Binary file
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: tree-sitter-pgn
3
- Version: 1.0.12
3
+ Version: 1.0.14
4
4
  Summary: PGN grammar for tree-sitter
5
5
  License: BSD
6
6
  Project-URL: Homepage, https://github.com/rolandwalker/tree-sitter-pgn
@@ -26,12 +26,52 @@ Chess Portable Game Notation (PGN) grammar for [tree-sitter](https://github.com/
26
26
 
27
27
  * [Emacs pygn-mode](https://github.com/dwcoates/pygn-mode)
28
28
 
29
- ## Example
29
+ ## Highlighting Example
30
30
 
31
31
  <a href="/doc/images/pgn_syntax_highlight.png">
32
32
  <img src="/doc/images/pgn_syntax_highlight.png" width=500/>
33
33
  </a>
34
34
 
35
+ ## Python Example
36
+
37
+ ```python
38
+ import more_itertools
39
+ from tree_sitter import Language, Parser
40
+ import tree_sitter_pgn as ts_pgn
41
+
42
+ PGN_LANGUAGE = Language(ts_pgn.language())
43
+ parser = Parser(PGN_LANGUAGE)
44
+
45
+ query = PGN_LANGUAGE.query(
46
+ '''
47
+ (series_of_games
48
+ game: (game) @game)
49
+
50
+ (movetext
51
+ san_move: (san_move) @san_move)
52
+ ''')
53
+
54
+ with open('input_file.pgn', 'rb') as file:
55
+ content = b''.join(file.readlines())
56
+ tree = parser.parse(content)
57
+
58
+ matches = query.captures(tree.root_node)
59
+
60
+ merged_nodes = [
61
+ *matches.get('game', []),
62
+ *matches.get('san_move', []),
63
+ ]
64
+ merged_nodes = sorted(merged_nodes, key=lambda elt: elt.start_byte)
65
+
66
+ for game in more_itertools.split_before(merged_nodes, lambda node: node.type == 'game'):
67
+ san = []
68
+ for node in game:
69
+ if node.type == 'san_move' and node.text is not None:
70
+ san.append(node.text.decode().strip())
71
+ continue
72
+ print(' '.join(san))
73
+ ```
74
+
35
75
  ## References
36
76
 
37
77
  * [PGN specification](http://www.saremba.de/chessgml/standards/pgn/pgn-complete.htm)
@@ -1,11 +1,11 @@
1
- tree_sitter_pgn-1.0.12.dist-info/RECORD,,
2
- tree_sitter_pgn-1.0.12.dist-info/WHEEL,sha256=c8AgqvTAV2CV0uNCcGCMD7sIwsb_yzeV9zyKiYQz6Z8,112
3
- tree_sitter_pgn-1.0.12.dist-info/LICENSE,sha256=OQC_60bW3_K5dikbtjNFxNBdIsqGpiKnMdnRlEZW9pY,1323
4
- tree_sitter_pgn-1.0.12.dist-info/top_level.txt,sha256=GT5VMTItAEXgTjoJj2gP_fQVqZd7tY5TIRpOgyp1zlU,25
5
- tree_sitter_pgn-1.0.12.dist-info/METADATA,sha256=ZWRJffM0LWFVin1Ijs-S-37jN2ceLJ-gl46SeawQNjA,1244
6
- tree_sitter_pgn/binding.c,sha256=f0wnkjshn03m8OnEMcCgHzXlieObCAo50sacARwJ4-Y,677
7
1
  tree_sitter_pgn/__init__.pyi,sha256=8xf7bY1szgDY9HRJ7FJ326So4SFgMiSRfCB4LADkTpU,27
8
- tree_sitter_pgn/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
- tree_sitter_pgn/_binding.abi3.so,sha256=j5ZPslXXkv0sQZIeCSsYOr8XKQuj-xAJgbL-K1jONb4,295232
10
2
  tree_sitter_pgn/__init__.py,sha256=ZiLr1Q0znhhSjnr-HOQ9eYQGPl377jelB9rBPHWpUFc,86
3
+ tree_sitter_pgn/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
+ tree_sitter_pgn/binding.c,sha256=f0wnkjshn03m8OnEMcCgHzXlieObCAo50sacARwJ4-Y,677
5
+ tree_sitter_pgn/_binding.abi3.so,sha256=O9pR3gwDA6bufoGQg4F5-5YJj91DH7aOygJ_nq12-wo,389904
11
6
  tree_sitter_pgn/queries/highlights.scm,sha256=f0ZNijh1NqOo3M4c2ChC0ra5SjPtFmR0CJg_-gcrSUU,676
7
+ tree_sitter_pgn-1.0.14.dist-info/LICENSE,sha256=OQC_60bW3_K5dikbtjNFxNBdIsqGpiKnMdnRlEZW9pY,1323
8
+ tree_sitter_pgn-1.0.14.dist-info/METADATA,sha256=Y4WOkxI7VL6qIDZgeDEtbpG69YjnzjAG9gpiXgULT3A,2203
9
+ tree_sitter_pgn-1.0.14.dist-info/top_level.txt,sha256=GT5VMTItAEXgTjoJj2gP_fQVqZd7tY5TIRpOgyp1zlU,25
10
+ tree_sitter_pgn-1.0.14.dist-info/RECORD,,
11
+ tree_sitter_pgn-1.0.14.dist-info/WHEEL,sha256=c8AgqvTAV2CV0uNCcGCMD7sIwsb_yzeV9zyKiYQz6Z8,112