Skip to content

Commit

Permalink
setup.py improvements
Browse files Browse the repository at this point in the history
Version 2.1.0

Python 2/3 compat

Rename to Basho fork
  • Loading branch information
Luke Bakken committed Mar 28, 2016
1 parent 8298677 commit 20427f7
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 18 deletions.
22 changes: 20 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
*.pyc
.DS_Store
build/*
.python-version
__pycache__/

.tox/

docs/_build

.*.swp
.coverage

build/
py-build/
dist/

*.egg-info/
*.egg
.eggs/

#*#
*~
3 changes: 1 addition & 2 deletions erlastic/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@

"""Erlang External Term Format serializer/deserializer"""

__version__ = "2.0.0"
__version__ = "2.1.0"
__license__ = "BSD"

from erlastic.codec import ErlangTermDecoder, ErlangTermEncoder
Expand Down
11 changes: 5 additions & 6 deletions erlastic/codec.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def decode_100(self, buf, offset):

def decode_115(self, buf, offset):
"""SMALL_ATOM_EXT"""
atom_len = six.intexbytes(buf, offset)
atom_len = six.indexbytes(buf, offset)
atom = buf[offset+1:offset+1+atom_len]
return self.convert_atom(atom), offset+atom_len+1

Expand Down Expand Up @@ -211,9 +211,6 @@ def __init__(self, encoding="utf-8", unicode_type="binary"):
self.unicode_type = unicode_type

def encode(self, obj, compressed=False):
import sys
import pprint
#pprint.pprint(self.encode_part(obj),stream=sys.stderr)
ubuf = six.b('').join(self.encode_part(obj))
if compressed is True:
compressed = 6
Expand Down Expand Up @@ -263,10 +260,12 @@ def encode_part(self, obj):
elif isinstance(obj, Atom):
st = obj.encode('latin-1')
return [pack_bytes([ATOM_EXT]), struct.pack(">H", len(st)), st]
elif isinstance(obj, six.string_types):
elif isinstance(obj, six.text_type):
st = obj.encode('utf-8')
return [pack_bytes([BINARY_EXT]), struct.pack(">L", len(st)), st]
elif isinstance(obj, six.binary_type):
elif isinstance(obj, six.string_types) or isinstance(obj, six.binary_type):
# https://pythonhosted.org/six/#six.string_types
# https://pythonhosted.org/six/#six.binary_type
return [pack_bytes([BINARY_EXT]), struct.pack(">L", len(obj)), obj]
elif isinstance(obj, tuple):
n = len(obj)
Expand Down
13 changes: 7 additions & 6 deletions setup.py
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
#!/usr/bin/env python

from distutils.core import setup
import setuptools

from erlastic import __version__ as version

setup(
name = 'erlastic',
setuptools.setup(
name = 'basho-erlastic',
version = version,
description = 'Erlastic',
author = 'Samuel Stauffer',
author_email = 'samuel@descolada.com',
url = 'http://github.com/samuel/python-erlastic',
author = 'Samuel Stauffer, Basho Technologies',
author_email = 'clients@basho.com',
url = 'http://github.com/basho/python-erlastic',
packages = ['erlastic'],
install_requires=['six'],
test_suite='tests',
classifiers = [
'Intended Audience :: Developers',
'License :: OSI Approved :: BSD License',
Expand Down
4 changes: 2 additions & 2 deletions tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,13 @@

class ErlangTestCase(unittest.TestCase):
def testDecode(self):
for python, expected_type, erlang in erlang_term_binaries + erlang_term_decode:
for python, expected_type, erlang in erlang_term_binaries + erlang_term_decode:
decoded = decode(erlang)
self.assertEqual(python, decoded)
self.assertTrue(isinstance(decoded, expected_type))

def testEncode(self):
for python, expected_type, erlang in erlang_term_binaries + erlang_term_encode:
for python, expected_type, erlang in erlang_term_binaries + erlang_term_encode:
encoded = encode(python)
self.assertEqual(erlang, encoded)

Expand Down

0 comments on commit 20427f7

Please sign in to comment.