def _update_setup_py(self, new_version): """ If this project has a setup.py, attempt to update it's version. """ self._update_version_file(new_version) setup_file = os.path.join(self.full_project_dir, "setup.py") if not os.path.exists(setup_file): return debug("Found setup.py, attempting to update version.") # We probably don't want version-release in setup.py as release is # an rpm concept. Hopefully this assumption on py_new_version = new_version.split('-')[0] f = open(setup_file, 'r') buf = StringIO() for line in f.readlines(): buf.write(replace_version(line, py_new_version)) f.close() # Write out the new setup.py file contents: f = open(setup_file, 'w') f.write(buf.getvalue()) f.close() buf.close() run_command("git add %s" % setup_file)
def _update_changelog(self, new_version): """ Update the changelog with the new version. """ # Not thrilled about having to re-read the file here but we need to # check for the changelog entry before making any modifications, then # bump the version, then update the changelog. f = open(self.changes_file, 'r') buf = StringIO() found_match = False done = False empty_line_regex = re.compile('^\s*$') for line in f.readlines(): if not done and not found_match and self.changelog_regex.match(line): buf.write(line) found_match = True elif not done and found_match and empty_line_regex.match(line): buf.write("\n- version %s\n" % new_version) done = True else: buf.write(line) f.close() # Write out the new file contents with our modified changelog entry: f = open(self.changes_file, 'w') f.write(buf.getvalue()) f.close() buf.close()
def _update_changelog(self, new_version): """ Update the changelog with the new version. """ # Not thrilled about having to re-read the file here but we need to # check for the changelog entry before making any modifications, then # bump the version, then update the changelog. f = open(self.changes_file, 'r') buf = StringIO() found_match = False done = False empty_line_regex = re.compile('^\s*$') for line in f.readlines(): if not done and not found_match and self.changelog_regex.match( line): buf.write(line) found_match = True elif not done and found_match and empty_line_regex.match(line): buf.write("\n- version %s\n" % new_version) done = True else: buf.write(line) f.close() # Write out the new file contents with our modified changelog entry: f = open(self.changes_file, 'w') f.write(buf.getvalue()) f.close() buf.close()
def _update_changelog(self, new_version): """ Update the changelog with the new version. """ # Not thrilled about having to re-read the file here but we need to # check for the changelog entry before making any modifications, then # bump the version, then update the changelog. f = open(self.spec_file, 'r') buf = StringIO() found_match = False for line in f.readlines(): match = self.changelog_regex.match(line) if match and not found_match: buf.write("%s %s\n" % (match.group(), new_version)) found_match = True else: buf.write(line) f.close() # Write out the new file contents with our modified changelog entry: f = open(self.spec_file, 'w') f.write(buf.getvalue()) f.close() buf.close()