Code Monkey home page Code Monkey logo

cambrinary's People

Contributors

andydecleyre avatar cookieppp avatar j3soon avatar ronymacfly avatar satotake avatar tjni avatar xueyuanl avatar zaibugemi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

cambrinary's Issues

Fails to suggest definitions everytime

Hi, thanks for maintaining this project. I use it almost everyday!

The application was working fine until yesterday. I keep receiving a response: NONE whenever I attempt to retrieve a definition.

~
$ cambrinary --word gratitude
None

~
$

Contents of a fresh dict.log.

2020-07-24 09:25:45,383 - /usr/local/Cellar/[email protected]/3.8.4/Frameworks/Python.framework/Versions/3.8/lib/python3.8/asyncio/selector_events.py[line:59] - DEBUG: Using selector: KqueueSelector
2020-07-24 09:25:45,383 - /Users/xxx/Library/Python/3.8/lib/python/site-packages/cambrinary/cambrinary.py[line:322] - INFO: start to work...
2020-07-24 09:25:45,384 - /Users/xxx/Library/Python/3.8/lib/python/site-packages/cambrinary/cambrinary.py[line:293] - INFO: begin to retrieve word: [gratitude] in english
2020-07-24 09:25:46,415 - /usr/local/Cellar/[email protected]/3.8.4/Frameworks/Python.framework/Versions/3.8/lib/python3.8/asyncio/base_events.py[line:1707] - ERROR: Task exception was never retrieved
future: <Task finished name='Task-2' coro=<look_up() done, defined at /Users/xxx/Library/Python/3.8/lib/python/site-packages/cambrinary/cambrinary.py:292> exception=ServerDisconnectedError()>
Traceback (most recent call last):
  File "/Users/xxx/Library/Python/3.8/lib/python/site-packages/cambrinary/cambrinary.py", line 294, in look_up
    html = await load(word, translation[trans])
  File "/Users/xxx/Library/Python/3.8/lib/python/site-packages/cambrinary/cambrinary.py", line 37, in load
    async with aiohttp.request('GET', url) as resp:
  File "/usr/local/lib/python3.8/site-packages/aiohttp/client.py", line 1051, in __aenter__
    self._resp = await self._coro
  File "/usr/local/lib/python3.8/site-packages/aiohttp/client.py", line 504, in _request
    await resp.start(conn)
  File "/usr/local/lib/python3.8/site-packages/aiohttp/client_reqrep.py", line 847, in start
    message, payload = await self._protocol.read()  # type: ignore  # noqa
  File "/usr/local/lib/python3.8/site-packages/aiohttp/streams.py", line 591, in read
    await self._waiter
aiohttp.client_exceptions.ServerDisconnectedError

When I visit https://dictionary.cambridge.org/ on a browser, I receive a Secure Connection Failed error. I checked DNS resolution and it seems to be resolving fine. Doesn't seem to be Cambrinary's issue.. but why can't I access Cambridge dictionary though?

Error when searching for a definition

Running cambrinary -w <word> returns:

  File "/home/incognitux/.local/bin/cambrinary", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/home/incognitux/.local/lib/python3.11/site-packages/cambrinary/cambrinary.py", line 135, in main
    loop.run_until_complete(asyncio.wait(tasks))
  File "/usr/lib64/python3.11/asyncio/base_events.py", line 653, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.11/asyncio/tasks.py", line 415, in wait
    raise TypeError("Passing coroutines is forbidden, use tasks explicitly.")
TypeError: Passing coroutines is forbidden, use tasks explicitly.
sys:1: RuntimeWarning: coroutine 'look_up' was never awaited

on Fedora Linux 37

Fails on `cambrinary -w 'black'`

Found a word that fails to run on my system while playing around with your utility.
cambrinary -w 'black' and cambrinary -w black fail to run.

