Permalink
Browse files

Support array types - not nicely, but turn into an array-of-dicts. Be…

…tter than nothing :)
  • Loading branch information...
1 parent 09a4e72 commit 6b97559b6e0f9a046f8ae91ca1c7c2e9f8536306 @rcoup rcoup committed Dec 22, 2010
Showing with 16 additions and 1 deletion.
  1. +16 −1 lighthouse.py
View
@@ -128,6 +128,18 @@ def _nil(self, data):
"""
return None
+ def _array(self, data):
+ """Returns an array
+ """
+ r = []
+ for item in data['children']:
+ item_obj = {}
+ for field in item['children']:
+ field_name, field_value, field_type = self._parse_field(field)
+ item_obj[field_name.replace('-', '_')] = field_value
+ r.append(item_obj)
+ return r
+
def _get_data(self, path):
"""Takes a path, joins it with the project's URL and grabs that
resource's XML data
@@ -195,7 +207,10 @@ def _parse_field(self, field):
if attributes:
field_type = attributes.get('type', None)
- if field_type:
+ if field_type == "array":
+ field_value = self._array(field)
+
+ elif field_type and (field_value is not None):
converter = getattr(self,'_'+field_type)
field_value = converter(field_value)

0 comments on commit 6b97559

Please sign in to comment.