-
Notifications
You must be signed in to change notification settings - Fork 129
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#3856: Use site-specific lists of recipes in the RTW
Co-authored-by: Emma Hogan <[email protected]>
- Loading branch information
1 parent
2a6be12
commit 983de78
Showing
8 changed files
with
276 additions
and
148 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
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
37 changes: 37 additions & 0 deletions
37
esmvaltool/utils/recipe_test_workflow/Jinja2Tests/file_exists.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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
""" | ||
Module for custom Jinja2 Tests. | ||
In Jinja2 "tests" are used to test a variable against an expression. | ||
Refer to Jinja2 tests: | ||
https://jinja.palletsprojects.com/en/stable/templates/#tests | ||
Jinja2 has a number of Builtin tests: | ||
https://jinja.palletsprojects.com/en/stable/templates/#list-of-builtin-tests | ||
Jinja2 also allows for writing custom tests in Python: | ||
https://jinja.palletsprojects.com/en/stable/api/#custom-tests | ||
Cylc supports custom filters, tests and globals as described here: | ||
https://cylc.github.io/cylc-doc/stable/html/user-guide/writing-workflows/jinja2.html#custom-jinja2-filters-tests-and-globals | ||
""" | ||
from pathlib import Path | ||
|
||
|
||
def file_exists(file_path): | ||
""" | ||
Test if a file exists. | ||
Parameters | ||
---------- | ||
file_path : str | ||
A file path. | ||
Returns | ||
------- | ||
bool | ||
Returns True if the file exists. | ||
""" | ||
run_directory = Path.cwd() | ||
site_recipes_file_path = run_directory / file_path | ||
return site_recipes_file_path.is_file() |
Oops, something went wrong.