From 3a514444f329fe49258daa8a399968211d9246c8 Mon Sep 17 00:00:00 2001 From: "SilverStrings (Matt)" <37874207+SilverStrings024@users.noreply.github.com> Date: Mon, 12 Jul 2021 18:06:37 -0400 Subject: [PATCH] Update utils.py Updated to use the tested and better documented version (Is not tested with Matomo or Django. Only with python) --- analytical/utils.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/analytical/utils.py b/analytical/utils.py index d2200ee..62679d8 100644 --- a/analytical/utils.py +++ b/analytical/utils.py @@ -176,9 +176,10 @@ def build_paq_cmd(cmd, args=[]): """ def __to_js_arg(arg): """ - Turn the argument into a js variable. - True -> true - False -> false + :Args: + - arg: The variable (Matomo argument) to be converted to JS. + :Return: + Javascript version of the passed arg parameter """ # Recursively handle dictionaries if isinstance(arg, dict): @@ -187,18 +188,14 @@ def build_paq_cmd(cmd, args=[]): arg.pop(k) arg[__to_js_arg(k)] = __to_js_arg(v) return arg - # Handle bools - elif isinstance(arg, bool): if arg: arg = "true" else: arg = "false" - # Handle lists elif isinstance(arg, list): for elem_idx in range(len(arg)): arg[elem_idx] = __to_js_arg(arg[elem_idx]) - return arg paq = "_paq.push(['%s', " % (cmd)