Exemplo n.º 1
0
 def test_text(self):
     text = generate_text.generate_text(self._reaction)
     self.assertRegex(text, 'vessel')
     self.assertRegex(text, 'oil bath')
     self.assertRegex(text, 'after 40 min')
     self.assertRegex(text, 'hexanone')
     self.assertRegex(text, 'automatically')
     self.assertRegex(text, 'mL')
Exemplo n.º 2
0
def main(argv):
    del argv  # Only used by app.run().
    reaction = message_helpers.load_message(FLAGS.input, reaction_pb2.Reaction)
    if FLAGS.output_type == 'html':
        text = generate_text.generate_html(reaction)
    elif FLAGS.output_type == 'text':
        text = generate_text.generate_text(reaction)
    else:
        raise ValueError(f'unsupported output_type: {FLAGS.output_type}')
    if FLAGS.output:
        with open(FLAGS.output, 'w') as f:
            f.write(text)
    else:
        print(text)