| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
""" |
| 18 |
Check for enabled features |
| 19 |
~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 20 |
|
| 21 |
""" |
| 22 |
|
| 23 |
import os as _os |
| 24 |
|
| 25 |
from ._inv import shell as _shell |
| 26 |
from ._inv import util as _util |
| 27 |
|
| 28 |
|
| 29 |
@_util.cached |
| 30 |
def black(_): |
| 31 |
""" |
| 32 |
Check if the black formatter is enabled |
| 33 |
|
| 34 |
Returns: |
| 35 |
bool: Black formatter enabled? |
| 36 |
""" |
| 37 |
return _shell.frompath("black") is not None |
| 38 |
|
| 39 |
|
| 40 |
@_util.cached |
| 41 |
def isort(ctx): |
| 42 |
""" |
| 43 |
Check if the isort formatter is enabled |
| 44 |
|
| 45 |
Returns: |
| 46 |
bool: isort formatter enabled? |
| 47 |
""" |
| 48 |
return _shell.frompath("isort") is not None |
| 49 |
|
| 50 |
|
| 51 |
@_util.cached |
| 52 |
def mypy(ctx): |
| 53 |
""" |
| 54 |
Check if the mypy checker is enabled |
| 55 |
|
| 56 |
Returns: |
| 57 |
bool: mypy checker enabled? |
| 58 |
""" |
| 59 |
return ctx.get("package") and _shell.frompath("mypy") is not None |
| 60 |
|
| 61 |
|
| 62 |
@_util.cached |
| 63 |
def pylint(ctx): |
| 64 |
""" |
| 65 |
Check if the pylint checker is enabled |
| 66 |
|
| 67 |
Returns: |
| 68 |
bool: pylint checker enabled? |
| 69 |
""" |
| 70 |
if _shell.frompath("pylint") is not None: |
| 71 |
return _os.path.exists(_shell.native("pylintrc")) |
| 72 |
return False |
| 73 |
|
| 74 |
|
| 75 |
@_util.cached |
| 76 |
def flake8(ctx): |
| 77 |
""" |
| 78 |
Check if the flake8 checker is enabled |
| 79 |
|
| 80 |
Returns: |
| 81 |
bool: flake8 checker enabled? |
| 82 |
""" |
| 83 |
if _shell.frompath("flake8") is not None: |
| 84 |
return _os.path.exists(_shell.native(".flake8")) |
| 85 |
return False |
| 86 |
|
| 87 |
|
| 88 |
@_util.cached |
| 89 |
def python_package(ctx): |
| 90 |
""" |
| 91 |
Check if the python package is configured |
| 92 |
|
| 93 |
Returns: |
| 94 |
bool: python package configured? |
| 95 |
""" |
| 96 |
return bool(ctx.get("package")) |
| 97 |
|
| 98 |
|
| 99 |
@_util.cached |
| 100 |
def python_wheels(ctx): |
| 101 |
""" |
| 102 |
Check if the python wheel building is configured |
| 103 |
|
| 104 |
Returns: |
| 105 |
bool: python package configured? |
| 106 |
""" |
| 107 |
return bool(ctx.get("package") and ctx.get("wheels", {}).get("build")) |
| 108 |
|
| 109 |
|
| 110 |
@_util.cached |
| 111 |
def python_tests(ctx): |
| 112 |
""" |
| 113 |
Check if the python tests are possible |
| 114 |
|
| 115 |
Returns: |
| 116 |
bool: python tests enabled? |
| 117 |
""" |
| 118 |
if ctx.get("package"): |
| 119 |
return _os.path.exists(_shell.native("tests")) |
| 120 |
return False |
| 121 |
|
| 122 |
|
| 123 |
@_util.cached |
| 124 |
def tox(_): |
| 125 |
""" |
| 126 |
Check if tox is installed |
| 127 |
|
| 128 |
Returns: |
| 129 |
bool: tox installed? |
| 130 |
""" |
| 131 |
return _shell.frompath("tox") is not None |
| 132 |
|
| 133 |
|
| 134 |
@_util.cached |
| 135 |
def tox_tests(ctx): |
| 136 |
""" |
| 137 |
Check if tox tests are possible |
| 138 |
|
| 139 |
Returns: |
| 140 |
bool: tox tests enabled? |
| 141 |
""" |
| 142 |
return tox(ctx) and python_tests(ctx) |
| 143 |
|
| 144 |
|
| 145 |
@_util.cached |
| 146 |
def sphinx(_): |
| 147 |
""" |
| 148 |
Check if sphinx is installed |
| 149 |
|
| 150 |
Returns: |
| 151 |
bool: Sphinx installed? |
| 152 |
""" |
| 153 |
return _shell.frompath("sphinx-build") is not None |
| 154 |
|
| 155 |
|
| 156 |
@_util.cached |
| 157 |
def terraform(ctx): |
| 158 |
""" |
| 159 |
Check if terraform is enabled |
| 160 |
|
| 161 |
Returns: |
| 162 |
bool: is terraform enabled? |
| 163 |
""" |
| 164 |
if _shell.frompath("terraform") is not None: |
| 165 |
path = ctx.paths.get("terraform") |
| 166 |
return path and _os.path.exists(_shell.native(path)) |
| 167 |
return False |
| 168 |
|
| 169 |
|
| 170 |
@_util.cached |
| 171 |
def sam(ctx): |
| 172 |
""" |
| 173 |
Check if sam is enabled |
| 174 |
|
| 175 |
Returns: |
| 176 |
bool: is sam enabled? |
| 177 |
""" |
| 178 |
if _shell.frompath("sam") is not None: |
| 179 |
path = ctx.paths.get("cloudformation") |
| 180 |
return path and _os.path.exists(_shell.native(path)) |
| 181 |
return False |