From 0d1961dfb25ac8e5a16df17cf989da467a13e018 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eray=20=C3=96zkural?= Date: Tue, 21 Jun 2005 12:33:40 +0000 Subject: [PATCH] * kafa gozu yararak biraz Files class'ini kullan - simdi anlasildi ki, o readerlari constructor'a koymak berbat bir fikirmis - onun yerine static bir alternatif constructor deniyorum list comprehensionlar icin calisacak - hala hicbir sey test edilmedi breakage bekleyin - bir de output dir olarak pkg_work_dir() kullandim bu da yanlis herhalde? --- pisi/build.py | 9 ++++++--- pisi/files.py | 15 +++++++++++++-- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/pisi/build.py b/pisi/build.py index e9fca92d..da839557 100644 --- a/pisi/build.py +++ b/pisi/build.py @@ -11,7 +11,7 @@ import util from ui import ui from context import ctx from sourcearchive import SourceArchive -from files import Files +from files import Files, FileInfo from specfile import SpecFile, MetaData class PisiBuildError(Exception): @@ -112,19 +112,22 @@ class PisiBuild: def genFilesXml(self, package): # the worst function in this project! # just testing... + files = Files() install_dir = self.ctx.pkg_install_dir() for fpath, fhash in util.get_file_hashes(install_dir): # get the relative path fpath = fpath[len(install_dir):] - depth = 0 ftype = "" + fsize = 0 for path in package.paths: if fpath.startswith(path.pathname): if depth < len(path.pathname): depth = len(path.pathname) ftype = path.fileType - print fpath, ftype, fhash + print fpath, ftype, fsize, fhash + files.list.append(FileInfo(fpath, ftype, fsize, fhash)) + files.write(os.path.join(self.ctx.pkg_work_dir(),"files.xml")) def buildPackages(self): for package in self.spec.packages: diff --git a/pisi/files.py b/pisi/files.py index 706bdd55..7e97fcbb 100644 --- a/pisi/files.py +++ b/pisi/files.py @@ -3,7 +3,18 @@ class FileInfo: - def __init__(self, node): + def __init__(self, _path = "", _type = "", _size = 0, _hash = ""): + self.path = _path + self.type = _type + self.size = _size + self.hash = _hash + + def readnew(node): + f = FileInfo() + f.read(node) + return f + + def read(self, node): self.path = getNodeText(getNode(node, "Path")) self.type = getNodeText(getNode(node, "Type")) self.size = int(getNodeText(getNode(node, "Size"))) @@ -36,7 +47,7 @@ class Files(XmlFile): self.readxml(filename) fileElts = getAllNodes(node, "File") - self.list = [FileInfo(x) for x in fileElts] + self.list = [FileInfo.readnew(x) for x in fileElts] def write(self, filename): self.newDOM()