MCPcopy Create free account
hub / github.com/ProjectUnifree/unifree / initialize

Method initialize

unifree/source_code_parsers.py:27–39  ·  view source on GitHub ↗
(cls)

Source from the content-addressed store, hash-verified

25
26 @classmethod
27 def initialize(cls) -> None:
28 c_sharp_library_path = cls._c_sharp_library_path()
29 if not os.path.exists(c_sharp_library_path):
30 c_sharp_library_folder_path = os.path.dirname(c_sharp_library_path)
31 log.debug(f"C# library not found at '{c_sharp_library_path}', building...")
32
33 tree_sitter_csharp_folder_path = os.path.join(unifree.project_root, 'vendor', 'tree-sitter-c-sharp')
34 if not os.path.exists(tree_sitter_csharp_folder_path):
35 log.error(f"CSharp implementation of the tree sitter is not found at {tree_sitter_csharp_folder_path}")
36 raise RuntimeError(f"CSharp tree sitter not found in {tree_sitter_csharp_folder_path}")
37
38 os.makedirs(c_sharp_library_folder_path, exist_ok=True)
39 tree_sitter.Language.build_library(c_sharp_library_path, [tree_sitter_csharp_folder_path])
40
41 def parse(self, file_path: str) -> tree_sitter.Tree:
42 if not os.path.exists(file_path) or not os.path.isfile(file_path):

Callers 1

__init__Method · 0.95

Calls 1

_c_sharp_library_pathMethod · 0.80

Tested by

no test coverage detected