2021-02-17 06:49:44,086 - /home/cookie/anaconda3/lib/python3.7/asyncio/selector_events.py[line:53] - DEBUG: Using selector: EpollSelector
2021-02-17 06:49:44,087 - /home/cookie/anaconda3/lib/python3.7/site-packages/cambrinary/cambrinary.py[line:130] - INFO: start to work...
2021-02-17 06:49:44,087 - /home/cookie/anaconda3/lib/python3.7/site-packages/cambrinary/cambrinary.py[line:97] - INFO: begin to retrieve word: [black] in english
2021-02-17 06:49:44,494 - /home/cookie/anaconda3/lib/python3.7/site-packages/cambrinary/cambrinary.py[line:35] - INFO: successfully execute: curl -k -X GET https://dictionary.cambridge.org/dictionary/english/black
2021-02-17 06:49:44,685 - /home/cookie/anaconda3/lib/python3.7/site-packages/cambrinary/cambrinary.py[line:89] - INFO: get a dictionary by pr dictionary
2021-02-17 06:49:44,693 - /home/cookie/anaconda3/lib/python3.7/site-packages/cambrinary/cambrinary.py[line:106] - INFO: the number of part_speeh is 3
2021-02-17 06:49:44,693 - /home/cookie/anaconda3/lib/python3.7/site-packages/cambrinary/type.py[line:273] - INFO: parse the 0th part_speech
2021-02-17 06:49:44,693 - /home/cookie/anaconda3/lib/python3.7/site-packages/cambrinary/type.py[line:99] - INFO: the pronunciation is: adjective �[0;34;49mUK�[0m �[0;39;49m/blæk/�[0m �[0;34;49mUS�[0m �[0;39;49m/blæk/�[0m 

2021-02-17 06:49:44,701 - /home/cookie/anaconda3/lib/python3.7/site-packages/cambrinary/type.py[line:247] - INFO: the number of block is 4
2021-02-17 06:49:44,701 - /home/cookie/anaconda3/lib/python3.7/site-packages/cambrinary/type.py[line:249] - INFO: parse the 0th block
2021-02-17 06:49:44,701 - /home/cookie/anaconda3/lib/python3.7/site-packages/cambrinary/type.py[line:168] - INFO: fetch the dsense_h
2021-02-17 06:49:44,702 - /home/cookie/anaconda3/lib/python3.7/site-packages/cambrinary/type.py[line:181] - INFO: the  title of block is �[0;39;49m[COLOUR]�[0m adjective

2021-02-17 06:49:44,702 - /home/cookie/anaconda3/lib/python3.7/site-packages/cambrinary/type.py[line:186] - INFO: the number of pad_indent is 1
2021-02-17 06:49:44,703 - /home/cookie/anaconda3/lib/python3.7/site-packages/cambrinary/type.py[line:249] - INFO: parse the 1th block
2021-02-17 06:49:44,703 - /home/cookie/anaconda3/lib/python3.7/site-packages/cambrinary/type.py[line:168] - INFO: fetch the dsense_h
2021-02-17 06:49:44,704 - /home/cookie/anaconda3/lib/python3.7/site-packages/cambrinary/type.py[line:181] - INFO: the  title of block is �[0;39;49m[PEOPLE]�[0m adjective

2021-02-17 06:49:44,705 - /home/cookie/anaconda3/lib/python3.7/site-packages/cambrinary/type.py[line:186] - INFO: the number of pad_indent is 1
2021-02-17 06:49:44,705 - /home/cookie/anaconda3/lib/python3.7/site-packages/cambrinary/type.py[line:249] - INFO: parse the 2th block
2021-02-17 06:49:44,705 - /home/cookie/anaconda3/lib/python3.7/site-packages/cambrinary/type.py[line:168] - INFO: fetch the dsense_h
2021-02-17 06:49:44,706 - /home/cookie/anaconda3/lib/python3.7/site-packages/cambrinary/type.py[line:181] - INFO: the  title of block is �[0;39;49m[COFFEE/TEA]�[0m adjective

2021-02-17 06:49:44,707 - /home/cookie/anaconda3/lib/python3.7/site-packages/cambrinary/type.py[line:186] - INFO: the number of pad_indent is 1
2021-02-17 06:49:44,707 - /home/cookie/anaconda3/lib/python3.7/site-packages/cambrinary/type.py[line:249] - INFO: parse the 3th block
2021-02-17 06:49:44,707 - /home/cookie/anaconda3/lib/python3.7/site-packages/cambrinary/type.py[line:168] - INFO: fetch the dsense_h
2021-02-17 06:49:44,708 - /home/cookie/anaconda3/lib/python3.7/site-packages/cambrinary/type.py[line:181] - INFO: the  title of block is �[0;39;49m[BAD]�[0m adjective

2021-02-17 06:49:44,708 - /home/cookie/anaconda3/lib/python3.7/site-packages/cambrinary/type.py[line:186] - INFO: the number of pad_indent is 2
2021-02-17 06:49:44,709 - /home/cookie/anaconda3/lib/python3.7/site-packages/cambrinary/type.py[line:273] - INFO: parse the 1th part_speech
2021-02-17 06:49:44,710 - /home/cookie/anaconda3/lib/python3.7/site-packages/cambrinary/type.py[line:99] - INFO: the pronunciation is: noun �[0;34;49mUK�[0m �[0;39;49m/blæk/�[0m �[0;34;49mUS�[0m �[0;39;49m/blæk/�[0m 

2021-02-17 06:49:44,713 - /home/cookie/anaconda3/lib/python3.7/site-packages/cambrinary/type.py[line:247] - INFO: the number of block is 2
2021-02-17 06:49:44,713 - /home/cookie/anaconda3/lib/python3.7/site-packages/cambrinary/type.py[line:249] - INFO: parse the 0th block
2021-02-17 06:49:44,713 - /home/cookie/anaconda3/lib/python3.7/site-packages/cambrinary/type.py[line:168] - INFO: fetch the dsense_h
2021-02-17 06:49:44,715 - /home/cookie/anaconda3/lib/python3.7/site-packages/cambrinary/type.py[line:181] - INFO: the  title of block is �[0;39;49m[COLOUR]�[0m noun

2021-02-17 06:49:44,715 - /home/cookie/anaconda3/lib/python3.7/site-packages/cambrinary/type.py[line:186] - INFO: the number of pad_indent is 2
2021-02-17 06:49:44,716 - /home/cookie/anaconda3/lib/python3.7/site-packages/cambrinary/type.py[line:249] - INFO: parse the 1th block
2021-02-17 06:49:44,716 - /home/cookie/anaconda3/lib/python3.7/site-packages/cambrinary/type.py[line:168] - INFO: fetch the dsense_h
2021-02-17 06:49:44,717 - /home/cookie/anaconda3/lib/python3.7/site-packages/cambrinary/type.py[line:181] - INFO: the  title of block is �[0;39;49m[PEOPLE]�[0m noun

2021-02-17 06:49:44,717 - /home/cookie/anaconda3/lib/python3.7/site-packages/cambrinary/type.py[line:186] - INFO: the number of pad_indent is 1
2021-02-17 06:49:44,718 - /home/cookie/anaconda3/lib/python3.7/asyncio/base_events.py[line:1604] - ERROR: Task exception was never retrieved
future: <Task finished coro=<look_up() done, defined at /home/cookie/anaconda3/lib/python3.7/site-packages/cambrinary/cambrinary.py:96> exception=AttributeError("'NoneType' object has no attribute 'find'")>
Traceback (most recent call last):
  File "/home/cookie/anaconda3/lib/python3.7/site-packages/cambrinary/cambrinary.py", line 110, in look_up
    word_obj.parse_part_speeches(part_speeches)
  File "/home/cookie/anaconda3/lib/python3.7/site-packages/cambrinary/type.py", line 276, in parse_part_speeches
    part_speech.parse_sense_blocks(p)
  File "/home/cookie/anaconda3/lib/python3.7/site-packages/cambrinary/type.py", line 252, in parse_sense_blocks
    sense_block.parse_pad_indents(block)
  File "/home/cookie/anaconda3/lib/python3.7/site-packages/cambrinary/type.py", line 195, in parse_pad_indents
    pad_indent.parse_trans(def_body)
  File "/home/cookie/anaconda3/lib/python3.7/site-packages/cambrinary/type.py", line 124, in parse_trans
    trans = body.find('span', attrs={'class': 'trans dtrans dtrans-se'}, recursive=False)
AttributeError: 'NoneType' object has no attribute 'find'

Please support Python3

I came across your post on Reddit and this is extremely useful while teaching my kid. I was too reluctant to start a new project myself but I've always missed this!

I would be great if you could add Python3 support (please refer to googler or Buku for HTTP query-response examples.

Getting empty string using -t option

For example: cambrinary -w dog -t russian prints just one empty string, but cambrinary -w dog -t japanese works fine. It would be nice to get some error message instead of the empty string in this case. Is it possible that there is no Russian explanation for most words? Russian is displayed properly in other terminal applications, so this should not be a problem with that I guess?..

Error

Traceback (most recent call last):
File "cambrinary.py", line 6, in
from bs4 import BeautifulSoup
ImportError: No module named bs4

--translation chinese didn't work

`
❯ cambrinary -w hello -t chinese
exclamation, noun UK /heˈləʊ/ US /heˈloʊ/

  • used when meeting or greeting someone
    • Hello, Paul. I haven't seen you for ages.
    • I know her vaguely - we've exchanged hellos a few times.
    • I just thought I'd call by and say hello.
    • And a big hello (= welcome) to all the parents who've come to see the show.
  • something that is said at the beginning of a phone conversation
    • "Hello, I'd like some information about flights to the US, please."
  • something that is said to attract someone's attention
    • The front door was open so she walked inside and called out, "Hello! Is there anybody in?"
  • said to someone who has just said or done something stupid, especially something that shows they are not noticing what is happening
    • She asked me if I'd just arrived and I was like "Hello, I've been here for an hour."
  • an expression of surprise
    • Hello, this is very strange - I know that man.
      `

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.