Skip to main content

Idempotent and minimal python library for rapid scripting.

Project description


Idempotent and minimal python 3 library for rapid scripting. Provide support for creating file, adding data to them, patching and so on.


(Ba)sh scripting is very easy to setup. So we end up using it all the time for simple procedural script.

Firing up python for a simple task seems too much but… what if a library will not only simplify scripting but offer some feature out of the box?

Sometimes is it useful to have idempotent script, like Ansible and Saltstack teach us.

runif enable an idempotent, functional programming-way.


  • No dependency: it works with python library out of the box

  • Python logging integration: debug, info level are tuned to provide you the right amount of information

  • Battle tested on complex scenarios


I have the need for a idempotent script for a complex set of migration procedures. Bash was a pain. Java was an overkill so runif popped out.

Try the examples running them from the root directory

The run() function is very handy to fire direct command, like running git pull or so on (as in a bash script)

Note: runif it is NOT a replacement for Gradle, GNU Make, Maven, etc.

Launch example

Install the package with > python install

Here an example of what happen if you run twice the same script:

$  python examples/
[INFO] demo ===> step1
[INFO] demo/demofile.txt ===> step2
[INFO] demo/demofile2.c ===> step2
[INFO] demo/demofile.txt ===> Step3
[INFO] demo/demofile.txt ===> <lambda>
demo/demofile.txt present!
[INFO] demo\demofile2.c ===> <lambda>
** demo\demofile2.c

$  python examples/
[INFO] demo/demofile.txt ===> <lambda>
demo/demofile.txt present!
[INFO] demo\demofile2.c ===> <lambda>
** demo\demofile2.c

Unstable interfaces / Dev notes

run_each               is still unstable
run_if_modified        is brand new and not tested on a huge set of test cases. it is NOT thread safe

See ./ for the last modification


Install py.test with

pip install pytest

run with PYTHONPATH=. pytest

The PYTHONPATH variable is used to ensure you are using the current version and not another possibly installed one on your env

See for usage examples


v1.0.4 - June Stable release v0.0.x - May 2020 First public release

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

runif-0.0.3.tar.gz (5.5 kB view hashes)

Uploaded source

Built Distribution

runif-0.0.3-py3-none-any.whl (6.0 kB view hashes)

Uploaded py3

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