From 036b8653046db7b3b10f2df18da14f7d4f4646e4 Mon Sep 17 00:00:00 2001 From: jurialmunkey Date: Wed, 1 Nov 2023 15:28:55 +1100 Subject: [PATCH] :sparkles: Add upper lower and capitalize funcs to executebuiltin --- resources/lib/method.py | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/resources/lib/method.py b/resources/lib/method.py index 3c98e50..a5acda4 100644 --- a/resources/lib/method.py +++ b/resources/lib/method.py @@ -148,6 +148,21 @@ def _set_escape(d): v = v.format(**kwargs) kwargs[k] = escape(v) + def _set_lower(d): + for k, v in d.items(): + k = k.format(**kwargs) + kwargs[k] = v.format(**kwargs).lower() + + def _set_upper(d): + for k, v in d.items(): + k = k.format(**kwargs) + kwargs[k] = v.format(**kwargs).upper() + + def _set_capitalize(d): + for k, v in d.items(): + k = k.format(**kwargs) + kwargs[k] = v.format(**kwargs).capitalize() + routes = { 'infolabels': _set_infolabels, 'regex': _set_regex, @@ -156,17 +171,12 @@ def _set_escape(d): 'decode': _set_decode, 'encode': _set_encode, 'escape': _set_escape, + 'lower': _set_lower, + 'upper': _set_upper, + 'capitalize': _set_capitalize, } - operations = [ - {'infolabels': meta.get('infolabels', {})}, - {'regex': meta.get('regex', {})}, - {'values': meta.get('values', {})}, - {'sums': meta.get('sums', {})}, - {'decode': meta.get('decode', {})}, - {'encode': meta.get('encode', {})}, - {'escape': meta.get('escape', {})} - ] + meta.get('operations', []) + operations = [{i: meta[i]} for i in routes if i in meta] + meta.get('operations', []) for i in operations: for k, v in i.items():