GithubHelp home page GithubHelp logo

mhwgoo / cambridge Goto Github PK

View Code? Open in Web Editor NEW
50.0 3.0 6.0 20.46 MB

Terminal version of Cambridge Dictionary by default. Also supports Merrian-Webster Dictionary.

License: GNU General Public License v3.0

Python 99.09% Makefile 0.91%
python cambridge-dictionary dictionary merrian-webster web-scraping

cambridge's Issues

Webster doesn't work

camb -wf hello
2022-11-14 10:29:27 ERROR webster.py[152] The fetched result is not what we intended for the word due to the network or website reasons, please try again.

key error?

C:\Users\abc>camb commit
Traceback (most recent call last):
File "c:\python39\lib\runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "c:\python39\lib\runpy.py", line 87, in run_code
exec(code, run_globals)
File "C:\Python39\Scripts\camb.exe_main
.py", line 4, in
File "c:\python39\lib\site-packages\cambridge\cambridge.py", line 512, in
from .log import logger
File "c:\python39\lib\site-packages\cambridge\log.py", line 11, in
data = Path(os.environ["HOME"]).absolute() / ".local" / "share" / "cambridge"
File "c:\python39\lib\os.py", line 679, in getitem
raise KeyError(key) from None
KeyError: 'HOME'

Fail in case of word not found

Current in case the word is not found, cambridge asks the user to select a similar word that is present in the dictionary.

I'm basic building a GUI around cambridge, and I need it to fail and return exit code != 0 in case the word is not found, without asking the user.

Otherwise my GUI will hang waiting for cambridge to exit.

Crash

➜  camb bolster

bolster verb T
UK |ˈbəʊl.stər| US |ˈboʊl.stɚ|
: to support or improve something or make it stronger
|More money is needed to bolster the industry.
|She tried to bolster my confidence/morale (= encourage me and make me feel stronger) by telling me that I had a special talent.
|They need to do something to bolster their image.

bolster noun C
UK |ˈbəʊl.stər| US |ˈboʊl.stɚ|
: a long firm cylinder-shaped pillow

FOUND "bolster" from CAMBRIDGE in cache. You can add "-f -w" to fetch the MERRIAM_WEBSTER dictionary
Traceback (most recent call last):
  File "/home/USERNAME/.pyenv/versions/cambridge/bin/camb", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/home/USERNAME/.pyenv/versions/3.12.2/envs/cambridge/lib/python3.12/site-packages/cambridge/main.py", line 5, in main
    args.func(args)
  File "/home/USERNAME/.pyenv/versions/3.12.2/envs/cambridge/lib/python3.12/site-packages/cambridge/args.py", line 281, in search_word
    cambridge.search_cambridge(input_word, is_fresh, is_ch, no_suggestions, None)
  File "/home/USERNAME/.pyenv/versions/3.12.2/envs/cambridge/lib/python3.12/site-packages/cambridge/dicts/cambridge.py", line 38, in search_cambridge
    cached = dicts.cache_run(input_word, req_url)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/USERNAME/.pyenv/versions/3.12.2/envs/cambridge/lib/python3.12/site-packages/cambridge/dicts/dicts.py", line 58, in cache_run
    data = get_cache(input_word, req_url)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/USERNAME/.pyenv/versions/3.12.2/envs/cambridge/lib/python3.12/site-packages/cambridge/cache.py", line 45, in get_cache
    with con:
sqlite3.ProgrammingError: Cannot operate on a closed database.

Cannot import fake user agent

[XXX@XXX Downloads]$ camb hello
Traceback (most recent call last):
  File "/home/XXX/.local/bin/camb", line 5, in <module>
    from cambridge.main import main
  File "/home/XXX/.local/lib/python3.10/site-packages/cambridge/main.py", line 16, in <module>
    from .args import parse_args
  File "/home/XXX/.local/lib/python3.10/site-packages/cambridge/args.py", line 15, in <module>
    from .dicts import webster, cambridge
  File "/home/XXX/.local/lib/python3.10/site-packages/cambridge/dicts/webster.py", line 12, in <module>
    from ..dicts import dict
  File "/home/XXX/.local/lib/python3.10/site-packages/cambridge/dicts/dict.py", line 6, in <module>
    from fake_user_agent import user_agent
