From 0dde18bb5684c42ac7c7c60eb4029095ab0016c9 Mon Sep 17 00:00:00 2001 From: Marc Bonnici Date: Fri, 8 Dec 2017 18:06:24 +0000 Subject: [PATCH] utils/misc: Add method to escape spaces --- devlib/utils/misc.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/devlib/utils/misc.py b/devlib/utils/misc.py index 857e99d..ec28c0b 100644 --- a/devlib/utils/misc.py +++ b/devlib/utils/misc.py @@ -414,6 +414,11 @@ def escape_double_quotes(text): return re.sub(r'\\("|\')', r'\\\\\1', text).replace('\"', '\\\"') +def escape_spaces(text): + """Escape spaces in the specified text""" + return text.replace(' ', '\ ') + + def getch(count=1): """Read ``count`` characters from standard input.""" if os.name == 'nt':