Skip to content

Commit

Permalink
Merge pull request #11 from 4Catalyzer/freshen
Browse files Browse the repository at this point in the history
Drop six. Add some love.
  • Loading branch information
taion committed Dec 16, 2015
2 parents 35a14db + 369db7a commit e66b2fd
Show file tree
Hide file tree
Showing 12 changed files with 113 additions and 33 deletions.
28 changes: 28 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
sudo: false

language: python
python:
- "2.7"
- "3.4"
- "3.5"
- "pypy"

env:
- TOXENV=py-base
- TOXENV=py-s3

cache:
directories:
- $HOME/.cache/pip

before_install:
- pip install -U pip
install:
- pip install -U tox

script:
- python setup.py test

branches:
only:
- master
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# flask-annex
Efficient integration of external storage services for Flask.
# Flask-Annex [![PyPI][pypi-badge]][pypi]
Efficient integration of external storage services for
[Flask](http://flask.pocoo.org/).

[![PyPI version](https://badge.fury.io/py/Flask-Annex.svg)](http://badge.fury.io/py/Flask-Annex)
[pypi-badge]: https://img.shields.io/pypi/v/Flask-Annex.svg
[pypi]: https://pypi.python.org/pypi/Flask-Annex
2 changes: 0 additions & 2 deletions flask_annex/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
from .base import AnnexBase
from . import utils

__all__ = ('Annex',)

# -----------------------------------------------------------------------------


Expand Down
2 changes: 1 addition & 1 deletion flask_annex/base.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from abc import ABCMeta, abstractmethod
from six import with_metaclass

from .compat import with_metaclass
from . import utils

# -----------------------------------------------------------------------------
Expand Down
24 changes: 24 additions & 0 deletions flask_annex/compat.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import sys

# -----------------------------------------------------------------------------

PY2 = sys.version_info[0] == 2

# -----------------------------------------------------------------------------

if PY2:
string_types = (str, unicode) # flake8: noqa
else:
string_types = (str,)


# From six.
def with_metaclass(meta, *bases):
"""Create a base class with a metaclass."""
# This requires a bit of explanation: the basic idea is to make a dummy
# metaclass for one level of class instantiation that replaces itself with
# the actual metaclass.
class metaclass(meta):
def __new__(cls, name, this_bases, d):
return meta(name, bases, d)
return type.__new__(metaclass, 'temporary_class', (), {})
6 changes: 2 additions & 4 deletions flask_annex/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@
import glob
import os
import shutil
from six import string_types

from .base import AnnexBase

__all__ = ('FileAnnex',)
from .compat import string_types

# -----------------------------------------------------------------------------

Expand Down Expand Up @@ -77,5 +75,5 @@ def send_file(self, key):
return flask.send_from_directory(
self._root_path, key,
as_attachment=True,
attachment_filename=os.path.basename(key)
attachment_filename=os.path.basename(key),
)
11 changes: 5 additions & 6 deletions flask_annex/s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@
from boto.s3.key import Key
import flask
import mimetypes
from six import string_types

from .base import AnnexBase

__all__ = ('S3Annex',)
from .compat import string_types

# -----------------------------------------------------------------------------

Expand All @@ -16,11 +14,12 @@


class S3Annex(AnnexBase):
def __init__(self, access_key_id, secret_access_key, bucket_name,
url_expires_in=DEFAULT_URL_EXPIRES_IN):
def __init__(
self, access_key_id, secret_access_key, bucket_name,
url_expires_in=DEFAULT_URL_EXPIRES_IN):
self._connection = S3Connection(access_key_id, secret_access_key)
self._bucket = self._connection.get_bucket(
bucket_name, validate=False
bucket_name, validate=False,
)

self._url_expires_in = url_expires_in
Expand Down
2 changes: 0 additions & 2 deletions flask_annex/utils.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import os

__all__ = ('get_config_from_env',)

# -----------------------------------------------------------------------------


Expand Down
7 changes: 0 additions & 7 deletions requirements.txt

This file was deleted.

4 changes: 2 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[metadata]
description-file = README.md
[wheel]
universal=1
41 changes: 35 additions & 6 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,26 @@
from setuptools import setup
from setuptools import Command, setup
import subprocess

# -----------------------------------------------------------------------------


def system(command):
class SystemCommand(Command):
user_options = []

def initialize_options(self):
pass

def finalize_options(self):
pass

def run(self):
subprocess.check_call(command, shell=True)

return SystemCommand


# -----------------------------------------------------------------------------

setup(
name="Flask-Annex",
Expand All @@ -18,15 +40,22 @@
'Programming Language :: Python',
'Programming Language :: Python :: 2',
'Topic :: Internet :: WWW/HTTP :: Dynamic Content',
'Topic :: Software Development :: Libraries :: Python Modules'
'Topic :: Software Development :: Libraries :: Python Modules',
),
keywords='storage s3 flask',
packages=('flask_annex',),
install_requires=(
'Flask',
'six'
'Flask >= 0.10',
),
extras_require={
's3': ('boto',)
}
's3': ('boto >= 2.38.0',),
},
cmdclass={
'clean': system('rm -rf build dist *.egg-info'),
'package': system('python setup.py pandoc sdist bdist_wheel'),
'pandoc': system('pandoc README.md -o README.rst'),
'publish': system('twine upload dist/*'),
'release': system('python setup.py clean package publish'),
'test': system('tox'),
},
)
11 changes: 11 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[tox]
envlist = py{27,35}-{base,s3}

[testenv]
deps =
flake8

commands =
s3: pip install .[s3]

flake8 .

0 comments on commit e66b2fd

Please sign in to comment.