MCPcopy
hub / github.com/psycopg/psycopg / update_file

Function update_file

tools/update_errors.py:199–215  ·  view source on GitHub ↗
(fn, new_lines)

Source from the content-addressed store, hash-verified

197
198
199def update_file(fn, new_lines):
200 logger.info("updating %s", fn)
201
202 with open(fn) as f:
203 lines = f.read().splitlines()
204
205 istart, iend = (
206 i
207 for i, line in enumerate(lines)
208 if re.match(r"\s*(#|\.\.)\s*autogenerated:\s+(start|end)", line)
209 )
210
211 lines[istart + 1 : iend] = new_lines
212
213 with open(fn, "w") as f:
214 for line in lines:
215 f.write(line + "\n")
216
217
218if __name__ == "__main__":

Callers 1

mainFunction · 0.70

Calls 3

infoMethod · 0.45
readMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected