Skip to main content

Python port of Ruby Rake

Project description

This is as straight of a clone of Rake that I could come up with.

Briefly:

# Trawlfile
@task
def bar():
    print "BAR!"

Does as you might expect:

$ trawl -T
bar
$ trawl bar
** Execute bar
BAR

And with dependencies:

# Trawlfile
@task
def bar():
    print "BAR!"

@task([bar])
def foo():
    print "FOO!"

Also does what you’d expect:

$ trawl -T
bar
foo
$ trawl bar
** Execute bar
BAR!
$ trawl foo
** Execute bar
BAR!
** Execute foo
FOO!

Which is awesome sauce, but what about files?

# Trawlfile
@build("myfile.txt", recreate=False)
def run(task):
    with open(task.name) as out:
        out.write("MUNCTIONAL!")

@build("yup.cfg", ["myfile.txt"])
def more(task):
    with open(task.name) as out:
        with open(task.source) as src:
            out.write(src.read() + "!!!1!")

Will cause “myfile.txt” to be created but not overwritten if it exists. “yup.cfg” will then only be rebuilt when “myfile.txt” changes as determined by the file’s mtime:

$ trawl yup.cfg
** Execute myfile.txt
** Execute yup.cfg
$ trawl yup.cfg
$

The last major bit is in defining rules:

@rule('.o', '.c'):
def compile(task):
    subprocess.check_call(["gcc", "-o", task.name, "-c", task.source])

objects = FileList("*.c").sub(".c$", ".o")
@build("appname", objects)
def link(task):
    subprocess.check_call(["gcc", "-o", task.name] + task.sources)

# Add a helpful handle for running
task("run", ["appname"])

TODO

Some things that need to be done yet:

  • Task descriptions

  • Argument support

  • Test and add methods to FileList

  • Add a function to import tasks programatically

Project details


Download files

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

Source Distribution

Trawl-0.2.0.tar.gz (27.5 kB view details)

Uploaded Source

File details

Details for the file Trawl-0.2.0.tar.gz.

File metadata

  • Download URL: Trawl-0.2.0.tar.gz
  • Upload date:
  • Size: 27.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for Trawl-0.2.0.tar.gz
Algorithm Hash digest
SHA256 e2ddbd156d70edc910fd899d5239b1e286ef2557ebd6e8b520cbe9efcb47ddd4
MD5 d3ab43dd9d553787f28d830fe4023c0a
BLAKE2b-256 ce16be88d43d08ce47eff12a7b2e9c9c7d3731158721d6870461763f238f1d7e

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page