ImportError: cannot import name 'user_agent' from 'fake_user_agent' (/home/XXX/.local/lib/python3.10/site-packages/fake_user_agent/__init__.py)

Doesn't work

I have latest pypi version 3.5.9:

❯ camb remit
2022-12-12 22:45:49 ERROR user_agent.py[70] Nothing parsed out
2022-12-12 22:45:49 ERROR base_events.py[1747] Task exception was never retrieved
future: <Task finished name='Task-1' coro=<main() done, defined at /home/USERNAME/.local/lib/python3.10/site-packages/fake_user_agent/user_agent.py:186> exception=SystemExit()>
Traceback (most recent call last):
  File "/home/USERNAME/.local/lib/python3.10/site-packages/cambridge/main.py", line 17, in main
    args.func(args, con, cur)
  File "/home/USERNAME/.local/lib/python3.10/site-packages/cambridge/args.py", line 243, in search_word
    cambridge.search_cambridge(con, cur, input_word, is_fresh, is_ch)
  File "/home/USERNAME/.local/lib/python3.10/site-packages/cambridge/dicts/cambridge.py", line 40, in search_cambridge
    fresh_run(con, cur, req_url, input_word, is_ch)
  File "/home/USERNAME/.local/lib/python3.10/site-packages/cambridge/dicts/cambridge.py", line 75, in fresh_run
    result = fetch_cambridge(req_url, input_word, is_ch)
  File "/home/USERNAME/.local/lib/python3.10/site-packages/cambridge/dicts/cambridge.py", line 50, in fetch_cambridge
    res = dict.fetch(req_url, session)
  File "/home/USERNAME/.local/lib/python3.10/site-packages/cambridge/dicts/dict.py", line 20, in fetch
    ua = user_agent()
  File "/home/USERNAME/.local/lib/python3.10/site-packages/fake_user_agent/user_agent.py", line 250, in user_agent
    return asyncio.run(main(browser, use_cache))
  File "/usr/lib/python3.10/asyncio/runners.py", line 47, in run
    _cancel_all_tasks(loop)
  File "/usr/lib/python3.10/asyncio/runners.py", line 63, in _cancel_all_tasks
    loop.run_until_complete(tasks.gather(*to_cancel, return_exceptions=True))
  File "/usr/lib/python3.10/asyncio/base_events.py", line 636, in run_until_complete
    self.run_forever()
  File "/usr/lib/python3.10/asyncio/base_events.py", line 603, in run_forever
    self._run_once()
  File "/usr/lib/python3.10/asyncio/base_events.py", line 1899, in _run_once
    handle._run()
  File "/usr/lib/python3.10/asyncio/events.py", line 80, in _run
    self._context.run(self._callback, *self._args)
  File "/home/USERNAME/.local/lib/python3.10/site-packages/fake_user_agent/user_agent.py", line 211, in main
    await asyncio.gather(*tasks)
  File "/usr/lib/python3.10/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/usr/lib/python3.10/asyncio/base_events.py", line 636, in run_until_complete
    self.run_forever()
  File "/usr/lib/python3.10/asyncio/base_events.py", line 603, in run_forever
    self._run_once()
  File "/usr/lib/python3.10/asyncio/base_events.py", line 1899, in _run_once
    handle._run()
  File "/usr/lib/python3.10/asyncio/events.py", line 80, in _run
    self._context.run(self._callback, *self._args)
  File "/home/USERNAME/.local/lib/python3.10/site-packages/fake_user_agent/user_agent.py", line 103, in write_to_dict
    versions = await parse(browser, session)
  File "/home/USERNAME/.local/lib/python3.10/site-packages/fake_user_agent/user_agent.py", line 92, in parse
    attempt = call_on_error(ValueError("Nothing parsed out"), url, attempt, OP[1])
  File "/home/USERNAME/.local/lib/python3.10/site-packages/fake_user_agent/user_agent.py", line 71, in call_on_error
    sys.exit()
SystemExit

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.