MCPcopy Index your code
hub / github.com/clips/pattern / replace_entity

Function replace_entity

pattern/db/__init__.py:253–262  ·  view source on GitHub ↗
(match)

Source from the content-addressed store, hash-verified

251 """
252 # http://snippets.dzone.com/posts/show/4569
253 def replace_entity(match):
254 hash, hex, name = match.group(1), match.group(2), match.group(3)
255 if hash == "#" or name.isdigit():
256 if hex == '' :
257 return unichr(int(name)) # "&" => "&"
258 if hex in ("x","X"):
259 return unichr(int('0x'+name, 16)) # "&" = > "&"
260 else:
261 cp = htmlentitydefs.name2codepoint.get(name) # "&" => "&"
262 return cp and unichr(cp) or match.group() # "&foo;" => "&foo;"
263 if isinstance(string, (str, unicode)):
264 return RE_UNICODE.subn(replace_entity, string)[0]
265 return string

Callers

nothing calls this directly

Calls 2

groupMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…