MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / find_insertion_point

Function find_insertion_point

scripts/update_license_headers.py:217–241  ·  view source on GitHub ↗

Determine where to insert the header. Returns the line index where the header should be placed. The header will be inserted *before* this index, with a blank line after it. Special cases: - Shebang (#!/...) on line 0 → insert at line 1 - Dockerfile `# syntax=` on line 0 → inser

(lines: list[str], path: Path)

Source from the content-addressed store, hash-verified

215
216
217def find_insertion_point(lines: list[str], path: Path) -> int:
218 """Determine where to insert the header.
219
220 Returns the line index where the header should be placed. The header
221 will be inserted *before* this index, with a blank line after it.
222
223 Special cases:
224 - Shebang (#!/...) on line 0 → insert at line 1
225 - Dockerfile `# syntax=` on line 0 → insert at line 1
226 - Otherwise → insert at line 0
227 """
228 if not lines:
229 return 0
230
231 first = lines[0]
232
233 # Shebang line — keep it on line 0, header goes after.
234 if first.startswith("#!"):
235 return 1
236
237 # Dockerfile syntax directive.
238 if is_dockerfile(path) and first.lower().startswith("# syntax="):
239 return 1
240
241 return 0
242
243
244def insert_header(content: str, comment: str, path: Path) -> str:

Callers 1

insert_headerFunction · 0.85

Calls 1

is_dockerfileFunction · 0.85

Tested by

no test coverage detected