* 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:
+6
-3
@@ -11,7 +11,7 @@ import util
|
|||||||
from ui import ui
|
from ui import ui
|
||||||
from context import ctx
|
from context import ctx
|
||||||
from sourcearchive import SourceArchive
|
from sourcearchive import SourceArchive
|
||||||
from files import Files
|
from files import Files, FileInfo
|
||||||
from specfile import SpecFile, MetaData
|
from specfile import SpecFile, MetaData
|
||||||
|
|
||||||
class PisiBuildError(Exception):
|
class PisiBuildError(Exception):
|
||||||
@@ -112,19 +112,22 @@ class PisiBuild:
|
|||||||
def genFilesXml(self, package):
|
def genFilesXml(self, package):
|
||||||
# the worst function in this project!
|
# the worst function in this project!
|
||||||
# just testing...
|
# just testing...
|
||||||
|
files = Files()
|
||||||
install_dir = self.ctx.pkg_install_dir()
|
install_dir = self.ctx.pkg_install_dir()
|
||||||
for fpath, fhash in util.get_file_hashes(install_dir):
|
for fpath, fhash in util.get_file_hashes(install_dir):
|
||||||
# get the relative path
|
# get the relative path
|
||||||
fpath = fpath[len(install_dir):]
|
fpath = fpath[len(install_dir):]
|
||||||
|
|
||||||
depth = 0
|
depth = 0
|
||||||
ftype = ""
|
ftype = ""
|
||||||
|
fsize = 0
|
||||||
for path in package.paths:
|
for path in package.paths:
|
||||||
if fpath.startswith(path.pathname):
|
if fpath.startswith(path.pathname):
|
||||||
if depth < len(path.pathname):
|
if depth < len(path.pathname):
|
||||||
depth = len(path.pathname)
|
depth = len(path.pathname)
|
||||||
ftype = path.fileType
|
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):
|
def buildPackages(self):
|
||||||
for package in self.spec.packages:
|
for package in self.spec.packages:
|
||||||
|
|||||||
+13
-2
@@ -3,7 +3,18 @@
|
|||||||
|
|
||||||
class FileInfo:
|
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.path = getNodeText(getNode(node, "Path"))
|
||||||
self.type = getNodeText(getNode(node, "Type"))
|
self.type = getNodeText(getNode(node, "Type"))
|
||||||
self.size = int(getNodeText(getNode(node, "Size")))
|
self.size = int(getNodeText(getNode(node, "Size")))
|
||||||
@@ -36,7 +47,7 @@ class Files(XmlFile):
|
|||||||
self.readxml(filename)
|
self.readxml(filename)
|
||||||
|
|
||||||
fileElts = getAllNodes(node, "File")
|
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):
|
def write(self, filename):
|
||||||
self.newDOM()
|
self.newDOM()
|
||||||
|
|||||||
Reference in New Issue
Block a user