changeset 2990:0df1074c02ee

catching error when page has no defined interface tag, as not required within XML schema
author Dave Moffat <me@davemoffat.com>
date Mon, 16 Jul 2018 14:48:06 +0100
parents 543f28dea505
children 77114de617ba
files python/score_parser.py
diffstat 1 files changed, 11 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/python/score_parser.py	Sat Jul 14 15:28:56 2018 +0100
+++ b/python/score_parser.py	Mon Jul 16 14:48:06 2018 +0100
@@ -66,13 +66,19 @@
 
             # Get the axis names
             pageConfig = root.find('./waet/page/[@id="'+page_name_root+'"]')
-            for interface in pageConfig.findall('./interface'):    # Get the <interface> nodes
-                interfaceName = interface.get("name"); # Get the axis name
-                if interfaceName == None:
-                    interfaceName = "default"   # If name not set, make name 'default'
+            if pageConfig is None:
+                interfaceName = "default"
                 if storage[page_name]['axis'].get(interfaceName) == None:
                     storage[page_name]['axis'][interfaceName] = {}  # If not in store for page, add empty dict
-                storage[page_name]['axis'][interfaceName][subject_id] = [] # Add the store for the session
+                storage[page_name]['axis'][interfaceName][subject_id] = []
+            else:
+                for interface in pageConfig.findall('./interface'):    # Get the <interface> nodes
+                    interfaceName = interface.get("name"); # Get the axis name
+                    if interfaceName == None:
+                        interfaceName = "default"   # If name not set, make name 'default'
+                    if storage[page_name]['axis'].get(interfaceName) == None:
+                        storage[page_name]['axis'][interfaceName] = {}  # If not in store for page, add empty dict
+                    storage[page_name]['axis'][interfaceName][subject_id] = [] # Add the store for the session
                     
             # header: fragment IDs in 'alphabetical' order
             # go to fragment column, or create new column if it doesn't exist yet