Return-Path: Delivered-To: apmail-gump-commits-archive@www.apache.org Received: (qmail 57050 invoked from network); 4 Jul 2010 06:58:58 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 4 Jul 2010 06:58:58 -0000 Received: (qmail 17459 invoked by uid 500); 4 Jul 2010 06:58:57 -0000 Mailing-List: contact commits-help@gump.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: general@gump.apache.org Delivered-To: mailing list commits@gump.apache.org Received: (qmail 17452 invoked by uid 99); 4 Jul 2010 06:58:56 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 04 Jul 2010 06:58:56 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 04 Jul 2010 06:58:54 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 0B13923889E0; Sun, 4 Jul 2010 06:58:01 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r960300 - /gump/trunk/python/gump/core/model/property.py Date: Sun, 04 Jul 2010 06:58:00 -0000 To: commits@gump.apache.org From: bodewig@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100704065801.0B13923889E0@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: bodewig Date: Sun Jul 4 06:58:00 2010 New Revision: 960300 URL: http://svn.apache.org/viewvc?rev=960300&view=rev Log: make property accept an outputtype attribute to select outputs by id and type Modified: gump/trunk/python/gump/core/model/property.py Modified: gump/trunk/python/gump/core/model/property.py URL: http://svn.apache.org/viewvc/gump/trunk/python/gump/core/model/property.py?rev=960300&r1=960299&r2=960300&view=diff ============================================================================== --- gump/trunk/python/gump/core/model/property.py (original) +++ gump/trunk/python/gump/core/model/property.py Sun Jul 4 06:58:00 2010 @@ -102,28 +102,26 @@ class Property(NamedModelObject): + project + ']') else: targetProject = workspace.getProject(project) + candidates = [o for o in targetProject.getOutputs() + if self.type_matches(o)] if self.hasDomAttribute('id'): - id = self.getDomAttributeValue('id') + idattr = self.getDomAttributeValue('id') # Find the referenced id - for output in targetProject.getOutputs(): - if output.getId() == id: - if reference == 'jarpath' \ - or reference == 'outputpath': - self.setValue(output.getPath()) - else: - self.setValue(output.getName()) + for output in candidates: + if output.getId() == idattr: + self.setValueFromOutput(output, reference) break else: responsibleParty.addError( \ ("Output with id %s was not found in " + \ "project %s ") % \ - (id, targetProject.getName())) + (idattr, targetProject.getName())) - elif targetProject.getOutputCount() == 1: + elif len(candidates) == 1: # There is only one, so pick it... - self.setValue(targetProject.getOutputAt(0).getPath()) - elif targetProject.getOutputCount() > 1: + self.setValueFromOutput(candidates[0], reference) + elif len(candidates) > 1: # Don't know which.... responsibleParty.addError( \ ("Multiple outputs defined by project %s; " + \ @@ -133,7 +131,7 @@ class Property(NamedModelObject): else: responsibleParty.addError( \ ('Project %s defines no outputs') % \ - (targetProject.getName())) + (targetProject.getName())) else: responsibleParty.addError('No project specified.') @@ -182,6 +180,25 @@ class Property(NamedModelObject): self.setComplete(True) + def setValueFromOutput(self, output, reference): + """ + set value to path or name of output depending on reference attribute + """ + if reference == 'jarpath' or reference == 'outputpath': + self.setValue(output.getPath()) + else: + self.setValue(output.getName()) + + def type_matches(self, output): + """ + Does the output's type match the outputtype attribute - if any? + """ + has_output_type = self.hasDomAttribute('outputtype') + output_type = self.getDomAttributeValue('outputtype') + return (has_output_type and output.getType() == output_type) \ + or \ + (not has_output_type and output.is_jar()) + def dump(self, indent = 0, output = sys.stdout): """ Display the property """ output.write(getIndent(indent) + 'Property: ' + self.getName() + ' ' \