comparison rgToolFactory2.py @ 8:9d58cc32a12d draft

Uploaded
author fubar
date Mon, 12 Jan 2015 05:27:52 -0500
parents 61381bad936d
children ce5ec1d989fd
comparison
equal deleted inserted replaced
7:61381bad936d 8:9d58cc32a12d
143 "&": "&", 143 "&": "&",
144 ">": ">", 144 ">": ">",
145 "<": "&lt;", 145 "<": "&lt;",
146 "$": "\$" 146 "$": "\$"
147 } 147 }
148 html_unescape_table = dict(zip(html_escape_table.values(),html_escape_table.keys())) 148
149 def html_escape(text): 149 def html_escape(text):
150 """Produce entities within text.""" 150 """Produce entities within text."""
151 return "".join(html_escape_table.get(c,c) for c in text) 151 return "".join(html_escape_table.get(c,c) for c in text)
152 152
153 153
154 def html_unescape(text): 154 def html_unescape(text):
155 """Revert entities within text.""" 155 """Revert entities within text."""
156 return "".join(html_unescape_table.get(c,c) for c in text) 156 t = text.replace('&amp;','&').replace('&gt;','>').replace('&lt;','<').replace('\$','$')
157 return t
157 158
158 def cmd_exists(cmd): 159 def cmd_exists(cmd):
159 return subprocess.call("type " + cmd, shell=True, 160 return subprocess.call("type " + cmd, shell=True,
160 stdout=subprocess.PIPE, stderr=subprocess.PIPE) == 0 161 stdout=subprocess.PIPE, stderr=subprocess.PIPE) == 0
161 162