Skip to main content

Idempotent and minimal python library for rapid scripting.

Project description

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

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 details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

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

Uploaded Python 3

File details

Details for the file runif-0.0.3.tar.gz.

File metadata

  • Download URL: runif-0.0.3.tar.gz
  • Upload date:
  • Size: 5.5 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for runif-0.0.3.tar.gz
Algorithm Hash digest
SHA256 1267ec49ba9f400a9c4d8991915e054d3e001b2340fee182cdd5b12007afc603
MD5 b3b0c6df12cdd12ff8d7b89b7516da3a
BLAKE2b-256 d090b08ac50de5fc5ab34e609f7a061e5d28d7afe08802e8b4e6dd1d4bdbcefa

See more details on using hashes here.

File details

Details for the file runif-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: runif-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 6.0 kB
  • Tags: Python 3
  • Uploaded using 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

File hashes

Hashes for runif-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 858c20fed0ddf9491c038e5c1fdbba4620dee17255097027ab6fc42928c1bf47
MD5 8b4685a551f61f7aae7d777a6e34934d
BLAKE2b-256 752d88737b437d06d3e88f4201ec1d9a77c14e67adcec95b02628b416358c2d6

See more details on using hashes here.

Supported by

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