Skip to content

Commit 61dabfb

Browse files
committed
Fix converter bug
1 parent 6323be6 commit 61dabfb

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

github3/converters.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ def inject(self, model):
5252
self.model = model
5353

5454
def _parse_map(self, model, raw_resource):
55-
return Modelizer(model).loads(raw_resource)
55+
if getattr(raw_resource, 'items', False):
56+
return Modelizer(model).loads(raw_resource)
5657

5758
def _parse_collection_map(self, model, raw_resources):
5859
# Dict of resources (Ex: Gist file)
@@ -62,7 +63,7 @@ def _parse_collection_map(self, model, raw_resources):
6263
dict_map[key] = Modelizer(model).loads(raw_resource)
6364
return dict_map
6465
# list of resources
65-
else:
66+
elif getattr(raw_resources, '__iter__', False):
6667
return [Modelizer(model).loads(raw_resource)
6768
for raw_resource in raw_resources]
6869

github3/tests/converters_test.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323
'list_map': [
2424
{'test_str': 'string', 'test_int': 1},
2525
{'test_str': 'string', 'test_int': 2},
26-
]
26+
],
27+
'fake_map': 9,
2728
}
2829

2930

@@ -36,10 +37,11 @@ def idl(self):
3637
'ints': ['test_int'],
3738
'dates': ['test_date'],
3839
'bools': ['test_bool'],
39-
'maps': {'map': Model},
40+
'maps': {'map': Model, 'fake_map': Model},
4041
'collection_maps': {
4142
'dict_map': Model,
4243
'list_map': Model,
44+
'fake_map': Model,
4345
},
4446
}
4547

0 commit comments

Comments
 (0)