ajack 2004/07/23 08:23:33 Modified: python/gump/utils domutils.py python/gump/model object.py property.py builder.py python/gump/test/resources/full1 module1.xml module2.xml project bsf.xml python/gump/test model.py Log: Whew, tracking down the problem w/ blank properties took way more time than it oughta... Revision Changes Path 1.5 +1 -1 gump/python/gump/utils/domutils.py Index: domutils.py =================================================================== RCS file: /home/cvs/gump/python/gump/utils/domutils.py,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- domutils.py 14 Jul 2004 23:36:28 -0000 1.4 +++ domutils.py 23 Jul 2004 15:23:33 -0000 1.5 @@ -163,7 +163,7 @@ def hasDomAttribute(element,name): if element.hasAttributes(): - if element.getAttribute(name): return True + return element.hasAttribute(name) return False def getDomAttributeValue(element,name,default=None): 1.27 +9 -7 gump/python/gump/model/object.py Index: object.py =================================================================== RCS file: /home/cvs/gump/python/gump/model/object.py,v retrieving revision 1.26 retrieving revision 1.27 diff -u -r1.26 -r1.27 --- object.py 19 Jul 2004 16:07:56 -0000 1.26 +++ object.py 23 Jul 2004 15:23:33 -0000 1.27 @@ -67,7 +67,13 @@ self.resolutionPerformed=False self.completionPerformed=False - + + def __repr__(self): + return str(self) + + def __str__(self): + return self.__class__.__name__ + def __del__(self): Annotatable.__del__(self) Workable.__del__(self) @@ -151,8 +157,7 @@ # Helper methods def hasDomAttribute(self,name): - if hasDomAttribute(self.element,name): return True - return False + return hasDomAttribute(self.element,name) def getDomAttributeValue(self,name,default=None): return self.expandVariables( @@ -302,10 +307,7 @@ def __hash__(self): if self.hash: return self.hash self.hash=hash(self.name) - return self.hash - - def __repr__(self): - return str(self) + return self.hash def __str__(self): return self.__class__.__name__+':'+self.name 1.25 +41 -12 gump/python/gump/model/property.py Index: property.py =================================================================== RCS file: /home/cvs/gump/python/gump/model/property.py,v retrieving revision 1.24 retrieving revision 1.25 diff -u -r1.24 -r1.25 --- property.py 19 Jul 2004 16:07:56 -0000 1.24 +++ property.py 23 Jul 2004 15:23:33 -0000 1.25 @@ -20,32 +20,52 @@ from gump.model.object import * from gump.utils.domutils import * +from types import NoneType # represents a <property/> element class Property(NamedModelObject): def __init__(self,name,dom,parent): NamedModelObject.__init__(self,name,dom,parent) - self.value=self.getDomAttributeValue('value') + + self.value=None + def setValue(self,value): + """ + Set a value for this property + """ self.value = value def getValue(self): + """ + Get a value + """ return self.value # provide default elements when not defined in xml def complete(self,parent,workspace): if self.isComplete(): return + if self.hasDomAttribute('value'): + self.value=self.getDomAttributeValue('value','') + if not self.value: + self.value='' + else: + self.value=None + # Properties are either on the workspace, or on # an ant entry within a project. Pick workspace or project. responsibleParty=workspace if not parent==workspace: responsibleParty=parent.getOwner() - project=self.getDomAttributeValue('project') - + # Get what this might refer to. + project=self.getDomAttributeValue('project') reference=self.getDomAttributeValue('reference') + + # + # Do we have a reference to process? + # if reference=='home': if not workspace.hasProject(project): responsibleParty.addError('Cannot resolve homedir of *unknown* [' + project + ']') @@ -61,8 +81,8 @@ elif reference=='jarpath' or reference=='jar': if self.hasDomAttribute('project'): if not workspace.hasProject(project): - responsibleParty.addError('Cannot resolve jar/jarpath of *unknown* [' \ - + project + ']') + responsibleParty.addError( \ + 'Cannot resolve jar/jarpath of *unknown* [' + project + ']') else: targetProject=workspace.getProject(project) @@ -80,6 +100,7 @@ responsibleParty.addError( \ ("jar with id %s was not found in project %s ") % \ (id, targetProject.getName())) + elif targetProject.getJarCount()==1: # There is only one, so pick it... self.setValue(targetProject.getJars()[0].getPath()) @@ -120,15 +141,17 @@ relativeProject.getModule().getWorkingDirectory(), path)) else: - responsibleParty.addError('Can\'t have path on property on workspace: ' + \ - + self.getName()) + responsibleParty.addError( \ + 'Can\'t have path on property on workspace: ' + self.getName()) - if not self.value: - responsibleParty.addError('Unhandled Property: ' + self.getName() + ' on: ' + \ - str(parent)) + # + # Do we have a value yet? + # + if isinstance(self.value,NoneType): + responsibleParty.addError('Unhandled Property: ' + self.getName() + ' on: ' + str(parent)) self.value='*Unset*' - self.setComplete(1) + self.setComplete(True) def dump(self, indent=0, output=sys.stdout): """ Display the property """ @@ -166,9 +189,15 @@ return False def getProperties(self): + """ + Get a list of all the property objects + """ return self.properties.values() - def importProperty(self,pdom): + def importProperty(self,pdom): + """ + Import a project from the DOM + """ property=None if hasDomAttribute(pdom,'name'): 1.4 +9 -0 gump/python/gump/model/builder.py Index: builder.py =================================================================== RCS file: /home/cvs/gump/python/gump/model/builder.py,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- builder.py 19 Jul 2004 16:07:56 -0000 1.3 +++ builder.py 23 Jul 2004 15:23:33 -0000 1.4 @@ -45,6 +45,15 @@ # Store owning project self.project=project + def __str__(self): + """ + Display what project this is on, if possible. + """ + if not self.project: + return self.__class__.__name__ + else: + return self.__class__.__name__ + ' on ' + `self.project` + # # expand properties - in other words, do everything to complete the # entry that does NOT require referencing another project 1.8 +1 -0 gump/python/gump/test/resources/full1/module1.xml Index: module1.xml =================================================================== RCS file: /home/cvs/gump/python/gump/test/resources/full1/module1.xml,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- module1.xml 21 May 2004 23:15:01 -0000 1.7 +++ module1.xml 23 Jul 2004 15:23:33 -0000 1.8 @@ -7,6 +7,7 @@ <cvs repository="repository1" tag="module1Tag"/> + <!-- leave here to allow test of <nag on module --> <nag from="Ms. Dev 1 <[EMAIL PROTECTED]>" to="[EMAIL PROTECTED]"/> 1.13 +3 -0 gump/python/gump/test/resources/full1/module2.xml Index: module2.xml =================================================================== RCS file: /home/cvs/gump/python/gump/test/resources/full1/module2.xml,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- module2.xml 12 Feb 2004 13:41:52 -0000 1.12 +++ module2.xml 23 Jul 2004 15:23:33 -0000 1.13 @@ -13,6 +13,8 @@ <ant target="gump"> <property name="ant.home" reference="home" project="project1"/> <property name="containsSpaces" value="a b c '' d e"/> + <property name="blank-ok" value=""/> + <property name="blank-bogus"/> <depend property="project1.jar" project="project1"/> </ant> @@ -26,6 +28,7 @@ <license name="LICENSE"/> + <!-- leave here to allow test of <nag on project --> <nag from="Mr Dev 2 <[EMAIL PROTECTED]>" to="[EMAIL PROTECTED]"/> </project> 1.19 +1 -1 gump/project/bsf.xml Index: bsf.xml =================================================================== RCS file: /home/cvs/gump/project/bsf.xml,v retrieving revision 1.18 retrieving revision 1.19 diff -u -r1.18 -r1.19 --- bsf.xml 22 Jul 2004 19:50:54 -0000 1.18 +++ bsf.xml 23 Jul 2004 15:23:33 -0000 1.19 @@ -24,7 +24,7 @@ <redistributable/> <project name="bsf"> - + <jar name="lib/bsf.jar"/> <license name="license.html"/> </project> 1.24 +17 -2 gump/python/gump/test/model.py Index: model.py =================================================================== RCS file: /home/cvs/gump/python/gump/test/model.py,v retrieving revision 1.23 retrieving revision 1.24 diff -u -r1.23 -r1.24 --- model.py 14 Jul 2004 20:47:02 -0000 1.23 +++ model.py 23 Jul 2004 15:23:33 -0000 1.24 @@ -79,6 +79,21 @@ self.assertTrue('Has Jars', self.package1.hasJars()) self.assertTrue('Is a package', self.packagedModule1.isPackaged()) + def testNotifys(self): + + self.assertTrue('Project1 has notifications', self.project1.hasNotifys()) + self.assertTrue('Module1 has notifications', self.module1.hasNotifys()) + self.assertTrue('Project2 has notifications', self.project2.hasNotifys()) + self.assertFalse('Module2 has NO notifications', self.module2.hasNotifys()) + + def testProperties(self): + properties=project2.getProperties() + self.assertNotNone('Project2 has properties', project2.hasProperties()) + self.assertNotNone('Project2 has properties', properties) + self.assertNotEmpty('Project2 has some properties', properties) + self.assertEqual('Explicit blank is ok', properties.getProperty('blank-ok'), "") + self.assertNotNone('Explicit blank is NOT ok', properties.getProperty('blank-bogus')) + def testRepository(self): repo1 = self.repo1
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]