You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@labs.apache.org by hw...@apache.org on 2010/08/04 05:09:46 UTC
svn commit: r982109 - /labs/mouse/mouse.py
Author: hwright
Date: Wed Aug 4 03:09:45 2010
New Revision: 982109
URL: http://svn.apache.org/viewvc?rev=982109&view=rev
Log:
Only add subelements to the final Mouse report for which there are values
in the result object.
Modified:
labs/mouse/mouse.py
Modified: labs/mouse/mouse.py
URL: http://svn.apache.org/viewvc/labs/mouse/mouse.py?rev=982109&r1=982108&r2=982109&view=diff
==============================================================================
--- labs/mouse/mouse.py (original)
+++ labs/mouse/mouse.py Wed Aug 4 03:09:45 2010
@@ -58,20 +58,24 @@ class Resource(object):
elem = ElementTree.Element('resource')
elem.set('name', self._item.name)
- child = ElementTree.SubElement(elem, 'header-sample')
- child.text = self._item.get_content()
-
- child = ElementTree.SubElement(elem, 'header-type')
- child.set('name', self._result.header_name)
-
- child = ElementTree.SubElement(elem, 'license-family')
- child.set('name', self._result.license_family)
-
- child = ElementTree.SubElement(elem, 'license-approval')
- if self._result.license_approved:
- child.set('name', 'true')
- else:
- child.set('name', 'false')
+ if hasattr(self._result, 'include_sample') and self._result.include_sample:
+ child = ElementTree.SubElement(elem, 'header-sample')
+ child.text = self._item.get_content()
+
+ if hasattr(self._result, 'header_name') and self._result.header_name:
+ child = ElementTree.SubElement(elem, 'header-type')
+ child.set('name', self._result.header_name)
+
+ if hasattr(self._result, 'license_family') and self._result.license_family:
+ child = ElementTree.SubElement(elem, 'license-family')
+ child.set('name', self._result.license_family)
+
+ if hasattr(self._result, 'license_approved'):
+ child = ElementTree.SubElement(elem, 'license-approval')
+ if self._result.license_approved:
+ child.set('name', 'true')
+ else:
+ child.set('name', 'false')
child = ElementTree.SubElement(elem, 'type')
child.set('name', self._result.type_name)
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@labs.apache.org
For additional commands, e-mail: commits-help@labs.apache.org