-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add python script to update values for release
- Loading branch information
1 parent
eec588d
commit f15f16a
Showing
2 changed files
with
51 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
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,45 @@ | ||
# ---------------------------------------------------------------------------- # | ||
# UPDATING FILES FOR RELEASES # | ||
# ---------------------------------------------------------------------------- # | ||
from datetime import datetime | ||
import re | ||
|
||
version = input("Version String: ").lower() | ||
today = datetime.today().strftime('%Y-%m-%d') | ||
|
||
yes_choices = ['yes', 'y'] | ||
no_choices = ['no', 'n'] | ||
|
||
# ---------------------------------------------------------------------------- # | ||
# CITATION.cff # | ||
# ---------------------------------------------------------------------------- # | ||
file_name = "CITATION.cff" | ||
|
||
if input(f"Update {file_name}? (yes/No): ").lower() in yes_choices: | ||
content = "" | ||
|
||
with open(file_name, 'r') as in_file: | ||
content = in_file.read() | ||
|
||
with open(file_name, 'w') as out_file: | ||
content = re.sub(r"\ndate: .*\n", f"\ndate: {today}\n", content) | ||
content = re.sub(r"\nversion: .*\n", f"\nversion: {version}\n", content) | ||
|
||
out_file.write(content) | ||
|
||
# ---------------------------------------------------------------------------- # | ||
# CMakeLists.txt # | ||
# ---------------------------------------------------------------------------- # | ||
file_name = "CMakeLists.txt" | ||
|
||
if input(f"Update {file_name}? (yes/No): ").lower() in yes_choices: | ||
content = "" | ||
|
||
with open(file_name, 'r') as in_file: | ||
content = in_file.read() | ||
|
||
with open(file_name, 'w') as out_file: | ||
content = re.sub(r" VERSION .+\n", f" VERSION {version}\n", content) | ||
|
||
out_file.write(content) | ||
|