From 3b16769152e6f5bff553a37d0e69f35dee28dc29 Mon Sep 17 00:00:00 2001 From: Jeremy Stanley Date: Thu, 17 Mar 2016 10:03:45 +0000 Subject: [PATCH] Make escape_macros no-op on nontext values Update the escape_macros() function to deal with YAML style Element.get() that may return datatypes other than str. This allows for indiscriminately passing facets through the function without recasting them. --- lib/mudpy/misc.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/mudpy/misc.py b/lib/mudpy/misc.py index bcb50c2..ed205a2 100644 --- a/lib/mudpy/misc.py +++ b/lib/mudpy/misc.py @@ -1,6 +1,6 @@ """Miscellaneous functions for the mudpy engine.""" -# Copyright (c) 2004-2015 Jeremy Stanley . Permission +# Copyright (c) 2004-2016 Jeremy Stanley . Permission # to use, copy, modify, and distribute this software is granted under # terms provided in the LICENSE file distributed with this software. @@ -1342,9 +1342,12 @@ def replace_macros(user, text, is_input=False): return text -def escape_macros(text): +def escape_macros(value): """Escapes replacement macros in text.""" - return text.replace("$(", "$_(") + if type(value) is str: + return value.replace("$(", "$_(") + else: + return value def first_word(text, separator=" "): -- 2.11.0