Catch a possible exception in case of malformed input
authordbs <dbs@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Sat, 29 Nov 2008 22:13:25 +0000 (22:13 +0000)
committerdbs <dbs@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Sat, 29 Nov 2008 22:13:25 +0000 (22:13 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@11365 dcc99617-32d9-48b4-a31d-7c20da2025e4

build/i18n/scripts/merge_ils_events.py

index 8f02505..0e88455 100755 (executable)
@@ -19,15 +19,19 @@ def merge_events(master, localization):
 
     events = master_xml.getElementsByTagName('event')
     for event in events:
-        merged.documentElement.appendChild(merged.createTextNode("\n"))
-        l10n_node = get_l10n_event_desc(l10n_xml, event.getAttribute('code'))
-        for child in event.childNodes:
-            if child.nodeName == 'desc':
-                if child.getAttribute('xml:lang') == l10n_node.getAttribute('xml:lang'):
-                    event.removeChild(child)
-        event.appendChild(l10n_node)
-        merged.documentElement.appendChild(event)
-        merged.documentElement.appendChild(merged.createTextNode("\n"))
+        try: 
+            code = event.getAttribute('code')
+            merged.documentElement.appendChild(merged.createTextNode("\n"))
+            l10n_node = get_l10n_event_desc(l10n_xml, code)
+            for child in event.childNodes:
+                if child.nodeName == 'desc':
+                    if child.getAttribute('xml:lang') == l10n_node.getAttribute('xml:lang'):
+                        event.removeChild(child)
+            event.appendChild(l10n_node)
+            merged.documentElement.appendChild(event)
+            merged.documentElement.appendChild(merged.createTextNode("\n"))
+        except AttributeError:
+            print("%s probably has an <event> [%s] without a matching <desc> node" % (localization, code))
 
     return merged