expirecache
========
Python utilities and middleware for neuron.js
expirecache analyzes the dependencies from user defined facades according
to the dependency tree, and outputs ``<script>`` tags and configurations
for `neuron.js <https://github.com/kaelzhang/neuron>`__
The dependency tree can be generated by
`neuron-package-dependency <https://github.com/kaelzhang/neuron-package-dependency>`__
Install
-------
.. code:: sh
$ pip install expirecache
Usage
-----
.. code:: py
from expirecache import Neuron
n = Neuron(
dependency_tree=dependency_tree, # must defined
resolve=resolve,
version=version,
cache=cache,
debug=False)
``expirecache`` could be used either in template file or your python
controller.
`Here <./sample/sample-jinja.html>`__ is a sample Jinja2 template file.
- **dependency\_tree** ``dict`` the ``json.loads()``\ ed dependency
tree
- **resolve** ``function(id)=`` (optional) implements your own custom
resolver. ``resolve`` accepts one parameter ``id`` which can be
either a ``str`` of module id or a ``list`` of module ids. If a
``str`` is passed in, the method should returns the resolved absolute
url of the module id. If ``id`` is a ``list``, an url of comboed
script files should be returned.
- **debug** ``function|bool=False`` tells expirecache whether should
switch on debug mode. When on debug mode, no javascript files of
dependencies will be preloaded, and the output will not be
compressed.
- if ``debug`` is callable, expirecache will use the return value of
method ``debug``
- if ``debug`` is a boolean value, and ``debug`` is true, the debug
mode will be on.
- **cache** ``dict=None`` if ``cache`` is defined, it should contains 3
methods:
- ``cache.has(key)`` returns ``bool``
- ``cache.get(key)`` looks up and returns the cached value by key
- ``cache.set(key, value)`` sets the value by key
- **version** ``str`` only works if ``cache`` is defined. expirecache will
uses ``version`` to generate the key to cache the output result
module id
^^^^^^^^^
.. code:: js
<name>@<version><path> # for example: 'jquery@2.0.0/jquery.js'
n.facade(entry, data=None)
^^^^^^^^^^^^^^^^^^^^^^^^^^
- **entry** ``str`` id of the entry module
Registers a facade entry with ``data``. expirecache will
Returns ``''``\ (empty string), so you can use this method in python
template
n.combo(id...)
^^^^^^^^^^^^^^
Returns ``''``
n.css(id)
^^^^^^^^^
Returns ``''``
n.output()
^^^^^^^^^^
Returns ``str``
n.output\_css()
^^^^^^^^^^^^^^^
Returns ``str``
License
-------
MIT
.. |Build Status| image:: https://travis-ci.org/kaelzhang/python-expirecache.svg?branch=master
:target: https://travis-ci.org/kaelzhang/python-expirecache
Metadata
Release files for expirecache 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| expirecache-1.0.0.tar.gz | 1.5 kB | Without provenance | Details |
Release files / expirecache-1.0.0.tar.gz
| Download URL | expirecache-1.0.0.tar.gz |
|---|---|
| Size | 1.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4d2d6ef6c27cfbf9a4df089fae560227e5bcd2b5c90f4acc2bcf7ee66b03768b
|
|
BLAKE2b-256 checksum How to use checksums |
cd309406d7e187b13758b6997d0d2d5a43ccc74ad759123dd83e228785bd0eda
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for expirecache 1.0.0
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.