Skip to content

Commit

Permalink
Merge pull request #36 from yymao/u/yymao/bug-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
yymao authored Dec 22, 2020
2 parents b6e3a02 + 65b8a88 commit fb079cb
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
9 changes: 8 additions & 1 deletion GCR/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,14 @@ def get_quantity_info(self, quantity, key=None, default=None):
Get information of a certain quantity.
If *key* is `None`, return the full dict for that quantity.
"""
d = self._get_quantity_info_dict(quantity, default if key is None else dict())
d = self._get_quantity_info_dict(quantity, default=None)
if d is None and quantity in self._quantity_modifiers:
native = self._quantity_modifiers[quantity]
if native:
d = self._get_quantity_info_dict(native, default=None)

if d is None:
return default

if key is None:
return d
Expand Down
12 changes: 10 additions & 2 deletions GCR/composite.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,8 +390,16 @@ def __getattr__(self, name):
return getattr(self.main, name)

def _get_quantity_info_dict(self, quantity, default=None):
cat_id, q = self._quantity_modifiers.get(quantity)
return self._get_catalog_by_id(cat_id).instance._get_quantity_info_dict(q, default=default)
native_q = self._quantity_modifiers.get(quantity)
if isinstance(native_q, tuple) and len(native_q) == 2:
cat_id, q = native_q
try:
cat = self._get_catalog_by_id(cat_id)
except KeyError:
pass
else:
return cat.instance.get_quantity_info(q, default=default)
return default

def _get_catalog_by_id(self, identifier):
for cat in self._catalogs:
Expand Down
2 changes: 1 addition & 1 deletion GCR/version.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"""package version"""

__version__ = '0.9.1'
__version__ = '0.9.2'

0 comments on commit fb079cb

Please sign in to comment.