Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NameError: name 'name2codepoint' is not defined #16

Closed
kenorb opened this issue Sep 26, 2017 · 2 comments
Closed

NameError: name 'name2codepoint' is not defined #16

kenorb opened this issue Sep 26, 2017 · 2 comments

Comments

@kenorb
Copy link
Collaborator

kenorb commented Sep 26, 2017

Downloading 'b'somefile'' from 'b'http://www.example.com/somefile'' into ....
Error: Reading socket timed out, try again later.

Traceback (most recent call last):
  File "google_dl", line 161, in <module>
    for results in page:
  File "google_dl", line 79, in __next__
    results = self.gs.get_results()
  File "~/.python/xgoogle/search.py", line 201, in get_results
    results = self._extract_results(page)
  File "~/.python/xgoogle/search.py", line 288, in _extract_results
    eres = self._extract_result(result)
  File "~/.python/xgoogle/search.py", line 295, in _extract_result
    title, url = self._extract_title_url(result)
  File "~/.python/xgoogle/search.py", line 309, in _extract_title_url
    title = self._html_unescape(title)
  File "~/.python/xgoogle/search.py", line 369, in _html_unescape
    return re.sub(r'&([^;]+);', entity_replacer, s, re.U)
  File "~/anaconda/lib/python3.6/re.py", line 191, in sub
    return _compile(pattern, flags).sub(repl, string, count)
  File "~/.python/xgoogle/search.py", line 356, in entity_replacer
    if entity in name2codepoint:
NameError: name 'name2codepoint' is not defined

Example command using google_dl utility:

google_dl -s http://www.marquette.edu/maqom/ -f pdf ""
@kenorb kenorb added the bug label Sep 26, 2017
@kenorb kenorb added the bounty label Jan 18, 2018
@PrisonGlobe
Copy link

name2code is a local variable there for doesn't exist outside of your function.

@kenorb
Copy link
Collaborator Author

kenorb commented Jan 18, 2018

It's module and it used in different parts as well, e.g.

$ grep -R name2codepoint .
./BeautifulSoup.py:  from htmlentitydefs import name2codepoint
./BeautifulSoup.py:  name2codepoint = {}
./BeautifulSoup.py:        if self.convertHTMLEntities and x in name2codepoint:
./BeautifulSoup.py:            return unichr(name2codepoint[x])
./BeautifulSoup.py:                data = unichr(name2codepoint[ref])
./googlesets.py:from htmlentitydefs import name2codepoint
./realtime.py:from htmlentitydefs import name2codepoint
./realtime.py:            if entity in name2codepoint:
./realtime.py:                return unichr(name2codepoint[entity])
./search.py:            if entity in name2codepoint:
./search.py:                return unichr(name2codepoint[entity])
./search.py:            if entity in name2codepoint:
./search.py:                return unichr(name2codepoint[entity])
./search.py:            if entity in name2codepoint:
./search.py:                return unichr(name2codepoint[entity])
./search.py:            if entity in name2codepoint:
./search.py:                return unichr(name2codepoint[entity])
./sponsoredlinks.py:from htmlentitydefs import name2codepoint
./sponsoredlinks.py:            if entity in name2codepoint:
./sponsoredlinks.py:                return unichr(name2codepoint[entity])

What is your suggestion then?

@kenorb kenorb closed this as completed in de4e973 Jun 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants