* 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?
This commit is contained in:
Eray Özkural
2005-06-21 12:33:40 +00:00
parent 836d38786e
commit 0d1961dfb2
2 changed files with 19 additions and 5 deletions
+6 -3
View File
@@ -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:
+13 -2
View File
@@ -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()