Did I find the right examples for you? yes no

All Samples(61)  |  Call(43)  |  Derive(0)  |  Import(18)
Removes HTML or XML character references and entities from a text string.

text -- The HTML (or XML) source text.
return -- The plain text, as a Unicode string, if necessary.

        def unescape(text):
    """
    Removes HTML or XML character references and entities from a text string.

    text -- The HTML (or XML) source text.
    return -- The plain text, as a Unicode string, if necessary.
    """
    def fixup(m):
        text = m.group(0)
        if text[:2] == "&#":
            # character reference
            try:
                if text[:3] == "&#x":
                    return unichr(int(text[3:-1], 16))
                else:
                    return unichr(int(text[2:-1]))
            except ValueError:
                pass
        else:
            # named entity
            try:
                text = unichr(htmlentitydefs.name2codepoint[text[1:-1]])
            except KeyError:
                pass
        return text  # leave as is
    return re.sub("&#?\w+;", fixup, text)
        


src/c/o/congress-HEAD/tasks/bill_info.py   congress(Download)
        bill_cache_for(bill_id, "cosponsors.html"),
        options)
    cosponsors_body = utils.unescape(cosponsors_body)
    cosponsors = cosponsors_for(cosponsors_body)
 
        bill_cache_for(bill_id, "summary.html"),
        options)
    summary_body = utils.unescape(summary_body)
    summary = summary_for(summary_body)
 
        bill_cache_for(bill_id, "titles.html"),
        options)
    titles_body = utils.unescape(titles_body)
    titles = titles_for(titles_body)
 
        bill_cache_for(bill_id, "actions.html"),
        options)
    actions_body = utils.unescape(actions_body)
    actions = actions_for(actions_body, bill_id)
 
    related_bills_body = utils.download(
        bill_url_for(bill_id, "K"),
        bill_cache_for(bill_id, "related_bills.html"),
        options)
    related_bills_body = utils.unescape(related_bills_body)

src/s/c/script.cdartmanager-HEAD/resources/lib/musicbrainz_utils.py   script.cdartmanager(Download)
#sys.path.append( os.path.join( BASE_RESOURCE_PATH, "lib" ) )
 
from utils import get_html_source, unescape, log, get_unicode, smart_unicode
 
artist_url = '''%s/ws/2/artist/?query=artist:"%s"&limit=%d'''
                mbartistid = re.search( '''<artist id="(.*?)">''', htmlsource)
                album["id"] = mbid.group(1)
                album["title"] = unescape( smart_unicode( mbtitle.group(1) ) )
                album["artist"] = unescape( smart_unicode( mbartist.group(1) ) )
                album["artist_id"] = mbartistid.group(1)
                        album["score"] = mbscore.group(1)
                        album["id"] = mbid.group(1)
                        album["title"] = unescape( smart_unicode( mbtitle.group(1) ) )
                        album["artist"] = unescape( smart_unicode( mbartist.group(1) ) )
                        album["artist_id"] = mbartistid.group(1)

src/c/o/congress-legislators-HEAD/scripts/bioguide.py   congress-legislators(Download)
      # doesn't support specifying an encoding, and the lxml.etree.HTMLParser doesn't
      # provide a cssselect method on element objects. So we'll just decode ourselves.
      body = utils.unescape(body, "Windows-1252")
 
      dom = lxml.html.parse(io.StringIO(body)).getroot()

src/s/p/spoj-0.0.20/src/spoj/commands/desc.py   spoj(Download)
# -*- coding: utf-8 -*-
from BeautifulSoup import BeautifulSoup
from . import Command
from ..settings import _url
from ..utils import unescape as _, pager, escape_sub
    def doing(self, args):
        __, soup = self.get_soup(_url('problems/'+args.problem_id))
 
        title = '%s <%s>' % (_(soup.findAll('h1')[1].text), args.problem_id)
        pp = soup.findAll('p')
        desc = BeautifulSoup(escape_sub(_(str(pp[1])))).text
        if desc.endswith('Input'):
            desc = desc[:-5]
        inp = _(pp[2].text)
        if inp.endswith('Output'):
            inp = inp[:-6]
        out = _(pp[3].text)
        idx = out.find('ExampleInput:')
        if idx:
            out = out[:idx]
 
        example = _(soup.find('pre').text)

src/s/p/spojcmd-0.3/src/spojcmd/commands/desc.py   spojcmd(Download)
# -*- coding: utf-8 -*-
from BeautifulSoup import BeautifulSoup
from . import Command
from ..settings import _url
from ..utils import unescape as _, pager, escape_sub
	print _url('problems/'+args.problem_id)
 
        title = '%s <%s>' % (_(soup.findAll('h1')[1].text), args.problem_id)
 
	print title
        if desc.endswith('Input'):
            desc = desc[:-5]
        inp = _(pp[2].text)
        if inp.endswith('Output'):
            inp = inp[:-6]
        out = _(pp[3].text)
            out = out[:idx]
 
        example = _(soup.find('pre').text)
        idx = example.find('Output:')
        _in = example[6:idx]

src/s/p/spoj-0.0.20/src/spoj/commands/list.py   spoj(Download)
from . import settings
from ..settings import _url
from ..utils import unescape as _, text_table, pager
 
 
        def cell_formatter(r, c, data_soup):
            if total_col > 5 and c == 1:
                return '*' if data_soup.find('img') else ''
            else:
                return _(data_soup.text)

src/s/p/spojcmd-0.3/src/spojcmd/commands/list.py   spojcmd(Download)
from . import settings
from ..settings import _url
from ..utils import unescape as _, text_table, pager
 
 
        def cell_formatter(r, c, data_soup):
            if total_col > 5 and c == 1:
                return '*' if data_soup.find('img') else ''
            else:
                return _(data_soup.text)

src/s/c/script.cinema.experience-HEAD/resources/lib/settings.py   script.cinema.experience(Download)
            setting_values = self.read_settings_xml()
            for k, v in sorted( setting_values.items() ):
                utils.log( "%30s: %s" % ( k, str( utils.unescape( v.decode('utf-8', 'ignore') ) ) ) )
        except:
            traceback.print_exc()

src/s/p/spoj-0.0.20/src/spoj/commands/tackle.py   spoj(Download)
from . import settings
from ..settings import _url
from ..utils import unescape as _, display_in_browser
 
 
                findAll('tr')[1].findAll('td')
        date = rows[2].text
        name = _(rows[3].text)
        status = _(rows[4].text)
        status = status.replace('edit', '')

src/s/p/spojcmd-0.3/src/spojcmd/commands/tackle.py   spojcmd(Download)
from . import settings
from ..settings import _url
from ..utils import unescape as _, display_in_browser
 
 
                findAll('tr')[1].findAll('td')
        date = rows[2].text
        name = _(rows[3].text)
        status = _(rows[4].text)
        status = status.replace('edit', '')

  1 | 2 | 3  Next