From dbb5bcbf4435e2e6a70738c2e31e4b44c70eeccf Mon Sep 17 00:00:00 2001 From: Ian Johnson Date: Thu, 6 Sep 2012 18:23:58 +0100 Subject: Reinstated the Python 2.7 dictionary comprehension implementation for dictionary wires. --- src/pypeline/helpers/helpers.py | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/src/pypeline/helpers/helpers.py b/src/pypeline/helpers/helpers.py index d811d44..2fadad0 100644 --- a/src/pypeline/helpers/helpers.py +++ b/src/pypeline/helpers/helpers.py @@ -149,15 +149,7 @@ def cons_wire(schema_conv_function): def cons_dictionary_wire(conversions): """Construct a wire that converts between two dictionaries. The keys of the conversions dictionary are keys in the output dictionary, of the preceeding component, whose values will be used to populate a dictionary whose keys are the value of the conversions dictionary.\n\nE.g., output = {'int': 9, 'string': 'hello'}, and conversions = {'int': 'int_two', 'string': 'string_two'}, yields an input dictionary, to the next component, input = {'int_two': 9, 'string_two': 'hello'}.""" - def conversion_function(a): - c = dict() - for key in conversions: - c[conversions[key]] = a[key] - return c - - return cons_wire(lambda a, _: conversion_function(a)) -# Python 2.7 syntax -# return cons_wire(lambda a, _: {conversions[key]: a[key] for key in conversions}) + return cons_wire(lambda a, _: {conversions[key]: a[key] for key in conversions}) def cons_split_wire(): -- cgit v1.2.3