about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPjotr Prins2020-04-10 12:09:57 -0500
committerPjotr Prins2020-04-10 12:09:57 -0500
commit686bb7e2b3e3bdb326553f2094a07d4f987e303b (patch)
tree1c26e7ac5c393f698f4813f936d7fd2917ed8c30
parent9b7fbc52ae229d72e75de9f433eea00ce37ba70a (diff)
downloadbh20-seq-resource-686bb7e2b3e3bdb326553f2094a07d4f987e303b.tar.gz
bh20-seq-resource-686bb7e2b3e3bdb326553f2094a07d4f987e303b.tar.lz
bh20-seq-resource-686bb7e2b3e3bdb326553f2094a07d4f987e303b.zip
This fixed
{'type': 'string?', 'jsonldPredicate': {'_id': 'http://purl.obolibrary.org/obo/UO_0000036'}}
{'type': 'string?', 'jsonldPredicate': 'http://purl.obolibrary.org/obo/NCIT_C25688'}
Traceback (most recent call last):

(...)
  File "/export/iwrk/opensource/code/vg/bh20-seq-resource/bh20simplewebuploader/main.py", line 106, in walk_fields
    for item in walk_fields(field_type, parent_keys + [field_name], subtree_optional or optional):
  File "/export/iwrk/opensource/code/vg/bh20-seq-resource/bh20simplewebuploader/main.py", line 92, in walk_fields
    ref_url = field_type.get('jsonldPredicate', {}).get('_id', None)
AttributeError: 'str' object has no attribute 'get'
-rw-r--r--bh20simplewebuploader/main.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/bh20simplewebuploader/main.py b/bh20simplewebuploader/main.py
index b4e8681..bfc7762 100644
--- a/bh20simplewebuploader/main.py
+++ b/bh20simplewebuploader/main.py
@@ -88,7 +88,11 @@ def generate_form(schema):
             if not isinstance(field_type, str):
                 # If the type isn't a string
                 # See if it has a more info/what goes here URL
-                ref_url = field_type.get('jsonldPredicate', {}).get('_id', None)
+                predicate = field_type.get('jsonldPredicate', {})
+                if not isinstance(predicate, str):
+                    ref_url = predicate.get('_id', None)
+                else:
+                    ref_url = predicate # not sure this is correct
                 # Grab out its type field
                 field_type = field_type.get('type', '')