From b69063d4064bcf2b9839f83092d657317a2a8e35 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Thu, 26 Apr 2012 13:14:12 +0530 Subject: [PATCH] esc/unesc chars -- for command line --- py/webnotes/utils/__init__.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/py/webnotes/utils/__init__.py b/py/webnotes/utils/__init__.py index 93a79cddf7..c2345f6aee 100644 --- a/py/webnotes/utils/__init__.py +++ b/py/webnotes/utils/__init__.py @@ -648,12 +648,31 @@ def get_file_timestamp(fn): else: return None +# to be deprecated def make_esc(esc_chars): """ Function generator for Escaping special characters """ return lambda s: ''.join(['\\' + c if c in esc_chars else c for c in s]) - + +# esc / unescape characters -- used for command line +def esc(s, esc_chars): + """ + Escape special characters + """ + for c in esc_chars: + esc_str = '\\' + c + s = s.replace(c, esc_str) + return s + +def unesc(s, esc_chars): + """ + UnEscape special characters + """ + for c in esc_chars: + esc_str = '\\' + c + s = s.replace(esc_str, c) + return s def get_doctype_label(dt=None): """