MCPcopy Create free account
hub / github.com/apache/solr / update_file

Function update_file

dev-tools/scripts/scriptutil.py:140–158  ·  view source on GitHub ↗
(filename, line_re, edit)

Source from the content-addressed store, hash-verified

138 return output.decode('utf-8')
139
140def update_file(filename, line_re, edit):
141 infile = open(filename, 'r')
142 buffer = []
143
144 changed = False
145 for line in infile:
146 if not changed:
147 match = line_re.search(line)
148 if match:
149 changed = edit(buffer, match, line)
150 if changed is None:
151 return False
152 continue
153 buffer.append(line)
154 if not changed:
155 raise Exception('Could not find %s in %s' % (line_re, filename))
156 with open(filename, 'w') as f:
157 f.write(''.join(buffer))
158 return True
159
160
161# branch types are "release", "stable" and "unstable"

Callers 4

update_solrversion_classFunction · 0.85
update_build_versionFunction · 0.85
update_solrconfigFunction · 0.85
update_buildFunction · 0.85

Calls 5

editFunction · 0.70
appendMethod · 0.65
writeMethod · 0.65
searchMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…