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

Method add_template_to_changes

scripts/release.py:121–141  ·  view source on GitHub ↗

Add the template to CHANGES.md if it does not exist

(self)

Source from the content-addressed store, hash-verified

119"""
120
121 def add_template_to_changes(self) -> int:
122 """Add the template to CHANGES.md if it does not exist"""
123 LOG.info(f"Adding template to {self.changes_path}")
124
125 with self.changes_path.open("r", encoding="utf-8") as cfp:
126 changes_string = cfp.read()
127
128 if "## Unreleased" in changes_string:
129 LOG.error(f"{self.changes_path} already has unreleased template")
130 return 1
131
132 templated_changes_string = changes_string.replace(
133 "# Change Log\n",
134 f"# Change Log\n\n{NEW_VERSION_CHANGELOG_TEMPLATE}",
135 )
136
137 with self.changes_path.open("w", encoding="utf-8") as cfp:
138 cfp.write(templated_changes_string)
139
140 LOG.info(f"Added template to {self.changes_path}")
141 return 0
142
143 def cleanup_changes_template_for_release(self) -> None:
144 LOG.info(f"Cleaning up {self.changes_path}")

Callers 1

mainFunction · 0.95

Calls 3

readMethod · 0.80
replaceMethod · 0.80
writeMethod · 0.80

Tested by

no test coverage detected