MCPcopy
hub / github.com/PyGithub/PyGithub / IndexFileWorker

Class IndexFileWorker

scripts/openapi.py:1882–1916  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1880
1881
1882class IndexFileWorker:
1883 def __init__(
1884 self, classes: dict[str, Any], index_config_file: Path, paths: list[dict[str, Any]], check_verbs: bool
1885 ):
1886 self.classes = classes
1887 self.paths = paths
1888 self.config = {}
1889 self.check_verbs = check_verbs
1890 self.tests_path = index_config_file.parent.parent / "tests"
1891
1892 if index_config_file.exists():
1893 with index_config_file.open("r") as r:
1894 self.config = json.load(r)
1895
1896 def index_file(self, filename: str):
1897 with open(filename) as r:
1898 code = "".join(r.readlines())
1899
1900 from pathlib import Path
1901
1902 paths = {}
1903 visitor = IndexPythonClassesVisitor(
1904 self.classes, paths, self.config.get("known method verbs", {}) if self.check_verbs else None
1905 )
1906 visitor.package("github")
1907 visitor.module(Path(filename.removesuffix(".py")).name)
1908 visitor.filename(filename)
1909 visitor.test_filename(str(self.tests_path / Path(filename).name))
1910 try:
1911 tree = cst.parse_module(code)
1912 tree.visit(visitor)
1913 # return path dict populated by this worker through 'paths' argument
1914 self.paths.append(paths)
1915 except Exception as e:
1916 raise RuntimeError(f"Failed to parse {filename}", e)
1917
1918
1919class HandleNewSchemas(Enum):

Callers 1

indexMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…