port to python, initial commit
make it work properly
Merge pull request #1 from terietor/port2Py

port the script into python