The last dictionary framework you need. (?)
Project description
zdict is a CLI dictionary framework mainly focus on any kind of online dictionary. This project originally forked from https://github.com/chenpc/ydict, which is a CLI tool for the Yahoo! online dictionary. After heavily refactoring the original project including:
Change from Python 2 to Python 3
Focus on being a flexible framework for any kind online dicitionaries, not only just a CLI tool for querying Yahoo! online dictionary.
Based on an open source project skeleton.
So, we decided to create a new project.
Installation
from PyPI :
pip install zdict
from GitHub :
pip install git+https://github.com/zdict/zdict.git
from Docker Hub :
# Pull the image of latest commit of master branch from Docker Hub
docker pull zdict/zdict
# Pull the image of latest release from Docker Hub
docker pull zdict/zdict:release
# Pull the image of specific release version from Docker Hub
docker pull zdict/zdict:${version}
docker pull zdict/zdict:v0.10.0
How to run the zdict docker image
# Run interactive mode
docker run -it --rm zdict/zdict # latest commit
docker run -it --rm zdict/zdict:release # latest release
docker run -it --rm zdict/zdict:v0.10.0 # use zdict v0.10.0
docker run -it --rm zdict/zdict:$tag # with specific tag
# Run normal mode
docker run -it --rm zdict/zdict apple bird # latest commit
docker run -it --rm zdict/zdict:release apple bird # latest release
docker run -it --rm zdict/zdict:v0.10.0 apple bird # use zdict v0.10.0
docker run -it --rm zdict/zdict:$tag apple bird # with specific tag
# You can also add the options while using docker run either interactive mode or normal mode
docker run -it --rm zdict/zdict:v0.10.0 -dt moe # use moe dict in interactive mode
docker run -it --rm zdict/zdict:v0.10.0 -dt moe 哈 # use moe dict in normal mode
Usage
usage: zdict [-h] [-v] [-d] [-t QUERY_TIMEOUT] [-j [JOBS]] [-sp] [-su] [-dt itaigi,moe,moe-taiwanese,spanish,oxford,jisho,yahoo,wiktionary,urban,yandex,all] [-ld] [-V] [-c] [--dump [PATTERN]] [-D] [word [word ...]] positional arguments: word Words for searching its translation optional arguments: -h, --help show this help message and exit -v, --version show program's version number and exit -d, --disable-db-cache Temporarily not using the result from db cache. (still save the result into db) -t QUERY_TIMEOUT, --query-timeout QUERY_TIMEOUT Set timeout for every query. default is 5 seconds. -j [JOBS], --jobs [JOBS] Allow N jobs at once. Do not pass any argument to use the number of CPUs in the system. -sp, --show-provider Show the dictionary provider of the queried word -su, --show-url Show the url of the queried word -dt itaigi,moe,moe-taiwanese,spanish,oxford,jisho,yahoo,wiktionary,urban,yandex,all, --dict itaigi,moe,moe-taiwanese,spanish,oxford,jisho,yahoo,wiktionary,urban,yandex,all Must be seperated by comma and no spaces after each comma. Choose the dictionary you want. (default: yahoo) Use 'all' for qureying all dictionaries. If 'all' or more than 1 dictionaries been chosen, --show- provider will be set to True in order to provide more understandable output. -ld, --list-dicts Show currently supported dictionaries. -V, --verbose Show more information for the queried word. (If the chosen dictionary have implemented verbose related functions) -c, --force-color Force color printing (zdict automatically disable color printing when output is not a tty, use this option to force color printing) --dump [PATTERN] Dump the querying history, can be filtered with regex -D, --debug Print raw html prettified by BeautifulSoup for debugging.
Screenshots
Yahoo Dictionary
Normal Mode
zdict hello
Interactive Mode
zdict
Moe Dictionary 萌典
Urban Dictionary
SpanishDict
Jisho Japanese Dictionary
Yandex Translate
Oxford Dictionary
To use this source, you should first apply an API key and place it under ~/.zdict/oxford.key in the format:
app_id, app_key
Wiktionary
iTaigi-愛台語
Development & Contributing
Testing
During development, you can install our project as editable. If you use virtualenv, you may want to create a new enviroment for zdict:
$ git clone https://github.com/zdict/zdict.git $ cd zdict $ pip install -e .
Once you installed it with the command above, just execute zdict after modification. Don’t need to install it again.
We use py.test:
$ pip install pytest pytest-cov coverage $ python setup.py test
or:
$ py.test
After runing testing, we will get a coverage report in html. We can browse around it:
$ cd htmlcov $ python -m http.server
Also, there is some configs for py.test in setup.cfg. Change it if you need.
Debugging
py.test can prompt pdb shell when your test case failed:
$ python setup.py test -a "--pdb"
or:
$ py.test --pdb
Bug Report
Feel free to send a bug report to https://github.com/zdict/zdict/issues. Please attach the error message and describe how to reproduce the bug. PR is also welcome.
Please use the -d/--disable-db-cache option to query before sending the bug report. Sometimes we modify the data schema in database for a dictionary, but the default dictionary query of zdict uses the cache in the database which may be stored within an old schema. This might cause an error while showing the result. Just use the -d/--disable-db-cache to update the cache in database.
Stargazers over time
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file zdict-3.2.0.tar.gz
.
File metadata
- Download URL: zdict-3.2.0.tar.gz
- Upload date:
- Size: 33.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/28.8.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.5.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a3063171267e16547fd8b2c5b20c9556d9ba1b9d32a0282d6d015cc475600b02 |
|
MD5 | b1e71fc9fc8ccb206605dc1aaa218b8e |
|
BLAKE2b-256 | 3cd4228b1349d36a33bee2cfb919a2ecd33d528e44e121b92643bb15b3bb05b0 |
File details
Details for the file zdict-3.2.0-py35+-none-any.whl
.
File metadata
- Download URL: zdict-3.2.0-py35+-none-any.whl
- Upload date:
- Size: 56.2 kB
- Tags: Python 3.5+
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/28.8.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.5.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 110d41def1ee9a6d4d45a8e84ef4e1231afbb9bb386f7514e42dc804bd1b1453 |
|
MD5 | 058360a0f89658c212ac023a4b25f109 |
|
BLAKE2b-256 | c41dd2f072a16c42db846f83d5434c23bfb9be02f5fab77a9b8c0d959c379c0e |