You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@gump.apache.org by bo...@apache.org on 2010/07/04 08:58:00 UTC
svn commit: r960300 - /gump/trunk/python/gump/core/model/property.py
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() + ' ' \