Skip to content

Commit

Permalink
Merge pull request michaelrigart#127 from YuxingW/jinja2_update
Browse files Browse the repository at this point in the history
relace contextfilter with pass_context
  • Loading branch information
markgoddard authored Jun 28, 2022
2 parents 35c57a9 + 4e83971 commit bc94897
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions filter_plugins/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@

import re

import jinja2
# NOTE: jinja2 3.1.0 dropped contextfilter in favour of pass_context.
try:
from jinja2 import pass_context
except ImportError:
from jinja2 import contextfilter as pass_context


def _fail(reason):
Expand Down Expand Up @@ -128,7 +132,7 @@ def _interface_check(context, interface, interface_type=None):
return _pass()


@jinja2.contextfilter
@pass_context
def ether_check(context, interface):
"""Check whether the active state of an Ethernet interface is as requested.
Expand All @@ -143,7 +147,7 @@ def ether_check(context, interface):
return result


@jinja2.contextfilter
@pass_context
def bridge_check(context, interface):
"""Check whether the active state of a bridge interface is as requested.
Expand Down Expand Up @@ -175,7 +179,7 @@ def bridge_check(context, interface):
return result


@jinja2.contextfilter
@pass_context
def bond_check(context, interface):
"""Check whether the active state of a bond interface is as requested.
Expand Down

0 comments on commit bc94897

Please sign in to comment.