feat: update makejinja to 2.5.0 (#1221)
* feat: update makejinja to 2.5.0 and implement mjfilter Signed-off-by: Devin Buhl <devin@buhl.casa> * fix: move logic for skip tests Signed-off-by: Devin Buhl <devin@buhl.casa> * feat: update makejinja to 2.5.0 Signed-off-by: Devin Buhl <devin@buhl.casa> --------- Signed-off-by: Devin Buhl <devin@buhl.casa>
This commit is contained in:
1 parent
8265c80909
commit
4be97f78e8
4 files changed
+8
-9
No files matched your search
@@ -0,0 +1,29 @@
|
||||
from typing import Any
|
||||
import bcrypt
|
||||
import makejinja
|
||||
import netaddr
|
||||
|
||||
import validation
|
||||
|
||||
def nthhost(value: str, query: int) -> str:
|
||||
value = netaddr.IPNetwork(value)
|
||||
try:
|
||||
nth = int(query)
|
||||
if value.size > nth:
|
||||
return str(value[nth])
|
||||
except ValueError:
|
||||
return False
|
||||
return value
|
||||
|
||||
def encrypt(value: str) -> str:
|
||||
return bcrypt.hashpw(value.encode(), bcrypt.gensalt(rounds=10)).decode("ascii")
|
||||
|
||||
class Plugin(makejinja.plugin.Plugin):
|
||||
def __init__(self, data: dict[str, Any]):
|
||||
if data.get("skip_tests", False):
|
||||
return
|
||||
|
||||
validation.validate(data)
|
||||
|
||||
def filters(self) -> makejinja.plugin.Filters:
|
||||
return [nthhost, encrypt]
|
||||
Reference in new issue
Block a user