Skip to content

Commit

Permalink
🆕 Prepare for Py-PI
Browse files Browse the repository at this point in the history
- Added setup.py
- Added development related imports and scripts
- Added .cfg files
  • Loading branch information
Alex Ronquillo committed Jan 15, 2018
1 parent 0d7d778 commit fff3e66
Show file tree
Hide file tree
Showing 8 changed files with 236 additions and 3 deletions.
4 changes: 4 additions & 0 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ name = "pypi"

[packages]

pycodestyle = "*"
"flake8" = "*"
isort = "*"
pylint = "*"


[dev-packages]
Expand Down
130 changes: 130 additions & 0 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

41 changes: 41 additions & 0 deletions linters.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/bin/bash

echo "> running pycodestyle..."
pycodestyle --max-line-length=99 --exclude='.eggs,build,dist' .
if [ $? != 0 ]
then
exit 1
else
echo "pycodestyle looks good!"
fi
echo

echo "> running flake8..."
flake8 --exclude='.eggs,build,dist' --max-line-length=99
if [ $? != 0 ]
then
exit 1
else
echo "flake8 looks good!"
fi
echo

echo "> running pylint..."
pylint marshmallow_arrow

if [ $? != 0 ] && [ $? != 32 ]; then
echo "Exit code: $?"
exit 1
else
echo "pylint looks good!"
fi
echo

echo "> running isort..."
isort -c
if [ $? != 0 ]; then
exit 1
else
echo "isort looks good!"
fi
echo
4 changes: 3 additions & 1 deletion marshmallow_arrow/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"""Provides Arrow field for Marshmallow."""

import arrow
from marshmallow import fields

Expand All @@ -21,7 +23,7 @@ def _serialize(self, value, attr, obj):

return value.isoformat()

def _deserialize(self, value, attr, obj):
def _deserialize(self, value, attr, data):
if not value:
raise self.fail('invalid_object')

Expand Down
14 changes: 14 additions & 0 deletions pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

echo "> let's make sure we're not on master..."
branch=`git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'`
if [ "$branch" == "master" ]
then
echo "Cannot commit to master, please create a dev branch."
exit 1
else
echo "$branch ok, continuing..."
fi
echo

. ./linters.sh
8 changes: 8 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[flake8]
max-line-length=100

[metadata]
description-file = README.md

[pycodestyle]
max-line-length=100
35 changes: 35 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
"""A Marshmallow Custom Field for Arrow objects."""

from setuptools import setup

setup(
name='Marshmallow-Arrow',
version='1.0',
url='https://github.com/youversion/marshmallow_arrow',
download_url='https://github.com/youversion/marshmallow_arrow/archive/master.zip',
license='MIT',
author='Alex Ronoquillo',
author_email='developers@youversion.com',
description='A Marshmallow Custom Field for Arrow objects.',
long_description=__doc__,
packages=['marshmallow_arrow'],
zip_safe=False,
include_package_data=True,
platforms='any',
install_requires=[
'arrow',
'marshmallow'
],
classifiers=[
'Environment :: Web Environment',
'Intended Audience :: Developers',
'License :: OSI Approved :: MIT License',
'Operating System :: OS Independent',
'Programming Language :: Python',
'Programming Language :: Python :: 3',
'Topic :: Internet :: WWW/HTTP :: Dynamic Content',
'Topic :: Software Development :: Libraries :: Python Modules'
],
keywords=['marshmallow', 'arrow'],
test_suite='tests',
)
3 changes: 1 addition & 2 deletions tests/test_arrow_field.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import arrow
from marshmallow import Schema, fields

from marshmallow_arrow import ArrowField


Expand All @@ -19,7 +20,6 @@ def test_deserialization():
birthday = arrow.utcnow().isoformat()
schema = CalendarEventSchema()
data, errors = schema.load({'name': 'Birthday Party', 'start_datetime': birthday})
print(data)
assert errors == {}
assert isinstance(data['start_datetime'], arrow.Arrow)
assert data['start_datetime'].isoformat() == birthday
Expand Down Expand Up @@ -53,7 +53,6 @@ def test_serialization():
birthday_event = CalendarEvent('Birthday Party', birthday)
schema = CalendarEventSchema()
result = schema.dump(birthday_event)
print(result.data)
assert result.data['start_datetime'] == birthday.isoformat()


Expand Down

0 comments on commit fff3e66

Please sign in to comment.