Last active
January 11, 2017 12:06
-
-
Save zeffii/6907d11bb4f3058642ce5b5507f119eb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import operator | |
def lamesetter(a, b, c): | |
operator.attrgetter(b)(a) = c | |
def process(self): | |
(O, V), Ov = self.inputs, self.outputs | |
Prop = self.formula or self.selected_mode | |
sv_setattr = getattr if '.' in Prop else lambda a, b: operator.attrgetter(b)(a) | |
sv_getattr = setattr if '.' in Prop else lamesetter | |
objs = O.sv_get() | |
v = V.sv_get() | |
if isinstance(objs[0], list): | |
if V.is_linked: | |
v = v if isinstance(v[0], list) else [v] | |
objs, v = safc(objs, v) | |
for OBL, VALL in zip(objs, v): | |
for i, i2 in zip(safc(OBL, VALL)): | |
sv_setattr(i, Prop, i2) | |
elif Ov.is_linked: | |
Ov.sv_set([[sv_getattr(i, Prop) for i in OBL] for OBL in objs]) | |
else: | |
if V.is_linked: | |
v = v[0] if isinstance(v[0], list) else v | |
objs, v = safc(objs, v) | |
for i, i2 in zip(objs, v): | |
sv_setattr(i, Prop, i2) | |
elif Ov.is_linked: | |
Ov.sv_set([sv_getattr(i, Prop) for i in objs]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment