Skip to content

Commit 1713c37

Browse files
authored
Better Topic Message Support. (#3)
- `uids` is NOT required parameter for `send_message` now. - `flake8` and its extensions compatibility. - `setuptools_scm` for version. - `pipenv` for dependencies management.
1 parent a4ba4e5 commit 1713c37

19 files changed

+139
-78
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,4 +129,6 @@ dmypy.json
129129
.pyre/
130130

131131
# Custom
132+
.vscode
133+
Pipfile.lock
132134
config.py

MANIFEST.in

Lines changed: 0 additions & 3 deletions
This file was deleted.

Makefile

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
.PHONY: clean install dev lint pycodestyle pyflakes pylint test dist upload
1+
.PHONY: clean install lint flake8 pylint test dist upload
2+
3+
PIPENV := $(shell command -v pipenv > /dev/null && echo env)
4+
PIPRUN := $(shell command -v pipenv > /dev/null && echo pipenv run)
25

36
clean:
47
find . -name '*.pyc' -print0 | xargs -0 rm -f
@@ -9,21 +12,15 @@ clean:
912
-rm -rf .tox .coverage
1013

1114
install:
12-
pip install .
13-
14-
dev:
15-
pip install .[dev]
16-
17-
lint: pycodestyle pyflakes pylint
15+
pip$(PIPENV) install .
1816

19-
pycodestyle:
20-
-pycodestyle setup.py wxpusher
17+
lint: flake8 pylint
2118

22-
pyflakes:
23-
-pyflakes setup.py wxpusher
19+
flake8:
20+
${PIPRUN} flake8 setup.py wxpusher
2421

2522
pylint:
26-
-pylint setup.py wxpusher
23+
${PIPRUN} pylint setup.py wxpusher
2724

2825
test:
2926
tox

Pipfile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
[[source]]
2+
name = "pypi"
3+
url = "https://pypi.org/simple"
4+
verify_ssl = true
5+
6+
[dev-packages]
7+
flake8 = "*"
8+
flake8-commas = "*"
9+
flake8-docstrings = "*"
10+
flake8-import-order = "*"
11+
pep8-naming = "*"
12+
pylint = "*"
13+
14+
[packages]
15+
wxpusher = {editable = true,path = "."}
16+
17+
[requires]
18+
python_version = "3"

README-en.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@ pip install -U wxpusher
2121

2222
```python
2323
from wxpusher import WxPusher
24-
WxPusher.send_message('<content>', '<uids>', '<appToken>')
24+
WxPusher.send_message('<content>',
25+
uids='<uids>',
26+
topic_ids='<topic_ids>',
27+
token='<appToken>')
2528
WxPusher.query_message('<messageId>')
2629
WxPusher.create_qrcode('<extra>', '<validTime>', '<appToken>')
2730
WxPusher.query_user('<page>', '<page_size>', '<appToken>')

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@ pip install -U wxpusher
2121

2222
```python
2323
from wxpusher import WxPusher
24-
WxPusher.send_message('<content>', '<uids>', '<appToken>')
24+
WxPusher.send_message('<content>',
25+
uids='<uids>',
26+
topic_ids='<topic_ids>',
27+
token='<appToken>')
2528
WxPusher.query_message('<messageId>')
2629
WxPusher.create_qrcode('<extra>', '<validTime>', '<appToken>')
2730
WxPusher.query_user('<page>', '<page_size>', '<appToken>')

VERSION

Lines changed: 0 additions & 1 deletion
This file was deleted.

setup.py

Lines changed: 29 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,52 @@
11
#!/usr/bin/env python
22
# -*- coding: utf-8 -*-
33
"""
4+
Python packaging for wxpusher.
5+
46
File: setup.py
57
Author: huxuan
68
Email: i(at)huxuan.org
7-
Description: Python packaging for wxpusher.
89
"""
10+
from pkg_resources import DistributionNotFound
11+
from pkg_resources import get_distribution
12+
913
from setuptools import setup
1014

15+
NAME = 'wxpusher'
16+
1117
CLASSIFIERS = [
1218
'Development Status :: 4 - Beta',
1319
'Intended Audience :: Developers',
1420
'License :: OSI Approved :: Apache Software License',
1521
'Programming Language :: Python :: 3',
1622
'Programming Language :: Python :: 3 :: Only',
17-
'Topic :: Utilities'
23+
'Topic :: Utilities',
1824
]
1925

2026
INSTALL_REQUIRES = [
21-
'requests'
27+
'requests',
2228
]
2329

24-
DEV_REQUIRES = [
25-
'pycodestyle',
26-
'pyflakes',
27-
'pylint'
28-
]
29-
30-
TEST_REQUIRES = [
31-
'coverage',
32-
'nose'
33-
]
34-
35-
EXTRAS_REQUIRE = {
36-
'dev': DEV_REQUIRES,
37-
'test': TEST_REQUIRES
38-
}
39-
4030
DESCRIPTION = (
4131
'WxPusher Python SDK.'
4232
)
4333

44-
VERSION = open('VERSION').read().strip()
34+
KEYWORDS = [
35+
'wxpusher',
36+
'wechat',
37+
'weixin',
38+
'notification',
39+
'push-notification',
40+
'python-sdk',
41+
]
42+
43+
try:
44+
VERSION = f'v{get_distribution(NAME).version}'
45+
except DistributionNotFound:
46+
VERSION = 'master'
47+
4548
PROJECT_URL = 'https://github.com/wxpusher/wxpusher-sdk-python'
46-
BASE_URL = f'{PROJECT_URL}/blob/v{VERSION}'
49+
BASE_URL = f'{PROJECT_URL}/blob/{VERSION}'
4750

4851

4952
def readme():
@@ -54,19 +57,19 @@ def readme():
5457
return content
5558

5659

57-
setup(name='wxpusher',
58-
version=VERSION,
60+
setup(name=NAME,
5961
description=DESCRIPTION,
6062
long_description=readme(),
6163
long_description_content_type='text/markdown',
6264
classifiers=CLASSIFIERS,
63-
keywords='wxpusher wechat push-notification',
64-
url='https://github.com/wxpusher/wxpusher-sdk-python',
65+
keywords=' '.join(KEYWORDS),
66+
url=PROJECT_URL,
6567
author='Xuan (Sean) Hu',
6668
author_email='[email protected]',
6769
license='Apache License 2.0',
6870
packages=['wxpusher'],
71+
use_scm_version=True,
72+
setup_requires=['setuptools_scm'],
6973
install_requires=INSTALL_REQUIRES,
70-
extras_require=EXTRAS_REQUIRE,
7174
python_requires='>=3',
7275
include_package_data=True)

tox.ini

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,21 @@
44
# and then run "tox" from this directory.
55

66
[tox]
7-
envlist = py3
7+
envlist = py3, lint-py3
88

99
[testenv]
1010
deps =
11-
.[test]
11+
coverage
12+
nose
13+
pipenv
1214
commands =
15+
pipenv install --skip-lock
1316
nosetests --with-coverage --cover-erase --cover-package=wxpusher
17+
18+
[testenv:lint-py3]
19+
basepython = python3
20+
deps =
21+
pipenv
22+
commands=
23+
pipenv install --skip-lock --dev
24+
pipenv run make lint

wxpusher/__init__.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
11
#!/usr/bin/env python
22
# -*- coding: utf-8 -*-
33
"""
4+
Init for WxPusher.
5+
46
File: __init__.py
57
Author: huxuan
68
Email: i(at)huxuan.org
7-
Description: init for WxPusher.
89
"""
9-
from .wxpusher import WxPusher
1010
from .exceptions import WxPusherException
1111
from .exceptions import WxPusherNoneTokenException
12+
from .wxpusher import WxPusher
1213

1314
__all__ = [
1415
'WxPusher',
1516
'WxPusherException',
16-
'WxPusherNoneTokenException'
17+
'WxPusherNoneTokenException',
1718
]
18-
19-
__version__ = open('VERSION').read().strip()

0 commit comments

Comments
 (0)