MCPcopy Create free account
hub / github.com/FastLED/FastLED / _calculate_include_depth

Function _calculate_include_depth

ci/lint_cpp/test_unity_build.py:217–236  ·  view source on GitHub ↗

Calculate how many levels deep an include is relative to its parent. Args: included_path: The included file path (e.g., "platforms/arm/d21/_build.hpp") expected_prefix: The expected prefix (e.g., "platforms") Returns: Number of directory levels (0 = wrong prefi

(included_path: str, expected_prefix: str)

Source from the content-addressed store, hash-verified

215
216
217def _calculate_include_depth(included_path: str, expected_prefix: str) -> int:
218 """
219 Calculate how many levels deep an include is relative to its parent.
220
221 Args:
222 included_path: The included file path (e.g., "platforms/arm/d21/_build.hpp")
223 expected_prefix: The expected prefix (e.g., "platforms")
224
225 Returns:
226 Number of directory levels (0 = wrong prefix, 1 = immediate child, 2+ = grandchild)
227 """
228 if not included_path.startswith(expected_prefix + "/"):
229 return 0 # Doesn't match expected prefix
230
231 # Remove prefix to get relative part
232 relative_part = included_path[len(expected_prefix) + 1 :] # +1 for the "/"
233
234 # Count directory levels (excluding the final _build.hpp)
235 relative_parts = Path(relative_part).parts
236 return len(relative_parts) - 1 # Subtract 1 for BUILD_HPP itself
237
238
239def _get_line_number(content: str, match_start: int) -> int:

Callers 1

check_hierarchyFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected