Skip to main content

Runif

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

Why?

(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.

FEATURES

  • 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

HISTORY

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 setup.py install

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

$  python examples/stepByStep.py
[INFO] runif.py.run_if_missed demo ===> step1
[INFO] runif.py.run_if_missed demo/demofile.txt ===> step2
[INFO] runif.py.run_if_missed demo/demofile2.c ===> step2
[INFO] runif.py.run_if_unmarked demo/demofile.txt ===> Step3
[INFO] runif.py.run_if_present demo/demofile.txt ===> <lambda>
demo/demofile.txt present!
[INFO] runif.py.run_each demo\demofile2.c ===> <lambda>
** demo\demofile2.c

$  python examples/stepByStep.py
[INFO] runif.py.run_if_present demo/demofile.txt ===> <lambda>
demo/demofile.txt present!
[INFO] runif.py.run_each 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 ./CHANGELOG.md for the last modification

Tests

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 https://docs.pytest.org/en/latest/example/index.html for usage examples

RELEASE HISTORY

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

Metadata

Release files for runif 0.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for runif 0.0.3
File Size Uploaded
runif-0.0.3.tar.gz 5.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for runif 0.0.3
File Interpreter ABI Platform
runif-0.0.3-py3-none-any.whl Python 3 none any Details

Total release size: 11.5 kB

Release files / runif-0.0.3.tar.gz

Download URL runif-0.0.3.tar.gz
Size 5.5 kB
Tags Source
SHA-256 checksum
How to use checksums
1267ec49ba9f400a9c4d8991915e054d3e001b2340fee182cdd5b12007afc603
BLAKE2b-256 checksum
How to use checksums
d090b08ac50de5fc5ab34e609f7a061e5d28d7afe08802e8b4e6dd1d4bdbcefa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.20.1 setuptools/47.1.0 requests-toolbelt/0.8.0 tqdm/4.42.1 CPython/3.7.0

Release files / runif-0.0.3-py3-none-any.whl

Download URL runif-0.0.3-py3-none-any.whl
Size 6.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
858c20fed0ddf9491c038e5c1fdbba4620dee17255097027ab6fc42928c1bf47
BLAKE2b-256 checksum
How to use checksums
752d88737b437d06d3e88f4201ec1d9a77c14e67adcec95b02628b416358c2d6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.20.1 setuptools/47.1.0 requests-toolbelt/0.8.0 tqdm/4.42.1 CPython/3.7.0

Release history Release notifications | RSS feed

This release

0.0.3 This release

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page