MCPcopy Create free account
hub / github.com/Graphify-Labs/graphify / _pascal_project_root

Function _pascal_project_root

graphify/extract.py:12980–13006  ·  view source on GitHub ↗

Return the highest ancestor directory that looks like a Pascal project root. Walks up the directory tree and tracks the topmost directory that: - is NOT a filesystem root (e.g. D:/, C:/, /) - has at least 2 .pas files OR at least 1 .dpr file as direct children The minimum-2 thr

(from_path: Path)

Source from the content-addressed store, hash-verified

12978
12979
12980def _pascal_project_root(from_path: Path) -> Path:
12981 """Return the highest ancestor directory that looks like a Pascal project root.
12982
12983 Walks up the directory tree and tracks the topmost directory that:
12984 - is NOT a filesystem root (e.g. D:/, C:/, /)
12985 - has at least 2 .pas files OR at least 1 .dpr file as direct children
12986
12987 The minimum-2 threshold avoids treating a level as the root just because a
12988 single stray .pas file was copied there. The filesystem-root exclusion
12989 prevents overshoot on drives that have a stray file directly at D:/.
12990
12991 Falls back to from_path.parent if nothing better is found.
12992 """
12993 best = from_path.parent
12994 current = from_path.parent
12995 for _ in range(12):
12996 if len(current.parts) <= 1:
12997 break # never use a filesystem root (D:/, C:/, /)
12998 pas_count = sum(1 for _ in current.glob("*.pas"))
12999 dpr_count = sum(1 for _ in current.glob("*.dpr"))
13000 if pas_count >= 2 or dpr_count >= 1:
13001 best = current
13002 parent = current.parent
13003 if parent == current:
13004 break
13005 current = parent
13006 return best
13007
13008
13009def _pascal_resolve_unit(from_path: Path, unit_name: str) -> str:

Callers 2

_pascal_resolve_unitFunction · 0.85
_pascal_resolve_classFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected