[Python-modules-commits] [flask-compress] 01/08: New upstream version 1.3.1
Dominik George
natureshadow-guest at moszumanska.debian.org
Thu Sep 22 14:27:40 UTC 2016
This is an automated email from the git hooks/post-receive script.
natureshadow-guest pushed a commit to branch master
in repository flask-compress.
commit abb7478d7226df0e7aa5fd953fc6828d044f622c
Author: Dominik George <nik at naturalnet.de>
Date: Thu Sep 22 15:24:49 2016 +0200
New upstream version 1.3.1
---
Flask_Compress.egg-info/PKG-INFO | 28 +++++++
Flask_Compress.egg-info/SOURCES.txt | 8 ++
Flask_Compress.egg-info/dependency_links.txt | 1 +
Flask_Compress.egg-info/not-zip-safe | 1 +
Flask_Compress.egg-info/requires.txt | 1 +
Flask_Compress.egg-info/top_level.txt | 1 +
PKG-INFO | 28 +++++++
flask_compress.py | 117 +++++++++++++++++++++++++++
setup.cfg | 5 ++
setup.py | 42 ++++++++++
10 files changed, 232 insertions(+)
diff --git a/Flask_Compress.egg-info/PKG-INFO b/Flask_Compress.egg-info/PKG-INFO
new file mode 100644
index 0000000..d55e890
--- /dev/null
+++ b/Flask_Compress.egg-info/PKG-INFO
@@ -0,0 +1,28 @@
+Metadata-Version: 1.1
+Name: Flask-Compress
+Version: 1.3.1
+Summary: Compress responses in your Flask app with gzip.
+Home-page: https://github.com/wichitacode/flask-compress
+Author: William Fagan
+Author-email: will at wichitacode.com
+License: MIT
+Description:
+ Flask-Compress
+ ------------
+
+ Compress responses in your Flask app with gzip..
+
+Platform: any
+Classifier: Environment :: Web Environment
+Classifier: Intended Audience :: Developers
+Classifier: License :: OSI Approved :: MIT License
+Classifier: Operating System :: OS Independent
+Classifier: Programming Language :: Python :: 2
+Classifier: Programming Language :: Python :: 2.6
+Classifier: Programming Language :: Python :: 2.7
+Classifier: Programming Language :: Python :: 3
+Classifier: Programming Language :: Python :: 3.3
+Classifier: Programming Language :: Python :: 3.4
+Classifier: Programming Language :: Python :: 3.5
+Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content
+Classifier: Topic :: Software Development :: Libraries :: Python Modules
diff --git a/Flask_Compress.egg-info/SOURCES.txt b/Flask_Compress.egg-info/SOURCES.txt
new file mode 100644
index 0000000..a76d097
--- /dev/null
+++ b/Flask_Compress.egg-info/SOURCES.txt
@@ -0,0 +1,8 @@
+flask_compress.py
+setup.py
+Flask_Compress.egg-info/PKG-INFO
+Flask_Compress.egg-info/SOURCES.txt
+Flask_Compress.egg-info/dependency_links.txt
+Flask_Compress.egg-info/not-zip-safe
+Flask_Compress.egg-info/requires.txt
+Flask_Compress.egg-info/top_level.txt
\ No newline at end of file
diff --git a/Flask_Compress.egg-info/dependency_links.txt b/Flask_Compress.egg-info/dependency_links.txt
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/Flask_Compress.egg-info/dependency_links.txt
@@ -0,0 +1 @@
+
diff --git a/Flask_Compress.egg-info/not-zip-safe b/Flask_Compress.egg-info/not-zip-safe
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/Flask_Compress.egg-info/not-zip-safe
@@ -0,0 +1 @@
+
diff --git a/Flask_Compress.egg-info/requires.txt b/Flask_Compress.egg-info/requires.txt
new file mode 100644
index 0000000..e3e9a71
--- /dev/null
+++ b/Flask_Compress.egg-info/requires.txt
@@ -0,0 +1 @@
+Flask
diff --git a/Flask_Compress.egg-info/top_level.txt b/Flask_Compress.egg-info/top_level.txt
new file mode 100644
index 0000000..849c87e
--- /dev/null
+++ b/Flask_Compress.egg-info/top_level.txt
@@ -0,0 +1 @@
+flask_compress
diff --git a/PKG-INFO b/PKG-INFO
new file mode 100644
index 0000000..d55e890
--- /dev/null
+++ b/PKG-INFO
@@ -0,0 +1,28 @@
+Metadata-Version: 1.1
+Name: Flask-Compress
+Version: 1.3.1
+Summary: Compress responses in your Flask app with gzip.
+Home-page: https://github.com/wichitacode/flask-compress
+Author: William Fagan
+Author-email: will at wichitacode.com
+License: MIT
+Description:
+ Flask-Compress
+ ------------
+
+ Compress responses in your Flask app with gzip..
+
+Platform: any
+Classifier: Environment :: Web Environment
+Classifier: Intended Audience :: Developers
+Classifier: License :: OSI Approved :: MIT License
+Classifier: Operating System :: OS Independent
+Classifier: Programming Language :: Python :: 2
+Classifier: Programming Language :: Python :: 2.6
+Classifier: Programming Language :: Python :: 2.7
+Classifier: Programming Language :: Python :: 3
+Classifier: Programming Language :: Python :: 3.3
+Classifier: Programming Language :: Python :: 3.4
+Classifier: Programming Language :: Python :: 3.5
+Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content
+Classifier: Topic :: Software Development :: Libraries :: Python Modules
diff --git a/flask_compress.py b/flask_compress.py
new file mode 100644
index 0000000..3f2d922
--- /dev/null
+++ b/flask_compress.py
@@ -0,0 +1,117 @@
+import sys
+from gzip import GzipFile
+from io import BytesIO
+
+from flask import request, current_app
+
+
+if sys.version_info[:2] == (2, 6):
+ class GzipFile(GzipFile):
+ """ Backport of context manager support for python 2.6"""
+ def __enter__(self):
+ if self.fileobj is None:
+ raise ValueError("I/O operation on closed GzipFile object")
+ return self
+
+ def __exit__(self, *args):
+ self.close()
+
+
+class DictCache(object):
+
+ def __init__(self):
+ self.data = {}
+
+ def get(self, key):
+ return self.data.get(key)
+
+ def set(self, key, value):
+ self.data[key] = value
+
+
+class Compress(object):
+ """
+ The Compress object allows your application to use Flask-Compress.
+
+ When initialising a Compress object you may optionally provide your
+ :class:`flask.Flask` application object if it is ready. Otherwise,
+ you may provide it later by using the :meth:`init_app` method.
+
+ :param app: optional :class:`flask.Flask` application object
+ :type app: :class:`flask.Flask` or None
+ """
+ def __init__(self, app=None):
+ """
+ An alternative way to pass your :class:`flask.Flask` application
+ object to Flask-Compress. :meth:`init_app` also takes care of some
+ default `settings`_.
+
+ :param app: the :class:`flask.Flask` application object.
+ """
+ self.app = app
+ if app is not None:
+ self.init_app(app)
+
+ def init_app(self, app):
+ defaults = [
+ ('COMPRESS_MIMETYPES', ['text/html', 'text/css', 'text/xml',
+ 'application/json',
+ 'application/javascript']),
+ ('COMPRESS_LEVEL', 6),
+ ('COMPRESS_MIN_SIZE', 500),
+ ('COMPRESS_CACHE_KEY', None),
+ ('COMPRESS_CACHE_BACKEND', None),
+ ]
+
+ for k, v in defaults:
+ app.config.setdefault(k, v)
+
+ backend = app.config['COMPRESS_CACHE_BACKEND']
+ self.cache = backend() if backend else None
+ self.cache_key = app.config['COMPRESS_CACHE_KEY']
+
+ if app.config['COMPRESS_MIMETYPES']:
+ app.after_request(self.after_request)
+
+ def after_request(self, response):
+ app = self.app or current_app
+ accept_encoding = request.headers.get('Accept-Encoding', '')
+
+ if (response.mimetype not in app.config['COMPRESS_MIMETYPES'] or
+ 'gzip' not in accept_encoding.lower() or
+ not 200 <= response.status_code < 300 or
+ (response.content_length is not None and
+ response.content_length < app.config['COMPRESS_MIN_SIZE']) or
+ 'Content-Encoding' in response.headers):
+ return response
+
+ response.direct_passthrough = False
+
+ if self.cache:
+ key = self.cache_key(response)
+ gzip_content = self.cache.get(key) or self.compress(app, response)
+ self.cache.set(key, gzip_content)
+ else:
+ gzip_content = self.compress(app, response)
+
+ response.set_data(gzip_content)
+
+ response.headers['Content-Encoding'] = 'gzip'
+ response.headers['Content-Length'] = response.content_length
+
+ vary = response.headers.get('Vary')
+ if vary:
+ if 'accept-encoding' not in vary.lower():
+ response.headers['Vary'] = '{}, Accept-Encoding'.format(vary)
+ else:
+ response.headers['Vary'] = 'Accept-Encoding'
+
+ return response
+
+ def compress(self, app, response):
+ gzip_buffer = BytesIO()
+ with GzipFile(mode='wb',
+ compresslevel=app.config['COMPRESS_LEVEL'],
+ fileobj=gzip_buffer) as gzip_file:
+ gzip_file.write(response.get_data())
+ return gzip_buffer.getvalue()
diff --git a/setup.cfg b/setup.cfg
new file mode 100644
index 0000000..861a9f5
--- /dev/null
+++ b/setup.cfg
@@ -0,0 +1,5 @@
+[egg_info]
+tag_build =
+tag_date = 0
+tag_svn_revision = 0
+
diff --git a/setup.py b/setup.py
new file mode 100644
index 0000000..9e82ee4
--- /dev/null
+++ b/setup.py
@@ -0,0 +1,42 @@
+"""
+Flask-Compress
+------------
+
+Compress responses in your Flask app with gzip..
+"""
+
+from setuptools import setup
+
+setup(
+ name='Flask-Compress',
+ version='1.3.1',
+ url='https://github.com/wichitacode/flask-compress',
+ license='MIT',
+ author='William Fagan',
+ author_email='will at wichitacode.com',
+ description='Compress responses in your Flask app with gzip.',
+ long_description=__doc__,
+ py_modules=['flask_compress'],
+ zip_safe=False,
+ include_package_data=True,
+ platforms='any',
+ install_requires=[
+ 'Flask'
+ ],
+ test_suite='tests',
+ classifiers=[
+ 'Environment :: Web Environment',
+ 'Intended Audience :: Developers',
+ 'License :: OSI Approved :: MIT License',
+ '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.3',
+ 'Programming Language :: Python :: 3.4',
+ 'Programming Language :: Python :: 3.5',
+ 'Topic :: Internet :: WWW/HTTP :: Dynamic Content',
+ 'Topic :: Software Development :: Libraries :: Python Modules'
+ ]
+)
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/flask-compress.git
More information about the Python-modules-commits
mailing list