Browse Source

esc/unesc chars -- for command line

version-14
Anand Doshi 13 years ago
parent
commit
b69063d406
1 changed files with 20 additions and 1 deletions
  1. +20
    -1
      py/webnotes/utils/__init__.py

+ 20
- 1
py/webnotes/utils/__init__.py View File

@@ -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):
"""


Loading…
Cancel
Save