From-Import-Removal

This commit is contained in:
Faik Uygur
2007-04-26 12:25:41 +00:00
parent 22f2b28761
commit 05ebb818e3
+11 -13
View File
@@ -288,20 +288,18 @@ def dir_size(dir):
# being true. Using 'du' command (like Debian does) can be a # being true. Using 'du' command (like Debian does) can be a
# better solution :(. # better solution :(.
# Not really, du calculates size on disk, this is much better -- exa # Not really, du calculates size on disk, this is much better -- exa
from os.path import getsize, islink, isdir, exists
join = join_path
if exists(dir) and (not isdir(dir) and not islink(dir)): if os.path.exists(dir) and (not os.path.isdir(dir) and not os.path.islink(dir)):
#so, this is not a directory but file.. #so, this is not a directory but file..
return getsize(dir) return os.path.getsize(dir)
if islink(dir): if os.path.islink(dir):
return 0 return 0
def sizes(): def sizes():
for root, dirs, files in os.walk(dir): for root, dirs, files in os.walk(dir):
yield sum([getsize(join(root, name)) for name in files if not islink(join(root, name))]) yield sum([os.path.getsize(join_path(root, name)) for name in files if not os.path.islink(join_path(root, name))])
yield sum([long(len(os.readlink((join(root, name))))) for name in files if islink(join(root, name))]) yield sum([long(len(os.readlink((join_path(root, name))))) for name in files if os.path.islink(join_path(root, name))])
return sum(sizes()) return sum(sizes())
def copy_file(src,dest): def copy_file(src,dest):
@@ -469,11 +467,11 @@ def uncompress(patchFile, compressType="gz", targetDir=None):
filePath = filePath.split(".%s" % compressType)[0] filePath = filePath.split(".%s" % compressType)[0]
if compressType == "gz": if compressType == "gz":
from gzip import GzipFile import gzip
obj = GzipFile(patchFile) obj = gzip.GzipFile(patchFile)
elif compressType == "bz2": elif compressType == "bz2":
from bz2 import BZ2File import bz2
obj = BZ2File(patchFile) obj = bz2.BZ2File(patchFile)
open(filePath, "w").write(obj.read()) open(filePath, "w").write(obj.read())
return filePath return filePath
@@ -669,7 +667,7 @@ def filter_latest_packages(package_paths):
""" For a given pisi package paths list where there may also be multiple versions """ For a given pisi package paths list where there may also be multiple versions
of the same package, filters only the latest versioned ones """ of the same package, filters only the latest versioned ones """
from pisi.version import Version import pisi.version
latest = {} latest = {}
for path in package_paths: for path in package_paths:
@@ -678,7 +676,7 @@ def filter_latest_packages(package_paths):
name, version = parse_package_name(os.path.basename(path[:-len(ctx.const.package_suffix)])) name, version = parse_package_name(os.path.basename(path[:-len(ctx.const.package_suffix)]))
if latest.has_key(name): if latest.has_key(name):
if Version(latest[name][2]) < Version(version): if pisi.version.Version(latest[name][2]) < pisi.version.Version(version):
latest[name] = (root, name, version) latest[name] = (root, name, version)
else: else:
if version: if version: