Ticket #10655: indentation_t10655_r10178.diff

File indentation_t10655_r10178.diff, 1.5 KB (added by Andrew Badr, 15 years ago)
  • django/utils/text.py

     
    219219smart_split = allow_lazy(smart_split, unicode)
    220220
    221221def _replace_entity(match):
    222      text = match.group(1)
    223      if text[0] == u'#':
    224          text = text[1:]
    225          try:
    226              if text[0] in u'xX':
    227                  c = int(text[1:], 16)
    228              else:
    229                  c = int(text)
    230              return unichr(c)
    231          except ValueError:
    232              return match.group(0)
    233      else:
    234          try:
    235              return unichr(name2codepoint[text])
    236          except (ValueError, KeyError):
    237              return match.group(0)
     222    text = match.group(1)
     223    if text[0] == u'#':
     224        text = text[1:]
     225        try:
     226            if text[0] in u'xX':
     227                c = int(text[1:], 16)
     228            else:
     229                c = int(text)
     230            return unichr(c)
     231        except ValueError:
     232            return match.group(0)
     233    else:
     234        try:
     235            return unichr(name2codepoint[text])
     236        except (ValueError, KeyError):
     237            return match.group(0)
    238238
    239239_entity_re = re.compile(r"&(#?[xX]?(?:[0-9a-fA-F]+|\w{1,8}));")
    240240
    241241def unescape_entities(text):
    242      return _entity_re.sub(_replace_entity, text)
     242    return _entity_re.sub(_replace_entity, text)
    243243unescape_entities = allow_lazy(unescape_entities, unicode)
    244244
    245245def unescape_string_literal(s):
Back to Top