Skip to main content

A pythonic scripting environment

Project description

Greenland: Pythonic Infrastructure
==================================

Greenland is a package that lowers the entry barrier to implementing
tasks that are often more typically done in shell scripts.

Source code is available from the `git repository`_. See
`CHANGELOG.rst`_ for changes and release history.

.. _CHANGELOG.rst: file:CHANGELOG.rst
.. _git repository: https://github.com/m-e-leypold/greenland4


The example given below showcases what Greenland purports to solve: To
provide easily composable building blocks for tasks that occur in
areas commonly reserved to shell scripting.

Greenland currently is not complete in this respect and will not be
for some time. The author regardless wishes users much fun and
success, in case they decide to use Greenland.


An example
----------

Assume, you're tasked with writing a utility for cleaning up directory
trees. It should allow th user to provide a pattern and a directory
path, then all files matching this pattern are deleted in the
referenced directory tree, like this:

.. code-block:: console

$> rm-in-tree '*~' my/data

The obvious and probably cheapest solution -- if you're fluent in bourne shell and shell
utilities, is, to build a shell script around a line like

.. code-block:: console

find "$ROOT" -name "$PATTERN" -print0 | xargs -0 rm -f

It still leaves you with the burden to do some command line parsing in
shell script -- which is not overly heavy in this case so far, but
spins quickly out of control when the client wants more features, like:

- A configuration for the default pattern in the users home directory.
- A verbose option to log the parameters given and the files deleted.
- A dry-run option to preview what will be deleted.

Sooner or later you'll wish you could do that in a real programming
language where not all data types are strings that are pasted together
by arcane expansion rules.

So, this would be a case to use in example Python. While handling data
in a real programming language is clearly less flakey than in the
shell, parsing command lines often still constitutes a major burden,
even with helpers already in the standard libraries. This is also true
for Python. And finding files in directory tree is also a bit of an
effort.

So what the author of Greenland would have liked is to have in Python
all the building blocks that one normally has available in shell
programming, but where possible, better (like in example the command
line parsing, which IMHO turns out to be a mess in practically all
appoaches I've seen so far).

So, what what the author of Greenland would have liked to have, is a
declarative way of specifying the command line arguments, like in

.. literalinclude:: examples/rm-in-tree/rm-in-tree
:language: python
:start-after: [manual] begin usage
:end-before: [manual] end usage
:dedent: 4

And the author of Greenland would have like to have a simple way to
iterate over all the files in a directory tree with a specified
property, like in

.. literalinclude:: examples/rm-in-tree/rm-in-tree
:language: python
:start-after: [manual] begin find_files
:end-before: [manual] end find_files
:dedent: 8

You can also see, how the *dry-run* option has become an object member
variable here. This is done automagically by the Greenland algorithms,
except if you specify otherwise.

LICENSE
-------

Greenland is free Software and licensed by the terms of the Gnu Public
License, version 3 or later (GPL3).

For details and the full license text see the file LICENSE.txt at the
top of the source tree.




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

greenland-0.0.5.tar.gz (22.9 kB view details)

Uploaded Source

Built Distribution

greenland-0.0.5-py3-none-any.whl (50.7 kB view details)

Uploaded Python 3

File details

Details for the file greenland-0.0.5.tar.gz.

File metadata

  • Download URL: greenland-0.0.5.tar.gz
  • Upload date:
  • Size: 22.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.20.1 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.7.0

File hashes

Hashes for greenland-0.0.5.tar.gz
Algorithm Hash digest
SHA256 73bb2250e8d4d30a602fc2c4b6c5a3998f1dc5db6d02c653019bb5075cae9260
MD5 6c4d6d5762a2a0e5ced8085cf5264fc2
BLAKE2b-256 afbdbac7c67bd50b1ecdfcc16d47cf34aec21be280c618c15ff0cabcb8b441d2

See more details on using hashes here.

File details

Details for the file greenland-0.0.5-py3-none-any.whl.

File metadata

  • Download URL: greenland-0.0.5-py3-none-any.whl
  • Upload date:
  • Size: 50.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.20.1 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.7.0

File hashes

Hashes for greenland-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 d8a3db6fcca55eda5e2b455c985f333bcee734386f97cde503d883a4160c8ac1
MD5 0164905a4e51084d0cbeb1839b4b38ea
BLAKE2b-256 e25f3850a6734463f8fda2db86d146d802765f74cd8f8dfb7263eb9148d684c6

See more details on using hashes here.

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