How to use the whitenoise.compress.Compressor function in whitenoise

To help you get started, we’ve selected a few whitenoise examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github evansd / whitenoise / tests / test_compress.py View on Github external
def test_compress():
    compressor = Compressor(use_brotli=False, use_gzip=False)
    assert [] == list(compressor.compress("tests/test_files/static/styles.css"))
github evansd / whitenoise / tests / test_compress.py View on Github external
def test_compressed_effectively_no_orig_size():
    compressor = Compressor(quiet=True)
    assert not compressor.is_compressed_effectively(
        "test_encoding", "test_path", 0, "test_data"
    )
github evansd / whitenoise / tests / test_compress.py View on Github external
def test_with_custom_extensions():
    compressor = Compressor(extensions=["jpg"], quiet=True)
    assert compressor.extension_re == re.compile(r"\.(jpg)$", re.IGNORECASE)
github evansd / whitenoise / tests / test_compress.py View on Github external
def test_custom_log():
    compressor = Compressor(log="test")
    assert compressor.log == "test"
github evansd / whitenoise / whitenoise / storage.py View on Github external
def create_compressor(self, **kwargs):
        return Compressor(**kwargs)
github evansd / whitenoise / whitenoise / compress.py View on Github external
def main(root, **kwargs):
    compressor = Compressor(**kwargs)
    for dirpath, dirs, files in os.walk(root):
        for filename in files:
            if compressor.should_compress(filename):
                path = os.path.join(dirpath, filename)
                for compressed in compressor.compress(path):
                    pass
github evansd / whitenoise / whitenoise / compress.py View on Github external
help="Don't produce gzip '.gz' files",
        action="store_false",
        dest="use_gzip",
    )
    parser.add_argument(
        "--no-brotli",
        help="Don't produce brotli '.br' files",
        action="store_false",
        dest="use_brotli",
    )
    parser.add_argument("root", help="Path root from which to search for files")
    parser.add_argument(
        "extensions",
        nargs="*",
        help="File extensions to exclude from compression "
        "(default: {})".format(", ".join(Compressor.SKIP_COMPRESS_EXTENSIONS)),
        default=Compressor.SKIP_COMPRESS_EXTENSIONS,
    )
    args = parser.parse_args()
    main(**vars(args))