version_replace

privex.helpers.setuppy.bump.version_replace(data: str, old_version: str, new_version: str)str[source]

Replace the version line in data containing old_version with a version line containing new_version

Example:

>>> data = "# Example\nVERSION = '1.2.3' # Some comment"
>>> version_replace(data=data, old_version='1.2.3', new_version='1.3.0')
"# Example\nVERSION = '1.3.0' # Some comment"

As shown in the above example, it shouldn’t affect surrounding lines, or even in-line comments.

Note: old_version isn’t really used by this function. It exists for compatibility with user drop-in replacement functions that may need to know the old version to replace it.

Parameters
  • data (str) – The string contents containing VERSION = 'x.y.z'

  • old_version (str) – The existing version number, e.g. '1.2.3'

  • new_version (str) – The new version to replace it with, e.g. '1.3.0'

Return str replaced

data with the VERSION line updated.