* improve specfilenew a little

This commit is contained in:
Eray Özkural
2005-10-25 15:40:22 +00:00
parent 8a4a47ac00
commit 934556dde8
2 changed files with 57 additions and 35 deletions
+53 -32
View File
@@ -25,7 +25,7 @@ from os.path import basename
from pisi.xmlext import * from pisi.xmlext import *
import pisi.xmlfile as xmlfile import pisi.xmlfile as xmlfile
from pisi.xmlfile import XmlFile from pisi.xmlfile import XmlFile
from pisi.ui import ui import pisi.context as ctx
from pisi.dependency import DepInfo from pisi.dependency import DepInfo
from pisi.util import Checks from pisi.util import Checks
@@ -42,8 +42,8 @@ class Packager:
class AdditionalFileInfo: class AdditionalFileInfo:
s_Filename = xmlfile.mandatory s_Filename = xmlfile.mandatory
a_Target = [types.StringType, xmlfile.mandatory] a_Target = [xmlfile.String, xmlfile.mandatory]
a_Permission = [types.StringType, xmlfile.optional] a_Permission = [xmlfile.String, xmlfile.optional]
def __str__(self): def __str__(self):
s = "%s -> %s " % (self.filename, self.target) s = "%s -> %s " % (self.filename, self.target)
@@ -54,9 +54,9 @@ class AdditionalFileInfo:
class Patch: class Patch:
s_Filename = xmlfile.mandatory s_Filename = xmlfile.mandatory
a_compressionType = [types.StringType, xmlfile.optional] a_compressionType = [xmlfile.String, xmlfile.optional]
a_level = [types.StringType, xmlfile.optional] a_level = [xmlfile.String, xmlfile.optional]
a_target = [types.StringType, xmlfile.optional] a_target = [xmlfile.String, xmlfile.optional]
def __str__(self): def __str__(self):
s = self.filename s = self.filename
@@ -71,10 +71,10 @@ class Patch:
class Update: class Update:
t_Date = [types.StringType, xmlfile.mandatory] t_Date = [xmlfile.String, xmlfile.mandatory]
t_Version = [types.StringType, xmlfile.mandatory] t_Version = [xmlfile.String, xmlfile.mandatory]
t_Release = [types.StringType, xmlfile.mandatory] t_Release = [xmlfile.String, xmlfile.mandatory]
t_Type = [types.StringType, xmlfile.optional] t_Type = [xmlfile.String, xmlfile.optional]
def __str__(self): def __str__(self):
s = self.date s = self.date
@@ -86,20 +86,37 @@ class Update:
class Path: class Path:
s_Path = xmlfile.mandatory s_Path = xmlfile.mandatory
a_fileType = [types.StringType, xmlfile.optional] a_fileType = [xmlfile.String, xmlfile.optional]
def __str__(self): def __str__(self):
s = self.pathname s = self.path
s += ", type=" + self.fileType s += ", type=" + self.fileType
return s return s
class Dependency:
t_Package = [xmlfile.String, xmlfile.mandatory]
a_versionFrom = [xmlfile.String, xmlfile.optional]
a_versionTo = [xmlfile.String, xmlfile.optional]
a_releaseFrom = [xmlfile.String, xmlfile.optional]
a_releaseTo = [xmlfile.String, xmlfile.optional]
def __str__(self):
s = self.package
if self.versionFrom:
s += 'ver >= ' + self.versionFrom
if self.versionTo:
s += 'ver <= ' + self.versionTo
if self.releaseFrom:
s += 'rel >= ' + self.releaseFrom
if self.releaseTo:
s += 'rel <= ' + self.releaseTo
return s
class ComarProvide: class ComarProvide:
s_om = [types.StringType, xmlfile.mandatory] s_om = [xmlfile.String, xmlfile.mandatory]
a_script = [types.StringType, xmlfile.mandatory] a_script = [xmlfile.String, xmlfile.mandatory]
def __str__(self): def __str__(self):
# FIXME: descriptive enough? # FIXME: descriptive enough?
@@ -110,9 +127,9 @@ class ComarProvide:
class Archive: class Archive:
s_uri = [ types.StringType, xmlfile.mandatory ] s_uri = [ xmlfile.String, xmlfile.mandatory ]
a_type =[ types.StringType, xmlfile.mandatory ] a_type =[ xmlfile.String, xmlfile.mandatory ]
a_sha1sum =[ types.StringType, xmlfile.mandatory ] a_sha1sum =[ xmlfile.String, xmlfile.mandatory ]
def decode_post(self): def decode_post(self):
self.name = basename(self.uri) self.name = basename(self.uri)
@@ -120,30 +137,34 @@ class Archive:
class Source: class Source:
t_Name = [types.StringType, xmlfile.mandatory] t_Name = [xmlfile.String, xmlfile.mandatory]
t_HomePage = [types.StringType, xmlfile.mandatory] t_HomePage = [xmlfile.String, xmlfile.mandatory]
t_Packager = [Packager, xmlfile.mandatory] t_Packager = [Packager, xmlfile.mandatory]
t_Summary = [types.StringType, xmlfile.mandatory] t_Summary = [xmlfile.String, xmlfile.mandatory]
t_Description = [types.StringType, xmlfile.mandatory] t_Description = [xmlfile.String, xmlfile.mandatory]
t_License = [ [types.StringType], xmlfile.mandatory] t_License = [ [xmlfile.String], xmlfile.mandatory]
t_IsA = [ [types.StringType], xmlfile.mandatory] t_IsA = [ [xmlfile.String], xmlfile.mandatory]
t_PartOf = [types.StringType, xmlfile.mandatory] t_PartOf = [xmlfile.String, xmlfile.mandatory]
t_Archive = [Archive, xmlfile.mandatory ] t_Archive = [Archive, xmlfile.mandatory ]
t_Patch = [ [Patch], xmlfile.mandatory, "Patches/Patch"] t_Patch = [ [Patch], xmlfile.mandatory, "Patches/Patch"]
t_BuildDep = [ [Dependency], xmlfile.mandatory, "BuildDependencies/Dependency"] t_BuildDep = [ [Dependency], xmlfile.mandatory, "BuildDependencies/Dependency"]
t_History = [ [Update], xmlfile.mandatory, "History/Update"] t_History = [ [Update], xmlfile.mandatory, "History/Update"]
class AdditionalFile:
s_filename = [xmlfile.String, xmlfile.mandatory]
a_target = [xmlfile.String, xmlfile.mandatory]
a_permission = [xmlfile.String, xmlfile.mandatory]
class Package: class Package:
t_Name = [ types.StringType, xmlfile.mandatory ] t_Name = [ xmlfile.String, xmlfile.mandatory ]
t_Summary = [ types.StringType, xmlfile.mandatory ] t_Summary = [ xmlfile.String, xmlfile.mandatory ]
t_Description = [ types.StringType, xmlfile.mandatory ] t_Description = [ xmlfile.String, xmlfile.mandatory ]
t_IsA = [ [types.StringType], xmlfile.mandatory] t_IsA = [ [xmlfile.String], xmlfile.mandatory]
t_PartOf = [types.StringType, xmlfile.mandatory] t_PartOf = [xmlfile.String, xmlfile.mandatory]
t_History = [ [Update], xmlfile.mandatory, "History/Update"] t_History = [ [Update], xmlfile.mandatory, "History/Update"]
t_Conflicts = [ [types.StringType], xmlfile.mandatory, "Conflicts/Package"] t_Conflicts = [ [xmlfile.String], xmlfile.mandatory, "Conflicts/Package"]
t_ProvidesComar = [ [ComarProvide], xmlfile.mandatory, "Provides/COMAR"] t_ProvidesComar = [ [ComarProvide], xmlfile.mandatory, "Provides/COMAR"]
t_RequriesComar = [ [types.StringType], xmlfile.mandatory, "Requires/COMAR"] t_RequriesComar = [ [xmlfile.String], xmlfile.mandatory, "Requires/COMAR"]
t_AdditionalFiles = [ [AdditionalFile], xmlfile.mandatory, "AdditionalFiles/AdditionalFile"] t_AdditionalFiles = [ [AdditionalFile], xmlfile.mandatory, "AdditionalFiles/AdditionalFile"]
+4 -3
View File
@@ -11,16 +11,17 @@
import unittest import unittest
import os import os
from pisi import specfile import pisi.specfilenew as specfile
from pisi.config import config from pisi.config import config
import pisi.util as util import pisi.util as util
class SpecFileTestCase(unittest.TestCase): class SpecFileNewTestCase(unittest.TestCase):
def setUp(self): def setUp(self):
self.spec = specfile.SpecFile() self.spec = specfile.SpecFile()
self.spec.read("tests/popt/pspec.xml") self.spec.read("tests/popt/pspec.xml")
def testReadSpec(self): def testReadSpec(self):
print 'GOTVEREN SENI'
self.assertEqual(self.spec.source.name, "popt") self.assertEqual(self.spec.source.name, "popt")
self.assertEqual(self.spec.source.version, "1.7") self.assertEqual(self.spec.source.version, "1.7")
@@ -77,4 +78,4 @@ class SpecFileTestCase(unittest.TestCase):
self.spec.write(os.path.join(config.tmp_dir(), 'popt-copy.pspec.xml')) self.spec.write(os.path.join(config.tmp_dir(), 'popt-copy.pspec.xml'))
suite = unittest.makeSuite(SpecFileTestCase) suite = unittest.makeSuite(SpecFileNewTestCase)