File: edit-compressed

package info (click to toggle)
debsecan 0.4.14
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 1,116 kB
  • sloc: python: 1,149; sh: 255; makefile: 47
file content (19 lines) | stat: -rw-r--r-- 409 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/usr/bin/python

import os
import sys
import tempfile
import zlib

input_name = sys.argv[1]
data = zlib.decompress(file(input_name).read())
(tmp, tmp_name) = tempfile.mkstemp()
try:
    tmp = file(tmp_name, "w")
    tmp.write(data)
    tmp.close()
    os.system("editor " + tmp_name)
    data = zlib.compress(file(tmp_name).read(), 9)
    file(input_name, "w+").write(data)
finally:
    os.unlink(tmp_name)