[MERGE] From-Import-Removal and yield sum(meren)

This commit is contained in:
Faik Uygur
2007-04-26 12:31:51 +00:00
parent c7b4cf16d8
commit 4cc7a6f3e8
+12 -14
View File
@@ -291,21 +291,19 @@ def dir_size(dir):
# being true. Using 'du' command (like Debian does) can be a
# better solution :(.
# 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..
return getsize(dir)
return os.path.getsize(dir)
if islink(dir):
if os.path.islink(dir):
return long(len(os.readlink(dir)))
def sizes():
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([long(len(os.readlink((join(root, name))))) for name in files if islink(join(root,name))])
return sum( sizes() )
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_path(root, name))))) for name in files if os.path.islink(join_path(root, name))])
return sum(sizes())
def copy_file(src,dest):
"""Copy source file to the destination file."""
@@ -472,11 +470,11 @@ def uncompress(patchFile, compressType="gz", targetDir=None):
filePath = filePath.split(".%s" % compressType)[0]
if compressType == "gz":
from gzip import GzipFile
obj = GzipFile(patchFile)
import gzip
obj = gzip.GzipFile(patchFile)
elif compressType == "bz2":
from bz2 import BZ2File
obj = BZ2File(patchFile)
import bz2
obj = bz2.BZ2File(patchFile)
open(filePath, "w").write(obj.read())
return filePath
@@ -662,7 +660,7 @@ def filter_latest_packages(package_paths):
""" For a given pisi package paths list where there may also be multiple versions
of the same package, filters only the latest versioned ones """
from pisi.version import Version
import pisi.version
latest = {}
for path in package_paths:
@@ -671,7 +669,7 @@ def filter_latest_packages(package_paths):
name, version = parse_package_name(os.path.basename(path[:-len(ctx.const.package_suffix)]))
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)
else:
if version: