~ubuntu-branches/ubuntu/raring/hplip/raring

« back to all changes in this revision

Viewing changes to debian/local/pyppd/pyppd/compressor.py

  • Committer: Bazaar Package Importer
  • Author(s): Mark Purcell
  • Date: 2010-12-23 11:04:31 UTC
  • mfrom: (2.1.158 natty)
  • Revision ID: james.westby@ubuntu.com-20101223110431-ev5wz1it6b7jce51
Tags: 3.10.9-1
New Upstream Release 

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
from subprocess import Popen, PIPE
 
2
 
 
3
def compress(value):
 
4
    """Compresses a string with the xz binary"""
 
5
 
 
6
    process = Popen(["xz", "--compress", "--force"], stdin=PIPE, stdout=PIPE)
 
7
    return process.communicate(value)[0]
 
8
 
 
9
def decompress(value):
 
10
    """Decompresses a string with the xz binary"""
 
11
 
 
12
    process = Popen(["xz", "--decompress", "--stdout", "--force"],
 
13
                    stdin=PIPE, stdout=PIPE)
 
14
    return process.communicate(value)[0]
 
15
 
 
16
def compress_file(path):
 
17
    """Compress the file at 'path' with the xz binary"""
 
18
 
 
19
    process = Popen(["xz", "--compress", "--force", "--stdout", path], stdout=PIPE)
 
20
    return process.communicate()[0]