Python awk replacement