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.

Sometimes is it useful to have idempotent script, like Ansible and Saltstack teach use, this script should only do an action if needed.

I have this need for a complex set of migration procedures. I was unable to do it bash It was an overkilll using Java

So runif popped out

Try the examples running them from the root directory

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

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

v0.0.1 - 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.2.tar.gz (5.0 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.2-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: runif-0.0.2.tar.gz
  • Upload date:
  • Size: 5.0 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.2.tar.gz
Algorithm Hash digest
SHA256 43321dc1858f2846bc241b29c247d2efe8d8e5baa5531198efcadd6b7b74e515
MD5 5967ce47303bd57d96fcb2fdacb65114
BLAKE2b-256 fdd590e0377495b42c0dbda95b1da378eed35ec33d2810df054e89a07065ac22

See more details on using hashes here.

File details

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

File metadata

  • Download URL: runif-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 5.3 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 fe7cd9601d7065dd76f851f52adc90590028524d0f54da520867767a87f4b03e
MD5 7570c8b068ea344d0c40e588cb225de2
BLAKE2b-256 98783545825b3aaef22fc1e20737c89340e8ff88dfa0b73a5472a812a0bbe8df

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