Skip to content

Commit 35eec21

Browse files
authored
Merge pull request GetStream#90 from GetStream/feature/reactions
Enrichment, Users, Collections and Reactions
2 parents 23f52d0 + 6b7bf05 commit 35eec21

33 files changed

+923
-1232
lines changed

.flake8

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[flake8]
2+
ignore = E501,W503,E203,E731
3+
max-line-length = 110
4+
select = C,E,F,W,B,B950
5+
exclude = .eggs/*,docs/*,lib,src,bin,include,share

.travis.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
language: python
2-
sudo: false
32
python:
43
- 2.6
54
- 2.7
@@ -12,13 +11,13 @@ matrix:
1211
include:
1312
- python: 3.7
1413
dist: xenial
15-
sudo: true
1614

1715
cache: pip
1816

1917
install:
2018
- pip install -r dev_requirements.txt
2119
script:
20+
- echo $STREAM_KEY
2221
- py.test -lv --cov=./
2322
after_script:
2423
- "pep8 --exclude=migrations --ignore=E501,E225,W293 stream"

README.md

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ Documentation for this Python client are available at the [Stream website](https
2828
### Usage
2929

3030
```python
31+
import datetime
32+
3133
# Instantiate a new client
3234
import stream
3335
client = stream.connect('YOUR_API_KEY', 'API_KEY_SECRET')
@@ -116,15 +118,11 @@ client.activity_partial_update(id=activity_id, set=set, unset=unset)
116118
# ...or by combination of foreign_id and time
117119
client.activity_partial_update(foreign_id=foreign_id, time=activity_time, set=set, unset=unset)
118120

119-
# Generating tokens for client side usage (JS client)
120-
token = user_feed_1.token
121-
# Javascript client side feed initialization
122-
# user1 = client.feed('user', '1', '{{ token }}');
121+
# Generating user token for client side usage (JS client)
122+
user_token = client.create_user_token("user-42")
123123

124-
# Generate a read-only token for client side usage (JS client)
125-
readonly_token = user_feed_1.get_readonly_token()
126124
# Javascript client side feed initialization
127-
# user1 = client.feed('user', '1', '{{ readonly_token }}');
125+
# client = stream.connect(apiKey, userToken, appId);
128126

129127
# Generate a redirect url for the Stream Analytics platform to track
130128
# events/impressions on url clicks
@@ -164,6 +162,15 @@ py.test --cov stream --cov-report html
164162
LOCAL=true py.test
165163
```
166164

165+
Install black and flake8
166+
167+
```
168+
pip install black
169+
pip install flake8
170+
```
171+
172+
Install git hooks to avoid pushing invalid code (git commit will run black and flak8)
173+
167174
### Releasing a new version
168175

169176
In order to release new version you need to be a maintainer on Pypi.

dotgit/hooks-wrapper

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/usr/bin/env bash
2+
3+
# Runs all executable pre-commit-* hooks and exits after,
4+
# if any of them was not successful.
5+
#
6+
# Based on
7+
# https://github.com/ELLIOTTCABLE/Paws.js/blob/Master/Scripts/git-hooks/chain-hooks.sh
8+
# http://osdir.com/ml/git/2009-01/msg00308.html
9+
#
10+
# assumes your scripts are located at <repo-root>/bin/git/hooks
11+
exitcodes=()
12+
hookname=`basename $0`
13+
# our special hooks folder
14+
CUSTOM_HOOKS_DIR=$(git rev-parse --show-toplevel)/dotgit/hooks
15+
# find gits native hooks folder
16+
NATIVE_HOOKS_DIR=$(git rev-parse --show-toplevel)/.git/hooks
17+
18+
# Run each hook, passing through STDIN and storing the exit code.
19+
# We don't want to bail at the first failure, as the user might
20+
# then bypass the hooks without knowing about additional issues.
21+
22+
for hook in $CUSTOM_HOOKS_DIR/$(basename $0)-*; do
23+
test -x "$hook" || continue
24+
$hook "$@"
25+
exitcodes+=($?)
26+
done
27+
28+
# check if there was a local hook that was moved previously
29+
if [ -f "$NATIVE_HOOKS_DIR/$hookname.local" ]; then
30+
out=`$NATIVE_HOOKS_DIR/$hookname.local "$@"`
31+
exitcodes+=($?)
32+
echo "$out"
33+
fi
34+
35+
# If any exit code isn't 0, bail.
36+
for i in "${exitcodes[@]}"; do
37+
[ "$i" == 0 ] || exit $i
38+
done

dotgit/hooks/pre-commit-format.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
if ! black . --check -q; then
6+
black .
7+
echo "some files were not formatted correctly (black) commit aborted!"
8+
echo "your changes are still staged, you can accept formatting changes with git add or ignore them by adding --no-verify to git commit"
9+
exit 1
10+
fi
11+
12+
flake8
13+

dotgit/setup-hooks.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/usr/bin/env bash
2+
# based on http://stackoverflow.com/a/3464399/1383268
3+
# assumes that the hooks-wrapper script is located at <repo-root>/bin/git/hooks-wrapper
4+
5+
HOOK_NAMES="applypatch-msg pre-applypatch post-applypatch pre-commit prepare-commit-msg commit-msg post-commit pre-rebase post-checkout post-merge pre-receive update post-receive post-update pre-auto-gc pre-push"
6+
# find gits native hooks folder
7+
HOOKS_DIR=$(git rev-parse --show-toplevel)/.git/hooks
8+
9+
for hook in $HOOK_NAMES; do
10+
# If the hook already exists, is a file, and is not a symlink
11+
if [ ! -h $HOOKS_DIR/$hook ] && [ -f $HOOKS_DIR/$hook ]; then
12+
mv $HOOKS_DIR/$hook $HOOKS_DIR/$hook.local
13+
fi
14+
# create the symlink, overwriting the file if it exists
15+
# probably the only way this would happen is if you're using an old version of git
16+
# -- back when the sample hooks were not executable, instead of being named ____.sample
17+
ln -s -f ../../dotgit/hooks-wrapper $HOOKS_DIR/$hook
18+
done

fabfile.py

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

pyproject.toml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
[tool.black]
2+
line-length = 88
3+
py36 = true
4+
include = '\.pyi?$'
5+
exclude = '''
6+
/(
7+
\.git
8+
| \.hg
9+
| \.egg
10+
| \.eggs
11+
| \.mypy_cache
12+
| \.tox
13+
| _build
14+
| \.venv
15+
| src
16+
| bin
17+
| stream_python\.egg-info
18+
| fabfile.py
19+
| lib
20+
| docs
21+
| buck-out
22+
| build
23+
| dist
24+
)/
25+
'''

setup.py

Lines changed: 33 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -6,38 +6,27 @@
66
from stream import __version__, __maintainer__, __email__, __license__
77
import sys
88

9-
unit = 'unittest2py3k' if sys.version_info > (3, 0, 0) else 'unittest2'
10-
tests_require = [
11-
unit,
12-
'pytest==3.2.5',
13-
'unittest2',
14-
'pytest-cov',
15-
'python-dateutil'
16-
]
9+
unit = "unittest2py3k" if sys.version_info > (3, 0, 0) else "unittest2"
10+
tests_require = [unit, "pytest==3.2.5", "unittest2", "pytest-cov", "python-dateutil"]
1711

18-
long_description = open('README.md', 'r').read()
12+
long_description = open("README.md", "r").read()
1913

20-
requests = 'requests>=2.3.0,<3'
14+
requests = "requests>=2.3.0,<3"
2115

2216
if sys.version_info < (2, 7, 9):
23-
requests = 'requests[security]>=2.4.1,<3'
17+
requests = "requests[security]>=2.4.1,<3"
2418

25-
install_requires = [
26-
'pycryptodomex==3.4.7',
27-
requests,
28-
'six>=1.8.0'
29-
]
19+
install_requires = ["pycryptodomex==3.4.7", requests, "six>=1.8.0"]
3020

3121
if sys.version_info < (2, 7, 0):
32-
install_requires.append('pyOpenSSL<18.0.0')
33-
install_requires.append('pyjwt>=1.3.0,<1.6.0')
34-
install_requires.append('pycparser<2.19')
22+
install_requires.append("pyOpenSSL<18.0.0")
23+
install_requires.append("pyjwt>=1.3.0,<1.6.0")
24+
install_requires.append("pycparser<2.19")
3525
else:
36-
install_requires.append('pyjwt>=1.3.0,<1.7.0')
26+
install_requires.append("pyjwt>=1.3.0,<1.7.0")
3727

3828

3929
class PyTest(TestCommand):
40-
4130
def finalize_options(self):
4231
TestCommand.finalize_options(self)
4332
self.test_args = []
@@ -46,43 +35,43 @@ def finalize_options(self):
4635
def run_tests(self):
4736
# import here, cause outside the eggs aren't loaded
4837
import pytest
49-
errno = pytest.main(
50-
'-v --cov=./')
38+
39+
errno = pytest.main("-v --cov=./")
5140
sys.exit(errno)
5241

5342

5443
setup(
55-
name='stream-python',
44+
name="stream-python",
5645
version=__version__,
5746
author=__maintainer__,
5847
author_email=__email__,
59-
url='http://github.com/GetStream/stream-python',
60-
description='Client for getstream.io. Build scalable newsfeeds & activity streams in a few hours instead of weeks.',
48+
url="http://github.com/GetStream/stream-python",
49+
description="Client for getstream.io. Build scalable newsfeeds & activity streams in a few hours instead of weeks.",
6150
long_description=long_description,
62-
long_description_content_type='text/markdown',
51+
long_description_content_type="text/markdown",
6352
license=__license__,
6453
packages=find_packages(),
6554
zip_safe=False,
6655
install_requires=install_requires,
67-
extras_require={'test': tests_require},
68-
cmdclass={'test': PyTest},
56+
extras_require={"test": tests_require},
57+
cmdclass={"test": PyTest},
6958
tests_require=tests_require,
7059
include_package_data=True,
7160
classifiers=[
72-
'Intended Audience :: Developers',
73-
'Intended Audience :: System Administrators',
74-
'Operating System :: OS Independent',
75-
'Topic :: Software Development',
76-
'Development Status :: 5 - Production/Stable',
77-
'License :: OSI Approved :: BSD License',
78-
'Natural Language :: English',
79-
'Programming Language :: Python :: 2.6',
80-
'Programming Language :: Python :: 2.7',
81-
'Programming Language :: Python :: 3',
82-
'Programming Language :: Python :: 3.4',
83-
'Programming Language :: Python :: 3.5',
84-
'Programming Language :: Python :: 3.6',
85-
'Programming Language :: Python :: 3.7',
86-
'Topic :: Software Development :: Libraries :: Python Modules',
61+
"Intended Audience :: Developers",
62+
"Intended Audience :: System Administrators",
63+
"Operating System :: OS Independent",
64+
"Topic :: Software Development",
65+
"Development Status :: 5 - Production/Stable",
66+
"License :: OSI Approved :: BSD License",
67+
"Natural Language :: English",
68+
"Programming Language :: Python :: 2.6",
69+
"Programming Language :: Python :: 2.7",
70+
"Programming Language :: Python :: 3",
71+
"Programming Language :: Python :: 3.4",
72+
"Programming Language :: Python :: 3.5",
73+
"Programming Language :: Python :: 3.6",
74+
"Programming Language :: Python :: 3.7",
75+
"Topic :: Software Development :: Libraries :: Python Modules",
8776
],
8877
)

0 commit comments

Comments
 (0)