Awk in Python: Incrementing the Release tag

Yesterday, i commented on how you could get Awk like behavior with Python. The more FP oriented reader might notice that they are pretty much Arrows. At this point, you may wonder why i'm doing this in Python if Haskell would be better suited to doing Arrows. Lately, i'm wondering the same thing, and i think it's about time i start programming more in Haskell. I think it would have to be a project i don't actually expect anyone to use.

Today, as a demonstration, i decided to start with something recognizable. Currently, in the Fedora Developer toolchain, we have a number of scripts and tools that do various tasks. Unfortunately, these tools are written in a style very close to shell scripts, which makes it hard to script actions on top of them. One goal of Devshell (among the many), is to have a library of common tasks that can be later scripted or built up upon. Rather than being forced to work at the shell script layer, any code that can access Python functions and objects can run these commands.

The first victim to undergo the scalpel is rpmdev-bumpspec. The following result is not 100% compatible with the original shell script, but it is part of a small library that will be able to modify a spec file in more than one way. Currently, any tag can be edited, the release tag incremented, and changelog entries inserted. It currently lets you also query any spec file for any RPM tag via python, and it handles calling out to the command line in the background. It will even zip it up into a list of dictionaries for your result. It also divides cleanly between the definition of a spec file and how to modify it.

Take me to the code!

0 flames: