diff options
author | Ian Johnson <ianj@wgrids.com> | 2012-09-06 21:23:58 +0400 |
---|---|---|
committer | Ian Johnson <ianj@wgrids.com> | 2012-09-06 21:23:58 +0400 |
commit | dbb5bcbf4435e2e6a70738c2e31e4b44c70eeccf (patch) | |
tree | e9b08930dbe131adddb1d2a3c3d8983ca803ab35 | |
parent | 8fd65828ba0335192f79274f4cfddda430ab5280 (diff) |
Reinstated the Python 2.7 dictionary comprehension implementation for dictionary wires.
-rw-r--r-- | src/pypeline/helpers/helpers.py | 10 |
1 files changed, 1 insertions, 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(): |