Exemple #1
0
    def test_examples(self):
        from src.PhraseExamples import PhraseExamples

        ritmom_root = parent_dir_path(parent_dir_path(abspath(__file__)))

        with open(f'{ritmom_root}/config.json') as f:
            config = load(f)
        pe = PhraseExamples(config)
        wi = pe.get_definitions_and_examples('stand up', 'english')

        # print(list(wi.definitions))
        # print(list(wi.antonyms))
        # print(list(wi.synonyms))
        # print(list(wi.examples))
        pass
Exemple #2
0
def tricks_from(args):
  """
  Subcommand to execute tricks from a tricks configuration file.

  :param args:
      Command line argument options.
  """
  from watchdog.observers import Observer

  add_to_sys_path(path_split(args.python_path))
  observers = []
  for tricks_file in args.files:
    observer = Observer(timeout=args.timeout)

    if not os.path.exists(tricks_file):
      raise IOError("cannot find tricks file: %s" % tricks_file)

    config = load_config(tricks_file)

    try:
      tricks = config[CONFIG_KEY_TRICKS]
    except KeyError:
      raise KeyError("No `%s' key specified in %s." % (
        CONFIG_KEY_TRICKS, tricks_file))

    if CONFIG_KEY_PYTHON_PATH in config:
      add_to_sys_path(config[CONFIG_KEY_PYTHON_PATH])

    dir_path = parent_dir_path(tricks_file)
    schedule_tricks(observer, tricks, dir_path, args.recursive)
    observer.start()
    observers.append(observer)

  try:
    while True:
      time.sleep(1)
  except KeyboardInterrupt:
    for o in observers:
      o.unschedule_all()
      o.stop()
  for o in observers:
    o.join()
Exemple #3
0
    This will be executed as payload from a worker process
    :param language_pair:
    :param items:
    :param part_number:
    :return:
    """
    global sequence_builder
    try:
        sequence_builder.make_audio_track(language_pair, items, part_number)
    except Exception as e:
        print(str(e))
        print_exc()


if __name__ == '__main__':
    ritmom_root = parent_dir_path(parent_dir_path(abspath(__file__)))

    def load_config():
        config = load(open(f'{ritmom_root}/config.json'))
        languages = config['languages']
        filtered_languages = dict()
        for language, props in languages.items():
            if 'ignore' not in props or not props['ignore']:
                filtered_languages[language] = {
                    prop: props[prop]
                    for prop in props if prop != 'ignore'
                }
        config['languages'] = filtered_languages
        return config

    def main():