def both_stripper(asker, update, object, a, b): keeps = properties.trivial() strips = properties.trivial() for x in [a, b]: keep_or_strip = asker.ask(modifiers_to_strip(update, x, object)).value new_keeps = fields.get(asker, fields.implication_about(to_keep()), keep_or_strip) keeps = properties.both(keeps, new_keeps) new_strips = fields.get(asker, fields.implication_about(to_strip()), keep_or_strip) strips = properties.both(strips, new_strips) return asker.reply(value=keep_strip(keep=keeps, strip=strips))
def reintroduce_field_value(asker, update, input, output, field, value): new_value = asker.ask(translate_field(field, value, update, input, output)) if new_value.has_answer(): return asker.reply(answer=held_update( apply_to_field( fields.modifier(), set_field(fields.implication_about(field),new_value.answer) ), output )) else: return output
def apply_update(asker, update, object): fast_result = fast_updater.dispatch(asker, update, object) if fast_result is not None: return fast_result exposed_object = asker.ask(convert.convert(object, convert.exposed_modifier())).firm_answer old_modifier = exposed_object.modifier #FIXME these forms seems more correct but are way too slow... #if properties.check_firmly(asker, properties.is_trivial(), old_modifier): #if booleans.ask_firmly(asker, builtins.equal(properties.trivial(), old_modifier)): if properties.trivial.head == old_modifier.head: return asker.ask_tail(apply_update_raw(update, exposed_object)) keep_or_strip = asker.ask(modifiers_to_strip(update, old_modifier, exposed_object)).value kept_modifier = fields.get(asker, fields.implication_about(to_keep()), keep_or_strip) stripped_modifier = fields.get(asker, fields.implication_about(to_strip()), keep_or_strip) stripped_object = exposed_object.simple_update(_modifier=kept_modifier) stripped_result = asker.ask(apply_update_raw(update, stripped_object)).firm_answer return asker.ask_tail(reintroduce_modifier( stripped_modifier, update, stripped_object, stripped_result ))