Skip to content

Commit

Permalink
Merge pull request #19 from nvllsvm/maintenance
Browse files Browse the repository at this point in the history
Maintenance
  • Loading branch information
gmr committed Nov 29, 2018
2 parents afddbd3 + 2fe2480 commit daacd40
Show file tree
Hide file tree
Showing 21 changed files with 97 additions and 192 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ downloads
eggs
fake-eggs
parts
.eggs

# Packages #
############
Expand Down
18 changes: 9 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
language: python
dist: xenial
python:
- 2.7
- 3.4
- 3.5
- 3.6
- 3.7-dev
- pypy
- 3.7
install:
- pip install codecov
- pip install -r requires/installation.txt
- pip install -r requires/testing.txt
script: nosetests
- pip install codecov -r requires/development.txt
script:
- nosetests
- python setup.py build_sphinx
- python setup.py check
- flake8
after_success:
- codecov
deploy:
distributions: sdist bdist_wheel
provider: pypi
on:
python: 2.7
python: 3.7
tags: true
all_branches: true
user: sprockets
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2015-2016 AWeber Communications
Copyright (c) 2015-2018 AWeber Communications
All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
Expand Down
2 changes: 0 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,11 @@ request handlers.
class SomeHandler(content.ContentMixin, web.RequestHandler):
def get(self):
self.send_response({'data': 'value'})
self.finish()
def post(self):
body = self.get_request_body()
# do whatever
self.send_response({'action': 'performed'})
self.finish()
Based on the settings stored in the ``Application`` instance and the HTTP
headers, the request and response data will be handled correctly or the
Expand Down
3 changes: 0 additions & 3 deletions docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,3 @@ Bundled Transcoders

.. autoclass:: MsgPackTranscoder
:members:

.. autoclass:: BinaryWrapper
:members:
11 changes: 3 additions & 8 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,18 @@
import alabaster
from sprockets.mixins.mediatype import __version__
import pkg_resources

needs_sphinx = '1.0'
extensions = ['sphinx.ext.autodoc',
'sphinx.ext.viewcode',
'sphinx.ext.intersphinx',
'sphinxcontrib.autohttp.tornado']
source_suffix = '.rst'
master_doc = 'index'
project = 'sprockets.mixins.mediatype'
copyright = '2015-2016, AWeber Communications'
release = __version__
copyright = '2015-2018, AWeber Communications'
release = pkg_resources.get_distribution('sprockets.mixins.mediatype').version
version = '.'.join(release.split('.')[0:1])

pygments_style = 'sphinx'
html_theme = 'alabaster'
html_style = 'custom.css'
html_static_path = ['static']
html_theme_path = [alabaster.get_path()]
html_sidebars = {
'**': ['about.html', 'navigation.html'],
}
Expand Down
1 change: 0 additions & 1 deletion examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ def post(self):
body = self.get_request_body()
self.set_status(200)
self.send_response(body)
self.finish()


def make_application(**settings):
Expand Down
5 changes: 2 additions & 3 deletions requires/development.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
-e .[msgpack]
-r docs.txt
-r testing.txt
-r installation.txt
sphinx>=1.2,<2
sphinxcontrib-httpdomain>=1.3,<2
2 changes: 2 additions & 0 deletions requires/docs.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
sphinx==1.8.2
sphinxcontrib-httpdomain==1.7.0
2 changes: 1 addition & 1 deletion requires/installation.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
ietfparse>=1.4,<1.5
tornado>=3.2,<6
tornado>=5,<6
8 changes: 4 additions & 4 deletions requires/testing.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
coverage>=3.7,<3.99 # prevent installing 4.0b on ALL pip versions
mock>=1.3,<2
u-msgpack-python>=2,<3
nose>=1.3,<2
coverage==4.5.2
flake8==3.6.0
nose==1.3.7
tox==3.5.3
7 changes: 7 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
[bdist_wheel]
universal = 1

[build_sphinx]
fresh-env = 1
warning-is-error = 1

[check]
strict = 1

[nosetests]
cover-branches = 1
cover-erase = 1
Expand Down
59 changes: 27 additions & 32 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,38 +1,30 @@
#!/usr/bin/env python
#

import os
import pathlib
import setuptools

from sprockets.mixins import mediatype

REPO_DIR = pathlib.Path(__name__).parent


def read_requirements(file_name):
def read_requirements(name):
requirements = []
try:
with open(os.path.join('requires', file_name)) as req_file:
for req_line in req_file:
req_line = req_line.strip()
if '#' in req_line:
req_line = req_line[0:req_line.find('#')].strip()
if req_line.startswith('-r'):
req_line = req_line[2:].strip()
requirements.extend(read_requirements(req_line))
else:
requirements.append(req_line)
except IOError:
pass
for req_line in REPO_DIR.joinpath(name).read_text().split('\n'):
req_line = req_line.strip()
if '#' in req_line:
req_line = req_line[0:req_line.find('#')].strip()
if req_line.startswith('-r'):
req_line = req_line[2:].strip()
requirements.extend(read_requirements(req_line))
else:
requirements.append(req_line)
return requirements


