Exemple #1
0
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
Exemple #2
0
 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')
Exemple #3
0
 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')
Exemple #4
0
 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')
Exemple #5
0
 def init_dialog(self, root_directory):
     self.dialog_renderer = DialogLoader().load(
         join(root_directory, 'dialog', self.lang))
Exemple #6
0
 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')
Exemple #7
0
 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')
Exemple #8
0
 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')
Exemple #9
0
 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')