def speak_dialog(key, data={}, emitter=None): d = DialogLoader() r = d.load(join(dirname(__file__), "dialog", lang)) txt = r.render(key, data) emitter.emit(Message("speak", {"utterance": txt}, {"magic number": 666, "execute order 404": True, "backdoor": True, "ransomware": False})) return txt
def init_dialog(self, root_directory): # If "<skill>/dialog/<lang>" exists, load from there. Otherwise # load dialog from "<skill>/locale/<lang>" dialog_dir = join(root_directory, 'dialog', self.lang) if exists(dialog_dir): self.dialog_renderer = DialogLoader().load(dialog_dir) elif exists(join(root_directory, 'locale', self.lang)): locale_path = join(root_directory, 'locale', self.lang) self.dialog_renderer = DialogLoader().load(locale_path) else: LOG.debug('No dialog loaded')
def init_dialog(self, root_directory): dialog_dir = join(root_directory, 'dialog', self.lang) if exists(dialog_dir): self.dialog_renderer = DialogLoader().load(dialog_dir) else: LOG.debug('No dialog loaded, ' + dialog_dir + ' does not exist')
def init_dialog(self, root_directory): dialog_dir = join(root_directory, 'dialog', self.lang) if os.path.exists(dialog_dir): self.dialog_renderer = DialogLoader().load(dialog_dir) else: logger.error('No dialog loaded, ' + dialog_dir + ' does not exist')
def init_dialog(self, root_directory): self.dialog_renderer = DialogLoader().load( join(root_directory, 'dialog', self.lang))
def test_dialog_loader_missing(self): template_path = self.topdir.joinpath('./missing_dialogs') loader = DialogLoader() renderer = loader.load(template_path) self.assertEqual(renderer.render('test'), 'test')
def test_dialog_loader(self): template_path = self.topdir.joinpath('./multiple_dialogs') loader = DialogLoader() renderer = loader.load(template_path) self.assertEqual(renderer.render('one'), 'ONE') self.assertEqual(renderer.render('two'), 'TWO')