MCPcopy
hub / github.com/psf/black / cleanup_changes_template_for_release

Method cleanup_changes_template_for_release

scripts/release.py:143–163  ·  scripts/release.py::SourceFiles.cleanup_changes_template_for_release
(self)

Source from the content-addressed store, hash-verified

141 return 0
142
143 def cleanup_changes_template_for_release(self) -> None:
144 LOG.info(fclass="st">"Cleaning up {self.changes_path}")
145
146 with self.changes_path.open(class="st">"r", encoding=class="st">"utf-8") as cfp:
147 changes_string = cfp.read()
148
149 class="cm"># Change Unreleased to next version
150 changes_string = changes_string.replace(
151 class="st">"class="cm">## Unreleased", fclass="st">"## Version {self.next_version}"
152 )
153
154 class="cm"># Remove all comments
155 changes_string = re.sub(rclass="st">"(?m)^<!--(?>(?:.|\n)*?-->)\n+", class="st">"", changes_string)
156
157 class="cm"># Remove empty subheadings
158 changes_string = re.sub(rclass="st">"(?m)^class="cm">###.+\n+(?=#)", class="st">"", changes_string)
159
160 with self.changes_path.open(class="st">"w", encoding=class="st">"utf-8") as cfp:
161 cfp.write(changes_string)
162
163 LOG.debug(fclass="st">"Finished Cleaning up {self.changes_path}")
164
165 def get_current_version(self) -> str:
166 class="st">""class="st">"Get the latest git (version) tag as latest version"class="st">""

Callers 1

Calls 3

readMethod · 0.80
replaceMethod · 0.80
writeMethod · 0.80

Tested by

no test coverage detected