MCPcopy
hub / github.com/anysearch-ai/anysearch-skill / replace_marker_section

Function replace_marker_section

scripts/generate.py:137–150  ·  view source on GitHub ↗

Replace everything between marker comments for section_name with new_text.

(content, ext, section_name, new_text)

Source from the content-addressed store, hash-verified

135
136
137def replace_marker_section(content, ext, section_name, new_text):
138 """Replace everything between marker comments for section_name with new_text."""
139 begin_tag, end_tag = MARKERS[ext]
140 begin = begin_tag.format(name=section_name)
141 end = end_tag.format(name=section_name)
142
143 if begin not in content:
144 raise ValueError(f"BEGIN marker '{begin_tag.format(name=section_name)}' not found")
145 if end not in content:
146 raise ValueError(f"END marker '{end_tag.format(name=section_name)}' not found")
147
148 before, rest = content.split(begin, 1)
149 _, after = rest.split(end, 1)
150 return before + begin + "\n" + new_text + "\n" + end + after
151
152
153def generate_script(script_path, constants):

Callers 1

generate_scriptFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected