예제 #1
0
def import_file(filename):
    """ Import words from file
    with pairs separated by " - " (dash with spaces)
    """
    print(_('Loading "%s"' % filename))
    with open(filename, "r", encoding="utf-8") as f:
        print(_("Loaded %s words" % q.add_words_list(f)))
예제 #2
0
    def test_add_words_list(self):
        count = q.add_words_list('''
            a - b

            c      -     d
            e - f-g - i
        '''.splitlines())
        self.assertEqual(count, 3)
        self.assertIn(('a', 'b'), q.list_words())
        self.assertIn(('c', 'd'), q.list_words())
        self.assertIn(('e', 'f-g - i'), q.list_words())