version_replace¶
-
privex.helpers.setuppy.bump.version_replace(data: str, old_version: str, new_version: str) → str[source]¶ Replace the version line in
datacontainingold_versionwith a version line containingnew_versionExample:
>>> 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_versionisn’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.