Installation and Getting Started

Pythons: Python 3

Platforms: All

PyPI package name: gulpy

Installation

Installation:

pip install -U gulpy

Creating Tasks:

Create a file in your project folder called gul.py And write this in the file:

from gulpy import Task

@Task('Task1')
def task():
    print('Running')

In terminal call gulpy Task1 This will run the task Task1 and prints ‘Running’

Programmatically run task:

If you wanna run a task or a series of tasks programmatically:

from gulpy import Task, run_task

@Task('Task1')
def task():
    print('Running')

@Task('Task2')
def task2():
    print('Running Task2')

run_task('Task1', 'Task2')

Parallel task execution:

To run parallel tasks:

from gulpy import Task, run_task

@Task('Task1')
def task():
    print('Running')

@Task('Task2')
def task2():
    print('Running Task2')

@Task('Task3')
def task3():
    print('Running Task3')

run_task('Task1', ['Task2', 'Task3'], 'Task1')

This will run Task1 and only after it finishes that Task2 and Task3 will run in parallel, and only after Task2 and Task3 finishes that Task1 will run again.

In short, every task that’s be passed in a list will be executed in parallel.

Streaming:

In Gulpy you can stream various files and treat it in pipes, that are functions or classes:

from gulpy import Task, Stream, Concat

@Task('Concat')
def task():
    s = Stream()
    s.src(['file1', 'file2'])\
     .pipe(Concat('concatenated'))\
     .dest('./dist')
    return s

Executing this task will occours the following: the Stream will get file1 and file2 streams, send to Concat pipe, Concat will concatenate its contents into concatenated file, and write concatenated into ./dist folder.

If you want to only copy files to another folder:

from gulpy import Task, Stream

@Task('Concat')
def task():
    s = Stream()
    s.src(['file1', 'file2'])\
     .dest('./dist')
    return s

This will copy file1 and file2 to ./dist folder.

Stream support shift operators too:

from gulpy import Task, Stream, Concat

@Task('Concat')
def task():
    s = Stream()
    s << 'file1' << 'file2' # Maybe s << ['file1', 'file2'] too
    s << Concat('concatenated')
    s >> './dist'
    return s

Logging:

To log using gulpy internal format:

from gulpy import Task, log, ok, warn, fail

@Task('Task1')
def task():
    print('Running')
    log('Task1', 'Running')
    ok('Task1', 'Running')
    warn('Task1', 'Running')
    fail('Task1', 'Running')