Skip to main content

Task executioner similar to gulp for Python

Project description

Task manager similar to gulp for the processing of static files.

Working with Flask-Gulp

Setting up Flask-Gulp is quite easy. Here is an example:

from flask_gulp import Static

static = Static(app)

This allows to add tasks with the task decorator:

def coffee_task():

The src function is provided as a global to the task function scope along with all the extensions.

As you can see, the workflow is similar to gulp.

The js and css functions

Inspired by Flask-Funnel, the js and css functions are provided to the application context in order to generate the corresponding links:

    <!-- ... -->
    {{ css('less') }}
   <!-- ... -->
   {{ js('coffee', 'cjsx') }}

Each one receives multiple tasks names and generate the links to the generated files.


Flask-Gulp comes shiped with four extensions, coffee, cjsx, less and dest. The first ones accept an executable setting, which holds the corresponding binary location, the default is to call it directly.

To add new extensions use the decorator provided with Flask-Gulp:

from flask_gulp.extensions import extension

def cjsx(resources):
    command = ['cjsx', '-c', '-s']
    bare = cjsx.settings.get('bare')
    if bare:
        command += ['-b']
    for filename, data in resources:
        process = subprocess.Popen(command,
        out, err = process.communicate(data)
        if process.returncode:
            yield None, err
            dest = replaceExt(filename, '.js')
            yield dest, out

Each extension receive an iterable object which yields the name and content of each file. The function must return an iterable object with the same format for resulting files. Returning the new file name as None will be interpreted as an error.

The variable <function_name>.settings holds a dictionary with the keywords provided in the extension initialization, for instance cjsx(bare=True).

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for Flask-Gulp, version 0.3.0
Filename, size File type Python version Upload date Hashes
Filename, size Flask-Gulp-0.3.0.tar.gz (5.8 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page