Skip to content

system (2)

env_var

env_var(env_var: str) -> bool

Returns true if an environment variable with given name has a value.

Example

Jinja call:

{% if "CI" is env_var %}
True!
{% endif %}
Result:
True!

DocStrings

Parameters:

Name Type Description Default
env_var str

The environment variable name to check

required
Source code in src/jinjarope/envtests.py
191
192
193
194
195
196
197
def is_env_var(env_var: str) -> bool:
    """Returns true if an environment variable with given name has a value.

    Args:
        env_var: The environment variable name to check
    """
    return bool(os.getenv(env_var))

installed

installed(package_name: str) -> bool

Returns true if a package with given name is found.

Example

Jinja call:

{% if "jinja2" is installed %}
True!
{% endif %}
Result:
True!

DocStrings

Parameters:

Name Type Description Default
package_name str

The package name to check

required
Source code in src/jinjarope/envtests.py
180
181
182
183
184
185
186
187
188
def is_installed(package_name: str) -> bool:
    """Returns true if a package with given name is found.

    Args:
        package_name: The package name to check
    """
    import importlib.util

    return bool(importlib.util.find_spec(package_name))