跳转到主要内容

构建工具,可选择性在指定条件下运行构建命令块

项目描述

HitchTrigger是一个自包含的构建工具,旨在在满足需要重新构建的条件时触发构建命令块。

条件可以是以下任一或多个的组合

  • 文件(例如源文件)已更改。

  • 指定的(构建)目录不存在。

  • 已过去一段时间。

  • 被监视的变量已更改其值。

  • 在上次运行命令时发生了异常(默认情况下始终为是)。

从PyPI安装

$ hitch install hitchtrigger

使用

import hitchtrigger

monitor = hitchtrigger.Monitor(
    "/path/to/project.watch"
    #override=["virtualenv", ],
)

# Will run in the following cases:
#
## The command block has never been run before.
## An exception was triggered within the context manager on the previous run.
## venv directory is non-existent.
## A period of 7 days has elapsed
## A previous block named 'previousblock' was run.
## Either requirements.txt or dev_requirements.txt have been modified (file modification dates are monitored).
## Var "v=1" is changed (e.g. to "v=2").
## The line 'override=["virtualenv", ]' is uncommented.

with monitor.block(
    "virtualenv",
    monitor.nonexistent("venv") | monitor.not_run_since(days=7) | monitor.was_run("previousblock")
    monitor.modified(["requirements.txt", "dev_requirements.txt"]) | monitor.var(v=1)
).context() as trigger:
    if trigger:
        print(trigger.why)  # Prints out reason for running

        Path("venv").rmtree(ignore_errors=True)
        virtualenv("venv").run()
        pip("install", "-r", "requirements.txt").run()
        pip("freeze").stdout(Path("freeze.txt")).run()
        pip("install", "dev_requirements.txt").run()

项目详情


下载文件

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

源分布

hitchtrigger-0.2.tar.gz (5.7 kB 查看哈希值)

上传时间 源代码

由以下支持