INNER CODE UNIT · Python
replace_chunk
simonw/simonw · build_readme.py:62
def replace_chunk(content, marker, chunk, inline=False):
r = re.compile(
r"<!\-\- {} starts \-\->.*<!\-\- {} ends \-\->".format(marker, marker),
re.DOTALL,
)
if not inline:
chunk = "\n{}\n".format(chunk)
chunk = "<!-- {} starts -->{}<!-- {} ends -->".format(marker, chunk, marker)
return r.sub(chunk, content)
# Single search query template. QUERY_STRING and AFTER are substituted in. Each
# repo node carries its README (a few common filename spellings are requested as
# aliases) so we never need a second fetch to mirror it.
GRAPHQL_SEARCH_QUERY = """
query {
search(first: 100, type: REPOSITORY, query: "QUERY_STRING", after: AFTER) {
pageInfo {