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