MCPcopy Index your code
hub / github.com/TheAlgorithms/Python / added_solution_file_path

Function added_solution_file_path

scripts/validate_solutions.py:58–79  ·  view source on GitHub ↗

Collects only the solution file path which got added in the current pull request. This will only be triggered if the script is ran from GitHub Actions.

()

Source from the content-addressed store, hash-verified

56
57
58def added_solution_file_path() -> list[pathlib.Path]:
59 """Collects only the solution file path which got added in the current
60 pull request.
61
62 This will only be triggered if the script is ran from GitHub Actions.
63 """
64 solution_file_paths = []
65 headers = {
66 "Accept": "application/vnd.github.v3+json",
67 "Authorization": "token " + os.environ["GITHUB_TOKEN"],
68 }
69 files = httpx.get(get_files_url(), headers=headers, timeout=10).json()
70 for file in files:
71 filepath = pathlib.Path.cwd().joinpath(file["filename"])
72 if (
73 filepath.suffix != ".py"
74 or filepath.name.startswith(("_", "test"))
75 or not filepath.name.startswith("sol")
76 ):
77 continue
78 solution_file_paths.append(filepath)
79 return solution_file_paths
80
81
82def collect_solution_file_paths() -> list[pathlib.Path]:

Callers 1

Calls 4

get_files_urlFunction · 0.85
jsonMethod · 0.80
getMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected