Beispiel #1
0
 def test_get_choices_allable_unselect(self):
     with patch("sys.stdout", new=StringIO()) as fake_out, patch("sys.stdin", new=StringIO("a\na\n0\n")):  # allable on, unselect all.
         self.assertEqual(cit.get_choices(["ABC", "DEF"], allable=True, exitable=True), [])
         expect_word = "[+] ABC"
         self.assertTrue(expect_word in fake_out.getvalue())
Beispiel #2
0
 def test_get_choices_allable_esc(self):
     with patch("sys.stdout", new=StringIO()) as fake_out, patch("sys.stdin", new=StringIO("all\n0\n")):  # allable off
         self.assertEqual(cit.get_choices(["a", "DEF"], allable=True, exitable=True), ["a", "DEF"])
         expect_word = "all) ** ALL **"
         self.assertTrue(expect_word in fake_out.getvalue())
Beispiel #3
0
 def test_get_choices_allable_off(self):
     with patch("sys.stdout", new=StringIO()) as fake_out, patch("sys.stdin", new=StringIO("a\n0\n")):  # allable off
         self.assertEqual(cit.get_choices(["ABC", "DEF"], exitable=True), [])
         expect_word = "Please enter a valid choice."
         self.assertTrue(expect_word in fake_out.getvalue())
Beispiel #4
0
 def test_get_choices_exitable(self):
     with patch("sys.stdout", new=StringIO()) as fake_out, patch("sys.stdin", new=StringIO("0\n")):
         self.assertEqual(cit.get_choices(["ABC", "DEF"], exitable=True), [])
         expect_word = "0) ** EXIT **"
         self.assertTrue(expect_word in fake_out.getvalue())
Beispiel #5
0
 def test_get_choices_done_esc(self):
     with patch("sys.stdout", new=StringIO()) as fake_out, patch("sys.stdin", new=StringIO("1\ndone\n")):
         self.assertEqual(cit.get_choices(["ABC", "0"]), ["ABC", ])
         expect_word = "done) ** DONE **"
         self.assertTrue(expect_word in fake_out.getvalue())
    if sys.platform.startswith("win"):
        os.startfile(path)
    elif platform.system() == "Darwin":
        subprocess.Popen(["open", path])
    else:
        subprocess.Popen(["xdg-open", path])


if __name__ == "__main__":
    cit.info("Output Folder: {}".format(GENERATED_DIR))
    cit.info("Phrases File location: {}".format(PHRASES_DIR))
    deco = "\n| * "
    phrases_filenames = get_phrases_filenames()
    cit.info("Phrases JSON Files:")
    for filename in phrases_filenames:
        cit.echo(filename, pre="*")
    phrases_paths = [os.path.join(PHRASES_DIR, fn) for fn in phrases_filenames]
    phrases = load_all_phrases(phrases_paths)
    cit.ask("Which one you wanna convert?")
    phrsr_keys = cit.get_choices(list(AVAIL_PHRASER.keys()), allable=True)
    for key in phrsr_keys:
        cit.title("Generating {}".format(key))
        phraselet = AVAIL_PHRASER[key]
        generate_UDP_file(Phraser=phraselet['phraser'],
                          output=phraselet['output'],
                          phrases=phrases)
        cit.end()
    cit.ask("Open Output Folder?")
    if cit.get_choice(('Yes', 'No')) == 'Yes':
        show_file(GENERATED_DIR)