From 12037e2bf18bd174327b9209fb46a68c905d1675 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Metin?= Date: Thu, 13 Apr 2006 17:14:03 +0000 Subject: [PATCH] remove xmill use bz2 instead. bz2 compresses better too ;). -rw-r--r-- 1 root root 102629 Nis 11 12:20 pisi-index.xmi -rw-r--r-- 1 root root 40 Nis 11 12:20 pisi-index.xmi.sha1sum -rw-r--r-- 1 root root 1182237 Nis 11 12:20 pisi-index.xml -rw-r--r-- 1 root root 86920 Nis 13 20:03 pisi-index.xml.bz2 -rw-r--r-- 1 root root 40 Nis 13 20:04 pisi-index.xml.bz2.sha1sum --- pisi/api.py | 2 +- pisi/file.py | 28 +++++++++++++++++++--------- pisi/index.py | 2 +- 3 files changed, 21 insertions(+), 11 deletions(-) diff --git a/pisi/api.py b/pisi/api.py index f742c947..f30ee042 100644 --- a/pisi/api.py +++ b/pisi/api.py @@ -304,7 +304,7 @@ def index(dirs=None, output = 'pisi-index.xml', skip_sources=False): repo_dir = str(repo_dir) ctx.ui.info(_('* Building index of PISI files under %s') % repo_dir) index.index(repo_dir, skip_sources) - index.write(output, sha1sum=True, compress=File.xmill, sign=File.detached) + index.write(output, sha1sum=True, compress=File.bz2, sign=File.detached) ctx.ui.info(_('* Index file written')) def add_repo(name, indexuri): diff --git a/pisi/file.py b/pisi/file.py index a2364e2d..facabb08 100644 --- a/pisi/file.py +++ b/pisi/file.py @@ -20,6 +20,7 @@ like all pisi classes, it has been programmed in a non-restricting way import os import types +import bz2 import gettext __trans = gettext.translation('pisi', fallback=True) @@ -53,7 +54,7 @@ class InvalidSignature(pisi.Error): class File: (read, write) = range(2) # modes - (xmill, sevenzip) = range(2) # compress enums + (bz2, sevenzip) = range(2) # compress enums (detached, whatelse) = range(2) @@ -68,13 +69,16 @@ class File: @staticmethod def decompress(localfile, compress): - if compress == File.xmill: - pisi.util.run_batch('xdemill -f ' + localfile) - if not localfile.endswith('.xmi'): - raise Error(_("xmill compressed filename must end with '.xmi'")) - localfile = localfile[:-4] + '.xml' + if compress == File.bz2: + if not localfile.endswith(".bz2"): + raise Error(_("bz2 compressed filename must end with '.bz2'")) + + open(localfile[:-4], "w").write(bz2.BZ2File(localfile).read()) + localfile = localfile[:-4] + elif compress == File.sevenzip: raise Error(_("sevenzip compression not supported yet")) + return localfile @staticmethod @@ -156,16 +160,22 @@ class File: "this method must be called at the end of operation" self.__file__.close() if self.mode == File.write: - if self.compress == File.xmill: - pisi.util.run_batch('xcmill -9 -f ' + self.localfile) - self.localfile = self.localfile[:-4] + '.xmi' + if self.compress == File.bz2: + bc = bz2.BZ2Compressor() + bc.compress(open(self.localfile).read()) + + self.localfile = self.localfile + ".bz2" + open(self.localfile, "w").write(bc.flush()) + elif self.compress == File.sevenzip: raise Error(_("sevenzip compression not supported yet")) + if self.sha1sum: sha1 = pisi.util.sha1_file(self.localfile) cs = file(self.localfile + '.sha1sum', 'w') cs.write(sha1) cs.close() + if self.sign==File.detached: pisi.util.run_batch('gpg --detach-sig ' + self.localfile) diff --git a/pisi/index.py b/pisi/index.py index 60bbe52e..3c9bfc35 100644 --- a/pisi/index.py +++ b/pisi/index.py @@ -65,7 +65,7 @@ class Index(XmlFile): urlfile = file(pisi.util.join_path(tmpdir, 'uri'), 'w') urlfile.write(filename) # uri self.read(filename, tmpDir=tmpdir, sha1sum=not force, - compress=File.xmill, sign=File.detached) + compress=File.bz2, sign=File.detached) if not repo: repo = self.distribution.name()