MCPcopy
hub / github.com/mne-tools/mne-python / _ensure_license

Function _ensure_license

tools/dev/ensure_headers.py:126–144  ·  view source on GitHub ↗
(lines, path)

Source from the content-addressed store, hash-verified

124
125
126def _ensure_license(lines, path):
127 # 1. Keep/replace existing
128 insert = get_license_idx(path, lines)
129
130 # 2. After author line(s)
131 if insert is None:
132 author_idx = get_author_idx(path, lines)
133 assert author_idx is not None, f"{author_idx=} for {path=}"
134 insert = author_idx + 1
135 if path_multi_author:
136 # Figure out where to insert the license:
137 for insert, line in enumerate(lines[author_idx + 1 :], insert):
138 if not line.startswith("# "):
139 break
140 if lines[insert].startswith(LICENSE_STARTS):
141 lines[insert] = LICENSE_LINE
142 else:
143 lines.insert(insert, LICENSE_LINE)
144 assert lines.count(LICENSE_LINE) == 1, f"{lines.count(LICENSE_LINE)=} for {path=}"
145
146
147def _ensure_copyright(lines, path):

Callers 1

ensure_headers.pyFile · 0.85

Calls 4

get_license_idxFunction · 0.85
get_author_idxFunction · 0.85
insertMethod · 0.80
countMethod · 0.80

Tested by

no test coverage detected