Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
mozillazg committed May 21, 2013
2 parents 06d8a81 + 6a01e35 commit c60072f
Show file tree
Hide file tree
Showing 8 changed files with 125 additions and 7 deletions.
2 changes: 2 additions & 0 deletions .gitignore
@@ -1,3 +1,5 @@
*.un~
*.swp
*.pyc
dist
pyshanb.egg-info
4 changes: 4 additions & 0 deletions ChangeLog.md
@@ -1,5 +1,9 @@
# PyShanb changelog

## 2013-05-21 0.5.2

* 发布到 PyPI

## 2013-03-16 0.5.1

* 新增加几个命令行参数([-i | -I] [-a | -A]
Expand Down
1 change: 1 addition & 0 deletions MANIFEST.in
@@ -0,0 +1 @@
include README.md LICENSE.txt ChangeLog.md requirements.txt pyshanb/pyshanb.conf
10 changes: 6 additions & 4 deletions README.md
@@ -1,6 +1,7 @@
# PyShanb:命令行下的扇贝词典

基于 [扇贝网 API v0.8](http://www.shanbay.com/support/dev/api.html "扇贝网 API v0.8") 开发的一个命令行下的查词工具。支持将生词添加到扇贝网的个人词库中。
基于 [扇贝网 API v0.8](http://www.shanbay.com/support/dev/api.html "扇贝网 API v0.8") 开发的一个命令行下的查词工具。
支持将生词添加到扇贝网的个人词库中。

## 功能

Expand All @@ -25,14 +26,15 @@

## 安装使用

1. 安装依赖模块:`pip install -r requirements.txt`
1. `pip install pyshanb``git clone https://github.com/mozillazg/PyShanb`
2. 配置用户名及密码(通过配置文件(pyshanb.conf)或命令行参数(-u -p));
3. 命令行下执行:`python pyshanb.py`(Tips:使用过程中输入 `q` 即可退出程序)。
4.`shanbay -u username -p password`

### 命令行参数

>python pyshanb.py --help
Usage: pyshanb.py [-s SETTINGS] [-u USERNAME] [-p PASSWORD]
>shanbay --hlep
Usage: shanbay-script.py [-s SETTINGS] [-u USERNAME] [-p PASSWORD]
[-e | -E] [-i | -I] [-a | -A] [--version]

Options:
Expand Down
40 changes: 38 additions & 2 deletions pyshanb/__init__.py
Expand Up @@ -5,5 +5,41 @@
PyShanb - 命令行下的扇贝词典
"""

__version_info__ = (0, 5, 1)
__version__ = filter(lambda n: isinstance(n, int), __version_info__)

__title__ = 'pyshanb'
__version_info__ = (0, 5, 2, 'final', 0)
__author__ = 'mozillazg'
__license__ = 'MIT'
__copyright__ = 'Copyright 2013 mozillazg'


# modified from django(https://github.com/django/django/)
def get_version(version=None):
"Returns a PEP 386-compliant version number from VERSION."
if version is None:
version = __version_info__
else:
assert len(version) == 5
assert version[3] in ('alpha', 'beta', 'rc', 'final')

# Now build the two parts of the version number:
# main = X.Y[.Z]
# sub = .devN - for pre-alpha releases
# | {a|b|c}N - for alpha, beta and rc releases

parts = 2 if version[2] == 0 else 3
main = '.'.join(str(x) for x in version[:parts])

sub = ''
if version[3] == 'alpha' and version[4] == 0:
git_changeset = get_git_changeset()
if git_changeset:
sub = '.dev%s' % git_changeset

elif version[3] != 'final':
mapping = {'alpha': 'a', 'beta': 'b', 'rc': 'c'}
sub = mapping[version[3]] + str(version[4])

return str(main + sub)

__version__ = get_version(__version_info__)
10 changes: 10 additions & 0 deletions pyshanb/__main__.py
@@ -0,0 +1,10 @@
#!/usr/bin/env python
"""The main entry point. Invoke as `shanbay' or `python -m pyshanb'.
"""
import sys
from .pyshanb import main


if __name__ == '__main__':
sys.exit(main())
3 changes: 2 additions & 1 deletion pyshanb/conf.py
Expand Up @@ -74,7 +74,8 @@ def get_settings(self, has_username=False, has_password=False):
and (self.password or has_password)):
a = u'Please configure your username and/or password,\n'
b = 'or command line option, like below:\n'
b += ' pyshanb.py -u root -p abc'
b += ' shanbay -u username -p password\n'
b += ' python pyshanb.py -u username -p password\n'
sys.exit(u'%sby editor config file:\n %s\n%s'
% (a, os.path.realpath(CONFIGFILE), b))

Expand Down
62 changes: 62 additions & 0 deletions setup.py
@@ -0,0 +1,62 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import os
import sys

import pyshanb

try:
from setuptools import setup
except ImportError:
from distutils.core import setup

if sys.argv[-1] == 'publish':
os.system('python setup.py sdist upload')
sys.exit()

requirements = [
'requests>=1.1.0'
]

packages = [
'pyshanb',
]

def long_description():
md =open('README.md').read() + '\n\n' + open('ChangeLog.md').read()
return md

setup(
name='pyshanb',
version=pyshanb.__version__,
description=pyshanb.__doc__.strip(),
long_description=long_description(),
url='https://github.com/mozillazg/PyShanb',
download_url='https://github.com/mozillazg/PyShanb',
author=pyshanb.__author__,
author_email='mozillazg101@gmail.com',
license=pyshanb.__license__,
packages=packages,
package_data={'': ['LICENSE.txt'], 'pyshanb': ['*.conf']},
package_dir={'pyshanb': 'pyshanb'},
include_package_data=True,
install_requires=requirements,
# setup_requires=['sphinx'],
zip_safe=False,
entry_points={
'console_scripts': [
'shanbay = pyshanb.__main__:main',
],
},
classifiers=[
'Development Status :: 5 - Production/Stable',
'Programming Language :: Python',
'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7',
'Environment :: Console',
'Intended Audience :: Developers',
'Intended Audience :: Education',
'License :: OSI Approved :: MIT License',
],
)

0 comments on commit c60072f

Please sign in to comment.