Skip to content

Commit fb079cb

Browse files
authored
Merge pull request #36 from yymao/u/yymao/bug-fix
2 parents b6e3a02 + 65b8a88 commit fb079cb

File tree

3 files changed

+19
-4
lines changed

3 files changed

+19
-4
lines changed

GCR/base.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,14 @@ def get_quantity_info(self, quantity, key=None, default=None):
185185
Get information of a certain quantity.
186186
If *key* is `None`, return the full dict for that quantity.
187187
"""
188-
d = self._get_quantity_info_dict(quantity, default if key is None else dict())
188+
d = self._get_quantity_info_dict(quantity, default=None)
189+
if d is None and quantity in self._quantity_modifiers:
190+
native = self._quantity_modifiers[quantity]
191+
if native:
192+
d = self._get_quantity_info_dict(native, default=None)
193+
194+
if d is None:
195+
return default
189196

190197
if key is None:
191198
return d

GCR/composite.py

+10-2
Original file line numberDiff line numberDiff line change
@@ -390,8 +390,16 @@ def __getattr__(self, name):
390390
return getattr(self.main, name)
391391

392392
def _get_quantity_info_dict(self, quantity, default=None):
393-
cat_id, q = self._quantity_modifiers.get(quantity)
394-
return self._get_catalog_by_id(cat_id).instance._get_quantity_info_dict(q, default=default)
393+
native_q = self._quantity_modifiers.get(quantity)
394+
if isinstance(native_q, tuple) and len(native_q) == 2:
395+
cat_id, q = native_q
396+
try:
397+
cat = self._get_catalog_by_id(cat_id)
398+
except KeyError:
399+
pass
400+
else:
401+
return cat.instance.get_quantity_info(q, default=default)
402+
return default
395403

396404
def _get_catalog_by_id(self, identifier):
397405
for cat in self._catalogs:

GCR/version.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
"""package version"""
22

3-
__version__ = '0.9.1'
3+
__version__ = '0.9.2'

0 commit comments

Comments
 (0)