From f8f2f3a542e6bca10d6d894544d767e8af2633f6 Mon Sep 17 00:00:00 2001 From: Damian Canabal Date: Mon, 29 Sep 2008 13:21:35 +0000 Subject: [PATCH] rolled back public ent_re to private and added a function has_entities instead --HG-- extra : convert_revision : svn%3Ab85faa78-f9eb-468e-a121-7cced6da292c%40282 --- scrapy/trunk/scrapy/utils/markup.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/scrapy/trunk/scrapy/utils/markup.py b/scrapy/trunk/scrapy/utils/markup.py index 87c4a3c02..2faf5e2b9 100644 --- a/scrapy/trunk/scrapy/utils/markup.py +++ b/scrapy/trunk/scrapy/utils/markup.py @@ -5,7 +5,7 @@ Functions for dealing with markup text import re import htmlentitydefs -ent_re = re.compile(r'&(#?)([^&;]+);') +_ent_re = re.compile(r'&(#?)([^&;]+);') _tag_re = re.compile(r'<[a-zA-Z\/!].*?>', re.DOTALL) def remove_entities(text, keep=(), remove_illegal=True): @@ -45,8 +45,10 @@ def remove_entities(text, keep=(), remove_illegal=True): else: return u'&%s;' % m.group(2) - return ent_re.sub(convert_entity, text.decode('utf-8')) + return _ent_re.sub(convert_entity, text.decode('utf-8')) +def has_entities(text): + return bool(_ent_re.search(text)) def replace_tags(text, token=''): """Replace all markup tags found in the given text by the given token. By