Kod üzerinden hızlıca bir geçtim, bir iki kozmetik düzenleme var. Path işleri os.path.join'e çevrildi. Gözümden kaçan başka yerler olabilir...

This commit is contained in:
S.Çağlar Onur
2005-07-01 13:18:12 +00:00
parent 5c1f3a94c3
commit b62213d908
6 changed files with 16 additions and 17 deletions
+8 -8
View File
@@ -21,7 +21,7 @@ class ArchiveBase(object):
self.filePath = filepath
self.type = atype
def unpack(self, targetDir, cleanDir=False):
def unpack(self, targetDir, cleanDir = False):
self.targetDir = targetDir
# first we check if we need to clean-up our working env.
if os.path.exists(self.targetDir):
@@ -35,10 +35,10 @@ class ArchiveTar(ArchiveBase):
type. Provides access to tar, tar.gz and tar.bz2 files.
This class provides the unpack magic for tar archives."""
def __init__(self, filepath, type="tar"):
def __init__(self, filepath, type = "tar"):
super(ArchiveTar, self).__init__(filepath, type)
def unpack(self, targetDir, cleanDir=False):
def unpack(self, targetDir, cleanDir = False):
"""Unpack tar archive to a given target directory(targetDir)."""
super(ArchiveTar, self).unpack(targetDir, cleanDir)
@@ -69,7 +69,7 @@ class ArchiveZip(ArchiveBase):
symmagic = 2716663808 #long of hex val '0xA1ED0000L'
def __init__(self, filepath, type="zip", mode='r'):
def __init__(self, filepath, type = "zip", mode = 'r'):
super(ArchiveZip, self).__init__(filepath, type)
self.zip = zipfile.ZipFile(self.filePath, mode)
@@ -83,9 +83,9 @@ class ArchiveZip(ArchiveBase):
# It's a pity that zipfile can't handle unicode strings. Grrr!
fileName = str(fileName)
if os.path.isdir(fileName) and not os.path.islink(fileName):
self.zip.writestr(fileName + '/', '')
self.zip.writestr(os.path.join(fileName, ''))
for f in os.listdir(fileName):
self.add_to_archive(fileName + '/' + f)
self.add_to_archive(os.path.join(fileName, f))
else:
if os.path.islink(fileName):
dest = os.readlink(fileName)
@@ -110,7 +110,7 @@ class ArchiveZip(ArchiveBase):
self.add_file(fileName)
os.chdir(cwd)
def unpack_file_cond(self, pred, targetDir, archiveRoot=''):
def unpack_file_cond(self, pred, targetDir, archiveRoot = ''):
"""Unpack/Extract a file according to predicate function filename ->
bool"""
zip = self.zip
@@ -186,7 +186,7 @@ class Archive:
self.archive = handlers.get(type)(filepath, type)
def unpack(self, targetDir, cleanDir=False):
def unpack(self, targetDir, cleanDir = False):
self.archive.unpack(targetDir, cleanDir)
def unpack_files(self, files, targetDir):
+1 -2
View File
@@ -260,8 +260,7 @@ class PisiBuild:
files = Files()
files.read(const.files_xml)
for finfo in files.list:
p = "install/" + finfo.path
pkg.add_to_package(p)
pkg.add_to_package("install/" + finfo.path)
pkg.close()
os.chdir(c)
+3 -3
View File
@@ -62,7 +62,7 @@ class Fetcher:
else:
self.fetchRemoteFile()
return self.filedest + "/" + self.url.filename()
return os.path.join(self.filedest, self.url.filename())
def doGrab(self, file, dest, totalsize):
symbols = [' B/s', 'KB/s', 'MB/s', 'GB/s']
@@ -106,7 +106,7 @@ class Fetcher:
if os.access(url.path(), os.F_OK) == False:
self.err("no such file or no perm to read")
dest = open(self.filedest + "/" + url.filename() , "w")
dest = open(os.path.join(self.filedest, url.filename()) , "w")
totalsize = os.path.getsize(url.path())
file = open(url.path())
self.doGrab(file, dest, totalsize)
@@ -132,7 +132,7 @@ class Fetcher:
totalsize = 0 # could not get the totalsize of file
else: totalsize = int(headers['Content-Length'])
dest = open(self.filedest + "/" + self.url.filename() , "w")
dest = open(os.path.join(self.filedest, self.url.filename()) , "w")
self.doGrab(file, dest, totalsize)
+1 -1
View File
@@ -7,7 +7,7 @@ from xmlfile import XmlFile
class FileInfo:
"""FileInfo holds the information for a File node/tag in files.xml"""
def __init__(self, _path = "", _type = "", _size="", _hash = ""):
def __init__(self, _path = "", _type = "", _size = "", _hash = ""):
self.path = _path
self.type = _type
self.size = _size
+2 -2
View File
@@ -34,7 +34,7 @@ def install(package_fn):
# check if we have all required files
metadata = MetaData()
metadata.read(config.install_dir() + '/metadata.xml')
metadata.read(os.path.join(config.install_dir(), 'metadata.xml'))
# check package semantics
if not metadata.verify():
raise InstallError("MetaData format wrong")
@@ -57,4 +57,4 @@ def install(package_fn):
installdb.install(metadata.package.name,
metadata.package.version,
metadata.package.release,
config.install_dir() + '/files.xml')
os.path.join(config.install_dir(), 'files.xml'))
+1 -1
View File
@@ -57,7 +57,7 @@ class MetaData(XmlFile):
other information. A metadata has two parts, Source and Package."""
def __init__(self):
XmlFile.__init__(self,"PISI")
XmlFile.__init__(self, "PISI")
def fromSpec(self, src, pkg):
self.source = SourceInfo()