Skip to content

Commit 78191c8

Browse files
committed
Documentation, formatting, fix test_interact
1 parent c41c27f commit 78191c8

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

spockbot/mcdata/recipes.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,22 @@ class Recipe(object):
1010
def __init__(self, raw):
1111
self.result = reformat_item(raw['result'], None)
1212
if 'ingredients' in raw:
13-
self.ingredients = [reformat_item(item, 0) for item in raw['ingredients']]
13+
self.ingredients = [reformat_item(item, 0)
14+
for item in raw['ingredients']]
1415
self.in_shape = None
1516
self.out_shape = None
1617
else:
1718
self.in_shape = reformat_shape(raw['inShape'])
1819
self.out_shape = reformat_shape(raw['outShape']) \
1920
if 'outShape' in raw else None
20-
self.ingredients = [item for row in self.in_shape for item in row] # flatten
21+
self.ingredients = [item for row in self.in_shape for item in row]
2122

2223
@property
2324
def total_ingredient_amounts(self):
25+
"""
26+
Returns:
27+
dict: In the form { (item_id, metadata) -> amount }
28+
"""
2429
totals = defaultdict(int)
2530
for id, meta, amount in self.ingredients:
2631
totals[(id, meta)] += amount
@@ -30,7 +35,7 @@ def total_ingredient_amounts(self):
3035
def ingredient_positions(self):
3136
"""
3237
Returns:
33-
dict: In the form { (item_id, metadata) -> [ (x, y, amount), ... ] }
38+
dict: In the form { (item_id, metadata) -> [(x, y, amount), ...] }
3439
"""
3540
positions = defaultdict(list)
3641
for y, row in enumerate(self.in_shape):

tests/plugins/helpers/test_interact.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ def requires(self, requirement):
2626
return NetMock()
2727
elif requirement == 'Channels':
2828
return True
29+
elif requirement == 'Event':
30+
return True
2931
else:
3032
raise AssertionError('Unexpected requirement %s' % requirement)
3133

0 commit comments

Comments
 (0)