[Python-modules-commits] [flask-compress] 02/11: Import flask-compress_1.3.2.orig.tar.gz
Dominik George
natureshadow-guest at moszumanska.debian.org
Thu Sep 29 09:39:12 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 e64478cc1faad0efb0e20632e3b910dbc70a28a7
Author: Dominik George <nik at naturalnet.de>
Date: Thu Sep 29 11:08:16 2016 +0200
Import flask-compress_1.3.2.orig.tar.gz
---
Flask_Compress.egg-info/PKG-INFO | 13 ++---
Flask_Compress.egg-info/SOURCES.txt | 10 +++-
LICENSE.txt | 20 +++++++
MANIFEST.in | 4 ++
PKG-INFO | 13 ++---
README.md | 78 ++++++++++++++++++++++++++
setup.py | 19 ++-----
tests/__init__.py | 0
tests/static/1.png | Bin 0 -> 239 bytes
tests/templates/large.html | 13 +++++
tests/templates/small.html | 4 ++
tests/test_flask_compress.py | 106 ++++++++++++++++++++++++++++++++++++
12 files changed, 248 insertions(+), 32 deletions(-)
diff --git a/Flask_Compress.egg-info/PKG-INFO b/Flask_Compress.egg-info/PKG-INFO
index d55e890..5dfe8ae 100644
--- a/Flask_Compress.egg-info/PKG-INFO
+++ b/Flask_Compress.egg-info/PKG-INFO
@@ -1,17 +1,12 @@
Metadata-Version: 1.1
Name: Flask-Compress
-Version: 1.3.1
+Version: 1.3.2
Summary: Compress responses in your Flask app with gzip.
-Home-page: https://github.com/wichitacode/flask-compress
+Home-page: https://libwilliam.github.io/flask-compress/
Author: William Fagan
-Author-email: will at wichitacode.com
+Author-email: libwilliam at gmail.com
License: MIT
-Description:
- Flask-Compress
- ------------
-
- Compress responses in your Flask app with gzip..
-
+Description: Full documentation can be found on the Flask-Compress "Home Page".
Platform: any
Classifier: Environment :: Web Environment
Classifier: Intended Audience :: Developers
diff --git a/Flask_Compress.egg-info/SOURCES.txt b/Flask_Compress.egg-info/SOURCES.txt
index a76d097..a6573ba 100644
--- a/Flask_Compress.egg-info/SOURCES.txt
+++ b/Flask_Compress.egg-info/SOURCES.txt
@@ -1,3 +1,6 @@
+LICENSE.txt
+MANIFEST.in
+README.md
flask_compress.py
setup.py
Flask_Compress.egg-info/PKG-INFO
@@ -5,4 +8,9 @@ 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
+Flask_Compress.egg-info/top_level.txt
+tests/__init__.py
+tests/test_flask_compress.py
+tests/static/1.png
+tests/templates/large.html
+tests/templates/small.html
\ No newline at end of file
diff --git a/LICENSE.txt b/LICENSE.txt
new file mode 100644
index 0000000..d07d183
--- /dev/null
+++ b/LICENSE.txt
@@ -0,0 +1,20 @@
+The MIT License (MIT)
+
+Copyright (c) 2013-2016 William Fagan
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal in
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+the Software, and to permit persons to whom the Software is furnished to do so,
+subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/MANIFEST.in b/MANIFEST.in
new file mode 100644
index 0000000..f5458f8
--- /dev/null
+++ b/MANIFEST.in
@@ -0,0 +1,4 @@
+include LICENSE.txt
+include README.md
+recursive-include tests *
+recursive-exclude tests *.pyc
diff --git a/PKG-INFO b/PKG-INFO
index d55e890..5dfe8ae 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,17 +1,12 @@
Metadata-Version: 1.1
Name: Flask-Compress
-Version: 1.3.1
+Version: 1.3.2
Summary: Compress responses in your Flask app with gzip.
-Home-page: https://github.com/wichitacode/flask-compress
+Home-page: https://libwilliam.github.io/flask-compress/
Author: William Fagan
-Author-email: will at wichitacode.com
+Author-email: libwilliam at gmail.com
License: MIT
-Description:
- Flask-Compress
- ------------
-
- Compress responses in your Flask app with gzip..
-
+Description: Full documentation can be found on the Flask-Compress "Home Page".
Platform: any
Classifier: Environment :: Web Environment
Classifier: Intended Audience :: Developers
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..0396c57
--- /dev/null
+++ b/README.md
@@ -0,0 +1,78 @@
+# Flask-Compress
+
+[](https://pypi.python.org/pypi/Flask-Compress)
+[](https://travis-ci.org/libwilliam/flask-compress)
+[](https://coveralls.io/github/libwilliam/flask-compress)
+[](https://github.com/libwilliam/flask-compress/blob/master/LICENSE.txt)
+
+Flask-Compress allows you to easily compress your [Flask](http://flask.pocoo.org/) application's responses with gzip.
+
+The preferred solution is to have a server (like [Nginx](http://wiki.nginx.org/Main)) automatically compress the static files for you. If you don't have that option Flask-Compress will solve the problem for you.
+
+
+## How it works
+
+Flask-Compress both adds the various headers required for a compressed response and gzips the response data. This makes serving gzip compressed static files extremely easy.
+
+Internally, every time a request is made the extension will check if it matches one of the compressible MIME types and will automatically attach the appropriate headers.
+
+
+## Installation
+
+If you use pip then installation is simply:
+
+```shell
+$ pip install flask-compress
+```
+
+or, if you want the latest github version:
+
+```shell
+$ pip install git+git://github.com/libwilliam/flask-compress.git
+```
+
+You can also install Flask-Compress via Easy Install:
+
+```shell
+$ easy_install flask-compress
+```
+
+
+## Using Flask-Compress
+
+Flask-Compress is incredibly simple to use. In order to start gzip'ing your Flask application's assets, the first thing to do is let Flask-Compress know about your [`flask.Flask`](http://flask.pocoo.org/docs/latest/api/#flask.Flask) application object.
+
+```python
+from flask import Flask
+from flask_compress import Compress
+
+app = Flask(__name__)
+Compress(app)
+```
+
+In many cases, however, one cannot expect a Flask instance to be ready at import time, and a common pattern is to return a Flask instance from within a function only after other configuration details have been taken care of. In these cases, Flask-Compress provides a simple function, `flask_compress.Compress.init_app`, which takes your application as an argument.
+
+```python
+from flask import Flask
+from flask_compress import Compress
+
+compress = Compress()
+
+def start_app():
+ app = Flask(__name__)
+ compress.init_app(app)
+ return app
+```
+
+In terms of automatically compressing your assets using gzip, passing your [`flask.Flask`](http://flask.pocoo.org/docs/latest/api/#flask.Flask) object to the `flask_compress.Compress` object is all that needs to be done.
+
+
+## Options
+
+Within your Flask application's settings you can provide the following settings to control the behavior of Flask-Compress. None of the settings are required.
+
+| Option | Description | Default |
+| ------ | ----------- | ------- |
+| `COMPRESS_MIMETYPES` | Set the list of mimetypes to compress here. | `[`<br>`'text/html',`<br>`'text/css',`<br>`'text/xml',`<br>`'application/json',`<br>`'application/javascript'`<br>`]` |
+| `COMPRESS_LEVEL` | Specifies the gzip compression level. | `6` |
+| `COMPRESS_MIN_SIZE` | Specifies the minimum file size threshold for compressing files. | `500` |
diff --git a/setup.py b/setup.py
index 9e82ee4..b186cba 100644
--- a/setup.py
+++ b/setup.py
@@ -1,21 +1,14 @@
-"""
-Flask-Compress
-------------
+import setuptools
-Compress responses in your Flask app with gzip..
-"""
-
-from setuptools import setup
-
-setup(
+setuptools.setup(
name='Flask-Compress',
- version='1.3.1',
- url='https://github.com/wichitacode/flask-compress',
+ version='1.3.2',
+ url='https://libwilliam.github.io/flask-compress/',
license='MIT',
author='William Fagan',
- author_email='will at wichitacode.com',
+ author_email='libwilliam at gmail.com',
description='Compress responses in your Flask app with gzip.',
- long_description=__doc__,
+ long_description='Full documentation can be found on the Flask-Compress "Home Page".',
py_modules=['flask_compress'],
zip_safe=False,
include_package_data=True,
diff --git a/tests/__init__.py b/tests/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/tests/static/1.png b/tests/static/1.png
new file mode 100644
index 0000000..b5dcd56
Binary files /dev/null and b/tests/static/1.png differ
diff --git a/tests/templates/large.html b/tests/templates/large.html
new file mode 100644
index 0000000..5940b55
--- /dev/null
+++ b/tests/templates/large.html
@@ -0,0 +1,13 @@
+<!DOCTYPE HTML>
+<html>
+<body>
+<p>
+Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
+tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
+quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
+consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
+cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
+proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
+</p>
+</body>
+</html>
diff --git a/tests/templates/small.html b/tests/templates/small.html
new file mode 100644
index 0000000..9a9a6d6
--- /dev/null
+++ b/tests/templates/small.html
@@ -0,0 +1,4 @@
+<!DOCTYPE HTML>
+<html>
+<body></body>
+</html>
diff --git a/tests/test_flask_compress.py b/tests/test_flask_compress.py
new file mode 100644
index 0000000..cbf1f68
--- /dev/null
+++ b/tests/test_flask_compress.py
@@ -0,0 +1,106 @@
+import unittest
+import os
+
+from flask import Flask, render_template
+
+from flask_compress import Compress
+
+
+class DefaultsTest(unittest.TestCase):
+ def setUp(self):
+ self.app = Flask(__name__)
+ self.app.testing = True
+
+ Compress(self.app)
+
+ def test_mimetypes_default(self):
+ """ Tests COMPRESS_MIMETYPES default value is correctly set. """
+ defaults = ['text/html', 'text/css', 'text/xml', 'application/json',
+ 'application/javascript']
+ self.assertEqual(self.app.config['COMPRESS_MIMETYPES'], defaults)
+
+ def test_level_default(self):
+ """ Tests COMPRESS_LEVEL default value is correctly set. """
+ self.assertEqual(self.app.config['COMPRESS_LEVEL'], 6)
+
+ def test_min_size_default(self):
+ """ Tests COMPRESS_MIN_SIZE default value is correctly set. """
+ self.assertEqual(self.app.config['COMPRESS_MIN_SIZE'], 500)
+
+
+class InitTests(unittest.TestCase):
+ def setUp(self):
+ self.app = Flask(__name__)
+ self.app.testing = True
+
+ def test_constructor_init(self):
+ Compress(self.app)
+
+ def test_delayed_init(self):
+ compress = Compress()
+ compress.init_app(self.app)
+
+
+class UrlTests(unittest.TestCase):
+ def setUp(self):
+ self.app = Flask(__name__)
+ self.app.testing = True
+
+ small_path = os.path.join(os.getcwd(), 'tests', 'templates',
+ 'small.html')
+
+ large_path = os.path.join(os.getcwd(), 'tests', 'templates',
+ 'large.html')
+
+ self.small_size = os.path.getsize(small_path) - 1
+ self.large_size = os.path.getsize(large_path) - 1
+
+ Compress(self.app)
+
+ @self.app.route('/small/')
+ def small():
+ return render_template('small.html')
+
+ @self.app.route('/large/')
+ def large():
+ return render_template('large.html')
+
+ def client_get(self, ufs):
+ client = self.app.test_client()
+ response = client.get(ufs, headers=[('Accept-Encoding', 'gzip')])
+ self.assertEqual(response.status_code, 200)
+ return response
+
+ def test_compress_level(self):
+ """ Tests COMPRESS_LEVEL correctly affects response data. """
+ self.app.config['COMPRESS_LEVEL'] = 1
+ response = self.client_get('/large/')
+ response1_size = len(response.data)
+
+ self.app.config['COMPRESS_LEVEL'] = 6
+ response = self.client_get('/large/')
+ response6_size = len(response.data)
+
+ self.assertNotEqual(response1_size, response6_size)
+
+ def test_compress_min_size(self):
+ """ Tests COMPRESS_MIN_SIZE correctly affects response data. """
+ response = self.client_get('/small/')
+ self.assertEqual(self.small_size, len(response.data))
+
+ response = self.client_get('/large/')
+ self.assertNotEqual(self.large_size, len(response.data))
+
+ def test_mimetype_mismatch(self):
+ """ Tests if mimetype not in COMPRESS_MIMETYPES. """
+ response = self.client_get('/static/1.png')
+ self.assertEqual(response.mimetype, 'image/png')
+
+ def test_content_length_options(self):
+ client = self.app.test_client()
+ headers = [('Accept-Encoding', 'gzip')]
+ response = client.options('/small/', headers=headers)
+ self.assertEqual(response.status_code, 200)
+
+if __name__ == '__main__':
+ unittest.main()
--
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