├── .gitignore
├── README.md
├── example.png
├── setup.py
└── termdic
├── __init__.py
└── termdic.py
/.gitignore:
--------------------------------------------------------------------------------
1 | .idea
2 |
3 | # https://github.com/github/gitignore/blob/master/Python.gitignore
4 | *.py[cod]
5 |
6 | # C extensions
7 | *.so
8 |
9 | # Packages
10 | *.egg
11 | *.egg-info
12 | dist
13 | build
14 | eggs
15 | parts
16 | bin
17 | var
18 | sdist
19 | develop-eggs
20 | .installed.cfg
21 | lib
22 | lib64
23 | __pycache__
24 |
25 | # Installer logs
26 | pip-log.txt
27 |
28 | # Unit test / coverage reports
29 | .coverage
30 | .tox
31 | nosetests.xml
32 |
33 | # Translations
34 | *.mo
35 |
36 | # Mr Developer
37 | .mr.developer.cfg
38 | .project
39 | .pydevproject
40 |
41 | mcms/db.sqlite3
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # termdic
2 |
3 |
4 |
5 | 基于python的命令行查词工具, 使用有道api。
6 |
7 | ## Installation 安装
8 |
9 | >sudo pip install termdic
10 |
11 | ## Usage 使用
12 |
13 | >tdic word
14 |
15 | >[wɜːd]
16 |
17 | >n. [语] 单词;话语;消息;诺言;命令
18 |
19 | >vt. 用言辞表达
20 |
21 | >n. (Word)人名;(英)沃德
22 |
23 | 查询单词并发音
24 |
25 | >tdic word -p
26 |
27 | 查询版本号
28 |
29 | >tdic -v
30 |
31 | 查看帮助
32 | >tdic -h
33 |
34 |
--------------------------------------------------------------------------------
/example.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hzwer/termdic/1ddbec8235afd0afa6c2ecba3b15968373911cea/example.png
--------------------------------------------------------------------------------
/setup.py:
--------------------------------------------------------------------------------
1 | # coding: utf-8
2 |
3 | from setuptools import setup, find_packages
4 |
5 | version = '0.1.3'
6 |
7 | setup(
8 | name = 'termdic',
9 | version = version,
10 | author = 'hzwer',
11 | author_mail = '598460606@163.com',
12 | url = 'https://github.com/hzwer/termdic',
13 | description = 'Dictionary in your terminal',
14 | keywords = 'dictionary, terminal',
15 | packages = find_packages(),
16 | include_package_data = True,
17 | zip_safe = False,
18 | install_requires = [
19 | 'requests',
20 | 'termcolor',
21 | ],
22 | entry_points = {
23 | 'console_scripts': [
24 | 'tdic = termdic.termdic:main'
25 | ]
26 | },
27 | )
28 |
--------------------------------------------------------------------------------
/termdic/__init__.py:
--------------------------------------------------------------------------------
1 | import termdic
2 | __version__ = '0.1.3'
3 |
--------------------------------------------------------------------------------
/termdic/termdic.py:
--------------------------------------------------------------------------------
1 | # coding: utf-8
2 |
3 | import os
4 | import re
5 | import sys
6 | import argparse
7 | import requests
8 | from termcolor import colored as cl
9 |
10 | # from termdic import __version__
11 | __version__ = '0.1.3'
12 |
13 | def look_up(word):
14 | url = 'http://dict.youdao.com/search?q='
15 | r = requests.get(url + word)
16 | content = r.text
17 |
18 | try:
19 | ps = re.findall(re.compile('"phonetic">(.*?)'), content)
20 | pattern = re.compile('"trans-container">(.*?)', re.S)
21 | tmp = re.findall(pattern, content)
22 | mean = re.findall(re.compile('