skip the buildconf section if not present
authorHasan Wan <hasan.wan@intel.com>
Mon, 27 May 2013 07:39:00 +0000 (15:39 +0800)
committerHasan Wan <hasan.wan@intel.com>
Mon, 27 May 2013 09:38:22 +0000 (17:38 +0800)
Change-Id: I5cd4803dbf1f0d6ca68183feeebe849857b417f4
Signed-off-by: Hasan Wan <hasan.wan@intel.com>
common/builddata.py

index 7707423..fc6e4f3 100644 (file)
@@ -56,21 +56,21 @@ class BuildData(object):
         btargets = get_elem(dom, "buildtargets")
 
         for btarget in btargets.getElementsByTagName("buildtarget"):
-            bconf = get_elem(btarget, "buildconf")
-
             target = {
                 "name":  btarget.getAttribute("name"),
                 "archs": [],
                 "repos": [],
-                "buildconf": {
-                    "location":
-                        get_elem(bconf, "location").getAttribute("href"),
-                    "checksum": {
-                       "type": get_elem(bconf, "checksum").getAttribute("type"),
-                       "value": get_elem(bconf, "checksum").firstChild.data
-                    }
                 }
-            }
+
+            try:
+                bconf = get_elem(btarget, "buildconf")
+                target["buildconf"]={"location": get_elem(bconf, "location").getAttribute("href"),
+                                     "checksum": {"type": get_elem(bconf, "checksum").getAttribute("type"),
+                                                  "value": get_elem(bconf, "checksum").firstChild.data}
+                                     }
+            except BuildDataError:
+                pass
+
             # Get archs
             for repo in btarget.getElementsByTagName("repo"):
                 barch = repo.getAttribute("arch")
@@ -105,14 +105,15 @@ class BuildData(object):
             target = self.targets[name]
             content += '<buildtarget name="%s">' % name
 
-            # buildconf
-            content += '<buildconf>'
-            buildconf = target['buildconf']
-            content += '<location href="%s"/>' % buildconf['location']
-            content += '<checksum type="%s">%s</checksum>' % \
-                       (buildconf['checksum']['type'],
-                        buildconf['checksum']['value'])
-            content += '</buildconf>'
+            if 'buildconf' in self.targets.keys():
+                # buildconf
+                content += '<buildconf>'
+                buildconf = target['buildconf']
+                content += '<location href="%s"/>' % buildconf['location']
+                content += '<checksum type="%s">%s</checksum>' % \
+                    (buildconf['checksum']['type'],
+                     buildconf['checksum']['value'])
+                content += '</buildconf>'
 
             # repos
             for rtype, rarch, rpath in target["repos"]: