Jun 5, 2013

compress/uncompress of zip/gzip files without the necessary tools but python is available

This week, I read about python onliners, which are provided by some
modules ( "batteries included" as the slogan of python ).

The gzip-Module allows to decompress gzip-Archives by
python -m gzip -d <gz-File>

the zipfile module allows create, test, list and decompress of zip archives:

# python -m zipfile -h 
    zipfile.py -l zipfile.zip # Show listing of a zipfile 
    zipfile.py -t zipfile.zip # Test if a zipfile is valid 
    zipfile.py -e zipfile.zip target # Extract zipfile into target dir 
    zipfile.py -c zipfile.zip src ... # Create zipfile from sources 

The  json/tool -Module allows formating of json-Strings:

# echo '{ "json": "obj", "test": [ 1, 2, 3] }' | python -m json.tool 

    "json": "obj", 
    "test": [ 

This call allows also an input and optional output-file for the json-Data.