vc-authn-oidc
vc-authn-oidc copied to clipboard
Add User Definable Variable Substitution
This PR resolves #649
I have documented and added a user definable way to add new variable substitutions. A simple API for defining regex based variable matching. Here is a simple example usage.
def sub_days_plus_one(days: str) -> int:
"""Strings like '$sub_days_plus_one_4' will be replaced with the
final number incremented by one. In this case 5.
$sub_days_plus_one_4 -> 5
$sub_days_plus_one_10 -> 11"""
return int(days) + 1
variable_substitution_map.add_variable_substitution(
r"\$sub_days_plus_one_(\d+)", sub_days_plus_one
)
variable_substitution_map["$sub_days_plus_one_1"] # -> 2