install_requires = read_requirements('installation.txt')
tests_require = read_requirements('testing.txt')

setuptools.setup(
name='sprockets.mixins.mediatype',
version=mediatype.__version__,
description='A mixin for reporting handling content-type/accept headers',
long_description='\n' + open('README.rst').read(),
long_description=REPO_DIR.joinpath('README.rst').read_text(),
url='https://github.com/sprockets/sprockets.mixins.media_type',
author='AWeber Communications',
author_email='api@aweber.com',
Expand All @@ -43,24 +35,27 @@ def read_requirements(file_name):
'License :: OSI Approved :: BSD License',
'Natural Language :: English',
'Operating System :: OS Independent',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.2',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: Implementation :: CPython',
'Programming Language :: Python :: Implementation :: PyPy',
'Topic :: Software Development :: Libraries',
'Topic :: Software Development :: Libraries :: Python Modules'
],
packages=setuptools.find_packages(),
install_requires=install_requires,
tests_require=tests_require,
packages=[
'sprockets',
'sprockets.mixins',
'sprockets.mixins.mediatype'
],
install_requires=read_requirements('requires/installation.txt'),
tests_require=read_requirements('requires/testing.txt'),
extras_require={
'msgpack': ['u-msgpack-python>=2.5.0,<3']
},
setup_requires=['setuptools_scm'],
use_scm_version=True,
namespace_packages=['sprockets', 'sprockets.mixins'],
test_suite='nose.collector',
python_requires='>=3.5',
zip_safe=False)
1 change: 0 additions & 1 deletion sprockets/__init__.py

This file was deleted.

1 change: 0 additions & 1 deletion sprockets/mixins/__init__.py

This file was deleted.

23 changes: 3 additions & 20 deletions sprockets/mixins/mediatype/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,11 @@
"""

try:
from .content import (ContentMixin, ContentSettings,
add_binary_content_type, add_text_content_type,
set_default_content_type)
from .content import (ContentMixin, ContentSettings,
add_binary_content_type, add_text_content_type,
set_default_content_type)

except ImportError as error: # pragma no cover
def _error_closure(*args, **kwargs):
raise error

class ErrorClosureClass(object):
def __init__(self, *args, **kwargs):
raise error

ContentMixin = ErrorClosureClass
ContentSettings = ErrorClosureClass
add_binary_content_type = _error_closure
add_text_content_type = _error_closure
set_default_content_type = _error_closure


version_info = (2, 2, 2)
__version__ = '.'.join(str(v) for v in version_info)
__all__ = ['ContentMixin', 'ContentSettings', 'add_binary_content_type',
'add_text_content_type', 'set_default_content_type',
'version_info', '__version__']
8 changes: 3 additions & 5 deletions sprockets/mixins/mediatype/content.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
_warning_issued = False


class ContentSettings(object):
class ContentSettings:
"""
Content selection settings.
Expand Down Expand Up @@ -75,7 +75,6 @@ def get(self):
response_body = settings['application/msgpack'].to_bytes(
response_dict, encoding='utf-8')
self.write(response_body)
self.finish()
def make_application():
app = web.Application([web.url('/', SomeHandler)])
Expand Down Expand Up @@ -277,7 +276,7 @@ def set_default_content_type(application, content_type, encoding=None):
settings.default_encoding = encoding


class ContentMixin(object):
class ContentMixin:
"""
Mix this in to add some content handling methods.
Expand All @@ -288,7 +287,6 @@ def post(self):
body = self.get_request_body()
# do stuff --> response_dict
self.send_response(response_dict)
self.finish()
:meth:`get_request_body` will deserialize the request data into
a dictionary based on the :http:header:`Content-Type` request
Expand All @@ -300,7 +298,7 @@ def post(self):
"""

def initialize(self):
super(ContentMixin, self).initialize()
super().initialize()
self._request_body = None
self._best_response_match = None
self._logger = getattr(self, 'logger', logger)
Expand Down
4 changes: 2 additions & 2 deletions sprockets/mixins/mediatype/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from tornado import escape


class BinaryContentHandler(object):
class BinaryContentHandler:
"""
Pack and unpack binary types.
Expand Down Expand Up @@ -58,7 +58,7 @@ def from_bytes(self, data_bytes, encoding=None):
return self._unpack(data_bytes)


class TextContentHandler(object):
class TextContentHandler:
"""
Transcodes between textual and object representations.
Expand Down

0 comments on commit daacd40

Please sign in to comment.