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

Function replace_entity

pattern/web/__init__.py:826–835  ·  view source on GitHub ↗
(match)

Source from the content-addressed store, hash-verified

824 """
825 # http://snippets.dzone.com/posts/show/4569
826 def replace_entity(match):
827 hash, hex, name = match.group(1), match.group(2), match.group(3)
828 if hash == "#" or name.isdigit():
829 if hex == '' :
830 return unichr(int(name)) # "&" => "&"
831 if hex in ("x","X"):
832 return unichr(int('0x'+name, 16)) # "&" = > "&"
833 else:
834 cp = htmlentitydefs.name2codepoint.get(name) # "&" => "&"
835 return cp and unichr(cp) or match.group() # "&foo;" => "&foo;"
836 if isinstance(string, (str, unicode)):
837 return RE_UNICODE.subn(replace_entity, string)[0]
838 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…