def interactively_initialize_performer( self, performer, cache=False, clear=True, pending_user_input=None, ): self.session.io_manager.assign_user_input(pending_user_input) menu = self.make_performer_configuration_menu(performer) while True: self.session.push_breadcrumb(performer.name) result = menu._run(clear=clear) if self.session.backtrack(): self.session.pop_breadcrumb() self.session.restore_breadcrumbs(cache=cache) return elif not result: self.session.pop_breadcrumb() continue if result in ('skip', ['skip']): break elif result in ('more', ['more']): with self.backtracking: wizard = InstrumentCreationWizard( session=self.session, is_ranged=True) instruments = wizard._run() if self.session.backtrack(): break if instruments is not None: for instrument in instruments: performer.instruments.append(instrument) break elif isinstance(result, list): for instrument_name in result: instrument_class = \ instrumenttools.default_instrument_name_to_instrument_class( instrument_name) instrument = instrument_class() performer.instruments.append(instrument) break else: raise ValueError("how'd we get here?") self.session.pop_breadcrumb() self.session.pop_breadcrumb() self.session.restore_breadcrumbs(cache=cache)
def _run( self, cache=False, clear=True, head=None, pending_user_input=None, ): self.session.io_manager.assign_user_input(pending_user_input) self.session.cache_breadcrumbs(cache=cache) self.session.push_breadcrumb(self._breadcrumb) if self.session.is_in_score: selector = iotools.Selector.make_score_instrument_selector( session=self.session, ) with self.backtracking: result = selector._run(clear=clear) if self.session.backtrack(): self.session.pop_breadcrumb() self.session.restore_breadcrumbs(cache=cache) return if isinstance(result, Instrument): self.session.pop_breadcrumb() self.session.restore_breadcrumbs(cache=cache) self.target = result return self.target elif not result == 'other': raise ValueError wizard = InstrumentCreationWizard(session=self.session) with self.backtracking: result = wizard._run() if self.session.backtrack(): self.session.pop_breadcrumb() self.session.restore_breadcrumbs(cache=cache) return self.session.pop_breadcrumb() self.session.restore_breadcrumbs(cache=cache) self.target = result return self.target