跳转到主要内容

Ruby Rake的Python端口

项目描述

这是我能够想到的最直接的Rake克隆。

简而言之

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

做你所期望的

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

以及依赖关系

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

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

也做你所期望的

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

这很酷,但文件呢?

# 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!")

将创建“myfile.txt”,如果存在则不会覆盖。然后“yup.cfg”只有在“myfile.txt”更改时(根据文件的mtime确定)才会重新构建

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

最后一项重要工作是定义规则

@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"])

待办事项

还有一些事情需要完成

  • 任务描述

  • 参数支持

  • 测试并向FileList添加方法

  • 添加一个函数以编程方式导入任务

项目详情


下载文件

下载适用于您平台的文件。如果您不确定要选择哪个,请了解有关 安装软件包 的更多信息。

源分发

Trawl-0.2.1.tar.gz (27.6 kB 查看哈希值)

上传时间:

由以下支持

AWSAWS 云计算和安全赞助商 DatadogDatadog 监控 FastlyFastly CDN GoogleGoogle 下载分析 MicrosoftMicrosoft PSF赞助商 PingdomPingdom 监控 SentrySentry 错误记录 StatusPageStatusPage 状态页面