Skip to content

Commit

Permalink
Documentation, formatting, fix test_interact
Browse files Browse the repository at this point in the history
  • Loading branch information
Gjum committed Jan 31, 2016
1 parent c41c27f commit 78191c8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
11 changes: 8 additions & 3 deletions spockbot/mcdata/recipes.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,22 @@ class Recipe(object):
def __init__(self, raw):
self.result = reformat_item(raw['result'], None)
if 'ingredients' in raw:
self.ingredients = [reformat_item(item, 0) for item in raw['ingredients']]
self.ingredients = [reformat_item(item, 0)
for item in raw['ingredients']]
self.in_shape = None
self.out_shape = None
else:
self.in_shape = reformat_shape(raw['inShape'])
self.out_shape = reformat_shape(raw['outShape']) \
if 'outShape' in raw else None
self.ingredients = [item for row in self.in_shape for item in row] # flatten
self.ingredients = [item for row in self.in_shape for item in row]

@property
def total_ingredient_amounts(self):
"""
Returns:
dict: In the form { (item_id, metadata) -> amount }
"""
totals = defaultdict(int)
for id, meta, amount in self.ingredients:
totals[(id, meta)] += amount
Expand All @@ -30,7 +35,7 @@ def total_ingredient_amounts(self):
def ingredient_positions(self):
"""
Returns:
dict: In the form { (item_id, metadata) -> [ (x, y, amount), ... ] }
dict: In the form { (item_id, metadata) -> [(x, y, amount), ...] }
"""
positions = defaultdict(list)
for y, row in enumerate(self.in_shape):
Expand Down
2 changes: 2 additions & 0 deletions tests/plugins/helpers/test_interact.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ def requires(self, requirement):
return NetMock()
elif requirement == 'Channels':
return True
elif requirement == 'Event':
return True
else:
raise AssertionError('Unexpected requirement %s' % requirement)

Expand Down

0 comments on commit 78191c8

Please sign in to comment.