Browse Source

Added ETF support for Python 3.x

Bumped requirements for PyNaCl and youtube-dl
pull/68/head
Giovani Irimea 8 years ago
parent
commit
97df6a1355
  1. 5
      .gitignore
  2. 2
      README.md
  3. 9
      disco/gateway/encoding/etf.py
  4. 8
      setup.py

5
.gitignore

@ -4,8 +4,10 @@ disco*.egg-info/
storage.db
storage.json
*.dca
*.pyc
.eggs/
.cache/
.benchmarks/
__pycache__
# Documentation stuff
@ -13,3 +15,6 @@ docs/api/
docs/_build
_book/
node_modules/
# JetBrains IDE
.idea/

2
README.md

@ -15,7 +15,7 @@ Disco was built to run both as a generic-use library, and a standalone bot toolk
|----|------|
|requests[security]|adds packages for a proper SSL implementation|
|ujson|faster json parser, improves performance|
|erlpack|ETF parser, only Python 2.x, run with the --encoder=etf flag|
|erlpack (2.x), earl-etf (3.x)|ETF parser run with the --encoder=etf flag|
|gipc|Gevent IPC, required for autosharding|
## Examples

9
disco/gateway/encoding/etf.py

@ -1,8 +1,13 @@
import six
from websocket import ABNF
from erlpack import unpack, pack
from disco.gateway.encoding.base import BaseEncoder
if six.PY3:
from earl import unpack, pack
else:
from erlpack import unpack, pack
class ETFEncoder(BaseEncoder):
TYPE = 'etf'
@ -14,4 +19,6 @@ class ETFEncoder(BaseEncoder):
@staticmethod
def decode(obj):
if six.PY3:
return unpack(obj, encoding='utf-8', encode_binary_ext=True)
return unpack(obj)

8
setup.py

@ -1,8 +1,8 @@
import six
from setuptools import setup, find_packages
from disco import VERSION
with open('requirements.txt') as f:
requirements = f.readlines()
@ -10,11 +10,11 @@ with open('README.md') as f:
readme = f.read()
extras_require = {
'voice': ['pynacl==1.1.2'],
'voice': ['pynacl==1.2.1'],
'http': ['flask==0.12.2'],
'yaml': ['pyyaml==3.12'],
'music': ['youtube_dl>=2017.10.20'],
'performance': ['erlpack==0.3.2', 'ujson==1.35'],
'music': ['youtube_dl>=2017.12.2'],
'performance': ['erlpack==0.3.2' if six.PY2 else 'earl-etf==2.1.2', 'ujson==1.35'],
'sharding': ['gipc==0.6.0'],
'docs': ['biblio==0.0.4'],
}

Loading…
Cancel
Save