tree-wide: Use is_compressed instead of hard-coding extensions

This commit is contained in:
Fatih Aşıcı
2010-07-13 09:31:23 +00:00
parent 5eb3cbb408
commit c085c2872a
2 changed files with 6 additions and 5 deletions
+4 -3
View File
@@ -23,6 +23,7 @@ import pisi.uri
import pisi.util
import pisi.context as ctx
import pisi.db.lazydb as lazydb
from pisi.file import File
class RepoError(pisi.Error):
pass
@@ -155,13 +156,13 @@ class RepoDB(lazydb.LazyDB):
index_path = repo.indexuri.get_uri()
#FIXME Local index files should also be cached.
if index_path.endswith("bz2") or repo.indexuri.is_remote_file():
if File.is_compressed(index_path) or repo.indexuri.is_remote_file():
index = os.path.basename(index_path)
index_path = pisi.util.join_path(ctx.config.index_dir(),
repo_name, index)
if index_path.endswith("bz2"):
index_path = pisi.util.remove_suffix(".bz2", index_path)
if File.is_compressed(index_path):
index_path = os.path.splitext(index_path)[0]
if not os.path.exists(index_path):
ctx.ui.warning(_("%s repository needs to be updated") % repo_name)
+1 -1
View File
@@ -66,7 +66,7 @@ class XmlFile(object):
# workaround for repo index files to fix
# rev. 17027 regression (http://liste.pardus.org.tr/gelistirici/2008-February/011133.html)
compressed = str(uri).endswith(".bz2") or str(uri).endswith(".gz")
compressed = pisi.file.File.is_compressed(str(uri))
if uri.is_local_file() and not compressed:
# this is a local file