-
Notifications
You must be signed in to change notification settings - Fork 26
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
3 changed files
with
127 additions
and
47 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
examples/cellpy project template/cellpy_cookie_NAME/cookiecutter.json
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
53 changes: 52 additions & 1 deletion
53
examples/cellpy project template/cellpy_cookie_NAME/hooks/pre_gen_project.py
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 |
---|---|---|
@@ -1,3 +1,54 @@ | ||
import os | ||
import sys | ||
|
||
print(f"setting up project in the following directory: {os.getcwd()}") | ||
|
||
MIN_CELLPY_MAJOR, MIN_CELLPY_MINOR = 1, 0 | ||
cellpy_version = "{{ cookiecutter.cellpy_version }}" | ||
major, minor = cellpy_version.split(".")[:2] | ||
major, minor = int(major), int(minor) | ||
too_old = False | ||
|
||
if major < MIN_CELLPY_MAJOR: | ||
too_old = True | ||
|
||
if major == MIN_CELLPY_MAJOR: | ||
if minor < MIN_CELLPY_MINOR: | ||
too_old = True | ||
|
||
# additional test for patch version since v.1.0.0 -> v.1.0.1 introduced a new batch method. | ||
if major == MIN_CELLPY_MAJOR and minor == MIN_CELLPY_MINOR: | ||
patch = cellpy_version.split(".")[2] | ||
if patch.startswith("0"): | ||
print() | ||
print(" ERROR ".center(80, "=")) | ||
print() | ||
print(" Cellpy Cookie says: 'OH NO!!!!'") | ||
print(" Cellpy Cookie says: 'Your version of cellpy is too old - aborting!'") | ||
print(" Cellpy Cookie says: 'Please update cellpy to the latest version'") | ||
print() | ||
print(" $ python -m pip install cellpy --upgrade") | ||
print() | ||
print(" Cellpy Cookie says: 'or use the cookie standard_1_0_0 instead!'") | ||
print() | ||
print(" $ cellpy new --template starndard_1_0_0") | ||
print() | ||
print(80 * "=") | ||
print() | ||
sys.exit(1) | ||
|
||
# end of additional test | ||
|
||
if too_old: | ||
print() | ||
print(" ERROR ".center(80, "=")) | ||
print() | ||
print(" Cellpy Cookie says: 'OH NO!!!!'") | ||
print(" Cellpy Cookie says: 'Your version of cellpy is too old - aborting!'") | ||
print() | ||
print(80 * "=") | ||
print() | ||
sys.exit(1) | ||
print(" Cellpy Cookie says: 'using cookie from the cellpy_cookies repository'") | ||
print(" Cellpy Cookie says: 'setting up project in the following directory:'") | ||
print(f" {os.getcwd()}'") | ||
print() |
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