[cig-commits] [commit] baagaard/feature-add-json-config: Fixed several json parsing bugs. (e5a1980)

cig_noreply at geodynamics.org cig_noreply at geodynamics.org
Tue Sep 24 09:17:23 PDT 2013


Repository : ssh://geoshell/pythia

On branch  : baagaard/feature-add-json-config
Link       : https://github.com/geodynamics/pythia/compare/7b5240df77e6a48a6b245bb29be8914ce1810f4e...e5a1980ae0c4351eb23cbf90578eda928a2d1213

>---------------------------------------------------------------

commit e5a1980ae0c4351eb23cbf90578eda928a2d1213
Author: Brad Aagaard <baagaard at usgs.gov>
Date:   Tue Sep 24 09:18:42 2013 -0700

    Fixed several json parsing bugs.
    
    Pyre expects strings for all properties. Need to create facility arrays.


>---------------------------------------------------------------

e5a1980ae0c4351eb23cbf90578eda928a2d1213
 pyre/inventory/json/Parser.py | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/pyre/inventory/json/Parser.py b/pyre/inventory/json/Parser.py
index 7a82ab7..3c9e7fe 100644
--- a/pyre/inventory/json/Parser.py
+++ b/pyre/inventory/json/Parser.py
@@ -67,21 +67,25 @@ class Parser(object):
 
             elif isinstance(value, list): # facility array
                 facilityArray = node.getNode(key)
+                arrayItems = []
                 for item in value:
                     if not isinstance(item, dict):
                         raise ValueError("Expected dictionaries in facility array '%s'. Object: %s" % \
                                              (value, item))
                     if not item.has_key('_value') or not item.has_key('_item'):
                         raise ValueError("Expected facility array dictionary to contain '_value' and '_item' keys. Object: %s" % item)
+                    arrayItems.append(str(item['_item']))
                     module = item['_value'].pop('_module', None)
                     if module is None:
                         raise ValueError("Component '%s' missing '_module' key." % item['_value'])
                     facilityArray.setProperty(item['_item'], module, self.locatorNL)
                     facility = facilityArray.getNode(item['_item'])
                     self._setNode(facility, item['_value'])
+                arrayValue = "[" + ",".join(arrayItems) + "]"
+                node.setProperty(key, arrayValue, self.locatorNL)
 
             else: # property
-                node.setProperty(key, value, self.locatorNL)
+                node.setProperty(key, str(value), self.locatorNL)
 
         return
 



More information about the CIG-COMMITS mailing list