MCPcopy Index your code
hub / github.com/ZeroIntensity/pointers.py / _write_autogen

Function _write_autogen

gen.py:133–147  ·  view source on GitHub ↗
(file: str, text: str)

Source from the content-addressed store, hash-verified

131
132
133def _write_autogen(file: str, text: str) -> None:
134 with open(f"./src/pointers/{file}") as f:
135 lines = f.read().split("\n") # readlines was keeping the \n
136
137 with open(f"./src/pointers/{file}", "w") as f:
138 try:
139 index = lines.index("# autogenerated")
140 except ValueError:
141 index = lines.index(
142 "# autogenerated "
143 ) # in case there's trailing whitespace
144
145 f.write(
146 "\n".join(lines[: index + 1]) + f"\n{text}",
147 )
148
149
150def _get_type(ctype: str, *, add_pointer: bool = False) -> str | None:

Callers 2

_gen_ct_bindingsFunction · 0.85
mainFunction · 0.85

Calls 3

splitMethod · 0.80
joinMethod · 0.80
indexMethod · 0.45

Tested by

no test coverage detected