diff --git a/pisi.e3p b/pisi.e3p
index f72ff3c2..6eff5225 100644
--- a/pisi.e3p
+++ b/pisi.e3p
@@ -1,7 +1,7 @@
-
+
Python
@@ -408,6 +408,10 @@
tests
sandbox
+
+ tests
+ beta-remoterepo.sh
+
pisi-cli
@@ -419,9 +423,9 @@
-
-
+
+
diff --git a/pisi/build.py b/pisi/build.py
index aa459806..94aa053c 100644
--- a/pisi/build.py
+++ b/pisi/build.py
@@ -28,7 +28,8 @@ import pisi.context as ctx
import pisi.dependency as dependency
import pisi.operations as operations
from pisi.sourcearchive import SourceArchive
-from pisi.files import Files, FileInfo
+from pisi.files import Files, File as FileInfo
+from pisi.files import Files
from pisi.metadata import MetaData
from pisi.package import Package
diff --git a/pisi/files.py b/pisi/files.py
index db697e72..16bb3ca5 100644
--- a/pisi/files.py
+++ b/pisi/files.py
@@ -15,93 +15,32 @@
# Authors: Eray Ozkural
-from pisi.xmlext import *
-from pisi.xmlfile import XmlFile
+import pisi.xmlfile as xmlfile
from pisi.util import Checks
import pisi.lockeddbshelve as shelve
-class FileInfo:
- """FileInfo holds the information for a File node/tag in files.xml"""
- def __init__(self, _path = "", _type = "", _size = "", _hash = None):
- self.path = _path
- self.type = _type
- self.size = _size
- self.hash = _hash
+class File:
+ """File holds the information for a File node/tag in files.xml"""
- def readnew(node):
- f = FileInfo()
- f.read(node)
- return f
- readnew = staticmethod(readnew)
+ __metaclass__ = xmlfile.autoxml
- def read(self, node):
- self.path = getNodeText(getNode(node, "Path"))
- self.type = getNodeText(getNode(node, "Type"))
- self.size = getNodeText(getNode(node, "Size"))
- hashnode = getNode(node, "SHA1Sum")
- if hashnode:
- self.hash = getNodeText(hashnode)
- else:
- self.hash = None
+ t_Path = [ xmlfile.String, xmlfile.mandatory ]
+ t_Type = [ xmlfile.String, xmlfile.mandatory ]
+ t_Size = [ xmlfile.Integer, xmlfile.mandatory ]
+ t_Hash = [ xmlfile.String, xmlfile.optional, "SHA1Sum" ]
- def elt(self, dom):
- ## FIXME: looking for a better way to do it
- ## could apparently use helper functions to do this shorter
- elt = dom.createElement("File")
- pathElt = dom.createElement("Path")
- pathElt.appendChild(dom.createTextNode(self.path))
- elt.appendChild(pathElt)
- typeElt = dom.createElement("Type")
- typeElt.appendChild(dom.createTextNode(self.type))
- elt.appendChild(typeElt)
- if self.size:
- sizeElt = dom.createElement("Size")
- sizeElt.appendChild(dom.createTextNode(self.size))
- elt.appendChild(sizeElt)
- if self.hash:
- hashElt = dom.createElement("SHA1Sum")
- hashElt.appendChild(dom.createTextNode(self.hash))
- elt.appendChild(hashElt)
- return elt
-
- def has_errors(self):
- err = Checks()
- err.has_tag(self.path, "File", "Path")
- err.has_tag(self.type, "File", "Type")
- return err.list
-
def __str__(self):
s = "%s, type: %s, size: %s, sha1sum: %s" % (self.path, self.type,
self.size, self.hash)
return s
-class Files(XmlFile):
-
- def __init__(self):
- XmlFile.__init__(self, "Files")
- self.list = []
+class Files(xmlfile.XmlFile):
- def append(self, fileinfo):
- self.list.append(fileinfo)
+ __metaclass__ = xmlfile.autoxml
- def read(self, filename):
- self.readxml(filename)
+ tag = "Files"
- fileElts = self.getAllNodes("File")
- self.list = [FileInfo.readnew(x) for x in fileElts]
-
- def write(self, filename):
- self.newDOM()
- document = self.dom.documentElement
- for x in self.list:
- document.appendChild(x.elt(self.dom))
- self.writexml(filename)
-
- def has_errors(self):
- err = Checks()
- for finfo in self.list:
- err.join(finfo.has_errors())
- return err.list
+ t_List = [ [File], xmlfile.optional, "File"]
class FilesDB(shelve.LockedDBShelf):
@@ -113,8 +52,8 @@ class FilesDB(shelve.LockedDBShelf):
self[str(x.path)] = (pkg_name, x)
def remove_files(self, files):
- for x in files.list:
- self.delete(str(x.path))
+ for x in files.list:
+ self.delete(str(x.path))
def has_file(self, path):
return self.has_key(str(path))
diff --git a/pisi/xmlfile.py b/pisi/xmlfile.py
index d21c8358..e8e13f34 100644
--- a/pisi/xmlfile.py
+++ b/pisi/xmlfile.py
@@ -292,9 +292,8 @@ class autoxml(oo.autosuper, oo.autoprop):
# generate top-level helper functions
cls.initializers = inits
- def initialize(self, tag = None, spec = None):
- #FIXME: what the hell is spec? :(
- if not tag:
+ def initialize(self, **args):
+ if not args.has_key('tag'):
tag = cls.tag
if xmlfile_support:
XmlFile.__init__(self, tag = tag)
@@ -303,6 +302,8 @@ class autoxml(oo.autosuper, oo.autoprop):
#super(cls, self).__init__(tag = tag) cooperative shit disabled for now
for init in inits:#self.__class__.initializers:
init(self)
+ for x in args.iterkeys():
+ setattr(self, x, args[x])
# init hook
if hasattr(self, 'init'):
self.init(tag)
@@ -613,7 +614,7 @@ class autoxml(oo.autosuper, oo.autoprop):
def make_object():
obj = tag_type.__new__(tag_type)
- obj.__init__(tag, spec)
+ obj.__init__(tag=tag, req=req)
return obj
def init():
@@ -728,7 +729,7 @@ class autoxml(oo.autosuper, oo.autoprop):
def make_object():
obj = tag_type.__new__(tag_type)
- obj.__init__(tag, spec)
+ obj.__init__(tag=tag, req=req)
return obj
def init():
diff --git a/tests/filestests.py b/tests/filestests.py
new file mode 100644
index 00000000..0779883b
--- /dev/null
+++ b/tests/filestests.py
@@ -0,0 +1,31 @@
+# Copyright (C) 2005, TUBITAK/UEKAE
+#
+# This program is free software; you can redistribute it and/or modify it under
+# the terms of the GNU General Public License as published by the Free
+# Software Foundation; either version 2 of the License, or (at your option)
+# any later version.
+#
+# Please read the COPYING file.
+#
+
+import unittest
+import os
+
+import pisi.context as ctx
+import pisi.api
+import pisi.installdb
+import pisi.files as files
+from pisi import util
+
+import testcase
+
+class FilesTestCase(testcase.TestCase):
+
+ def setUp(self):
+ testcase.TestCase.setUp(self, database=False)
+
+ def testFileInfo(self):
+ f1 = files.File(path = '/usr/bin/zibidi')
+ f2 = files.File(path = '/usr/bin/kopus', type='exec', size=13, hash="abugubu")
+
+suite = unittest.makeSuite(FilesTestCase)