xueyuanl / cambrinary Goto Github PK
View Code? Open in Web Editor NEWA linux terminal online dictionary, based on cambridge dictionary: https://dictionary.cambridge.org
License: GNU General Public License v3.0
A linux terminal online dictionary, based on cambridge dictionary: https://dictionary.cambridge.org
License: GNU General Public License v3.0
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?
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
I typed line like your example but terminal doesn't show definitions.
https://imgur.com/gallery/V7qZG2C
Though documented in --help
, the argument --synoym
is not recognized, whereas -s
does not change the output.
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'
I hope you could add Turkish Lang.
Thanks
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?..
Traceback (most recent call last):
File "cambrinary.py", line 6, in
from bs4 import BeautifulSoup
ImportError: No module named bs4
`
❯ cambrinary -w hello -t chinese
exclamation, noun UK /heˈləʊ/ US /heˈloʊ/
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.