Skip to main content
webdepcompress
~~~~~~~~~~~~~~

This package implements a simple framework-independent system for web
dependency compression. With the help of various compressors it
compresses JavaScript and CSS if necessary and allows a fallback if
the files are used uncompressed (developer mode).

This package provides a naive, whitespace removing compressor for
CSS and JavaScript but a powerful, yuicompressor based compressing
algorithm will be available from the pypi that is used automatically
if available. This makes it possible to ship this package with an
application for production usage and precompressed files without
having to install yuicompressor and Java.

Declaring Packs
---------------

Add a file to your package (for example packs.py) with the following
contents::

from webdepcompress.manager import PackManager

mgr = PackManager(os.path.join(os.path.dirname(__file__), 'static'),
lambda fn, t: '/static/' + fn)

mgr.add_pack('default', ['style.css', 'print.css',
'jquery.js', 'application.js'])

First you have to create a pack manager. That manager keeps a registry
of all your packs, because you can have multiple of those. The first
argument to it is the path to where the files are stored. Most of the
time it makes sure to point to somewhere inside your package. That path
is used as base path for the source files and it will also be used as
a path for the compressed files when created.

The second argument to the manager is a function that returns the URL
to the file. In this case it assumes that the files are available
as ``/static/filename.css`` and so forth.

When you add a pack you call `PackManager.add_pack` with the
name of the pack as first argument and the files it should pack together
as the second.

Using Packs
-----------

Packs provide a simple interface:

>>> mgr['default']
<Pack 'default'>
>>> print mgr['default']
<link rel="stylesheet" type="text/css" href="/static/style.css">
<link rel="stylesheet" type="text/css" href="/static/print.css">
<script type="text/javascript" src="/static/jquery.js"></script>
<script type="text/javascript" src="/static/application.js"></script>

As you can see, the `__str__` and `__unicode__` special methods of a
pack return the HTML needed to include the files specified. Please note
that it will print out the stylesheets before the scripts by default
and that scripts and files are kept in the order specified but grouped
by type. It also outputs HTML4/HTML5 by default and not XHTML. This
can be changed.

Packs can be compressed by calling the `PackManager.compress`
method on the manager or of a pack:

>>> mgr.compress()

That can take a while, after that you can see that the manager spits
out the compressed includes:

>>> print mgr['default']
<link rel="stylesheet" type="text/css" href="/static/default.compressed.css">
<script type="text/javascript" src="/static/default.compressed.js"></script>

You can pass packs to your template engine easily. The best idea is to
forward the pack as a string or list of strings so that the template
cannot call `compress` on it.

Setuputils Integration
----------------------

If you add a webdepcompress_manager setting to your setup call you
can use the `compress_deps` command from `setup.py`::

setup(
...,
webdepcompress_manager='yourapplication.packs.mgr'
)

Then you can compile the deps from the command line::

$ python setup.py compress_deps

And clean the compressed files again::

$ python setup.py compress_deps --clean


:copyright: (c) 2009 by Armin Ronacher, see AUTHORS for more details.
:license: BSD, see LICENSE for more details.

Metadata

Release files for WebDepCompress 0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for WebDepCompress 0.2
File Size Uploaded Provenance Actions
WebDepCompress-0.2.tar.gz 7.3 kB Without provenance Details for WebDepCompress-0.2.tar.gz

Release files / WebDepCompress-0.2.tar.gz

Download URL WebDepCompress-0.2.tar.gz
Size 7.3 kB
Tags Source
SHA-256 checksum
How to use checksums
4d798cf30a1d5cabe8ae6c730e66a06d516290c1feed92d23874624ff0fe93e6
BLAKE2b-256 checksum
How to use checksums
95cd4fffe000aa0a5d0b3105d7e01dc5598fec40bfe6a15fc9775ff6d2c7a662
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for WebDepCompress 0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page