From 314bb863eb53a4a19129921c95a3f1e27b17e881 Mon Sep 17 00:00:00 2001 From: j Date: Tue, 23 Feb 2016 09:43:33 +0530 Subject: [PATCH] dont reuse same variable in loop --- oml/item/api.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/oml/item/api.py b/oml/item/api.py index a3a31a2..8599de9 100644 --- a/oml/item/api.py +++ b/oml/item/api.py @@ -247,17 +247,18 @@ def findMetadata(data): elif key == 'id': import user.models items = {} + value = data[key] for u in user.models.User.query.filter_by(peered=True): peer = utils.get_peer(u.id) - if data[key] in peer.library: - h = peer.get_metahash(data[key]) + if value in peer.library: + h = peer.get_metahash(value) if h not in items: - items[h] = peer.library[data[key]].get('meta', {}).copy() + items[h] = peer.library[value].get('meta', {}).copy() items[h]['users'] = [u.id] j = items[h] - for key in [k['id'] for k in settings.config['itemKeys'] if isinstance(k['type'], list)]: - if key in j and not isinstance(j[key], list): - j[key] = [j[key]] if j[key] else [] + for key_ in [k['id'] for k in settings.config['itemKeys'] if isinstance(k['type'], list)]: + if key_ in j and not isinstance(j[key_], list): + j[key_] = [j[key_]] if j[key_] else [] else: items[h]['users'].append(u.id) response['items'] = list(items.values())