-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#!/usr/bin/env python3 | ||
# -*- coding: utf-8 -*- | ||
|
||
import sys | ||
from datetime import datetime | ||
from os.path import abspath, dirname, join | ||
|
||
from packaging.version import parse | ||
|
||
|
||
def main(): | ||
version = sys.argv[1] | ||
parse(version) | ||
versionQuoted = f'"{version}"' | ||
rootDir = dirname(dirname(abspath(__file__))) | ||
replaceVar(join(rootDir, "scal3/core.py"), "VERSION", versionQuoted) | ||
# replaceVar(join(rootDir, "pyproject.toml"), "version", versionQuoted) | ||
|
||
# update copyright year number | ||
for fname in ("about", "license-dialog"): | ||
with open(fname, encoding="utf-8") as file: | ||
text = file.read() | ||
pos = text.find("© ") | ||
text = text[: pos + 7] + str(datetime.now().year) + text[pos + 11 :] | ||
with open(fname, "w", encoding="utf-8") as file: | ||
file.write(text) | ||
|
||
|
||
def replaceVar(fname: str, name: str, value: str) -> None: | ||
prefix = name + " = " | ||
lines = [] | ||
with open(fname, encoding="utf-8") as _file: | ||
for _line in _file: | ||
line = _line | ||
if line.startswith(prefix): | ||
line = f"{name} = {value}\n" | ||
lines.append(line) | ||
with open(fname, mode="w", encoding="utf-8") as _file: | ||
_file.writelines(lines) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |