你需要的最后一个字典框架。(?)
zdict的Python项目详细描述
zdict是一个cli字典框架,主要关注任何类型的在线字典。 这个项目最初是由https://github.com/chenpc/ydict派生的,它是yahoo!的一个cli工具。在线词典。 在对原始项目进行了大量重构之后,包括:
- 从python 2更改为python 3 <> LI>专注于任何类型的在线词典的灵活框架,而不仅仅是CLI查询雅虎的工具!在线词典。
- 基于开源项目框架。
所以,我们决定创建一个新项目。
目录
Installation
来自PyPI:
pip install zdict
来自GitHub:
pip install git+https://github.com/zdict/zdict.git
来自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
如何运行zdict docker图像
# 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.
Development & Contributing
Testing
在开发过程中,您可以将我们的项目安装为editable。 如果使用virtualenv,您可能需要为zdict创建一个新的环境:
$ git clone https://github.com/zdict/zdict.git $ cd zdict $ pip install -e .
一旦你用上面的命令安装了它, 修改后执行zdict。 不用再安装了。
我们使用py.test:
$ pip install pytest pytest-cov coverage $ python setup.py test
或:
$ py.test
在运行测试之后,我们将得到一个HTML格式的覆盖率报告。 我们可以浏览它:
$ cd htmlcov $ python -m http.server
另外,在setup.cfg中有一些py.test的配置。 如果你需要的话就换。
Bug Report
请随时向https://github.com/zdict/zdict/issues发送错误报告。 请附上错误信息并描述如何重现错误。 公关也是受欢迎的。
在发送错误报告之前,请使用-d/--disable-db-cache选项进行查询。 有时我们会为字典修改数据库中的数据模式, 但zdict的默认字典查询使用数据库中的缓存,该缓存可能存储在旧模式中。 这可能会导致显示结果时出错。 只需使用-d/--disable-db-cache更新数据库中的缓存。