Ejemplo n.º 1
0
 def test_line(self):
     line = "On the bus"
     out = meow.meow_meow(line, no.no)
     self.assertEqual(out, "No noo noo")
Ejemplo n.º 2
0
 def test_line_punctuation(self):
     line = "On the bus? On the bus."
     out = meow.meow_meow(line, no.no)
     self.assertEqual(out, "No noo noo? No noo noo.")
     self.assertEqual(out, "No noo noo? No noo noo.")
Ejemplo n.º 3
0
 def test_line(self):
     line = "On the bus"
     out = meow.meow_meow(line, meow.meow)
     self.assertEqual(out, "Me mew mew")
Ejemplo n.º 4
0
 def test_line_punctuation(self):
     line = "On the bus? On the bus."
     out = meow.meow_meow(line, meow.meow)
     self.assertEqual(out, "Me mew mew? Me mew mew.")
Ejemplo n.º 5
0
def no(word):
    """Noify a word"""
    length = len(word)

    # Words longer than two will have:
    #  * first letter N
    #  * all others O

    return meow.capify("n" + ("o" * (length-1)), word)


if __name__ == '__main__':
    parser = argparse.ArgumentParser(
        description="Replace all words with nos, preserving punctuation.")
    parser.add_argument('infile', nargs='?', type=argparse.FileType('r'),
                        default=sys.stdin, help="Input text")
    parser.add_argument('-t', '--translation', action="store_true",
                        help="Output a line-by-line translation")
    args = parser.parse_args()

#     for line in fileinput.input(openhook=fileinput.hook_encoded("utf-8")):
    for line in args.infile:
        line = line.decode("utf-8-sig").rstrip()  # No BOM
        if args.translation:
            print()
            print(line.encode("utf-8"))
        print(meow.meow_meow(line, no).encode("utf-8"))

# End of file
Ejemplo n.º 6
0
 def test_line_punctuation(self):
     line = "On the bus? On the bus."
     out = meow.meow_meow(line, meow.meow)
     self.assertEqual(out, "Me mew mew? Me mew mew.")
Ejemplo n.º 7
0
 def test_line(self):
     line = "On the bus"
     out = meow.meow_meow(line, meow.meow)
     self.assertEqual(out, "Me mew mew")
Ejemplo n.º 8
0
 def test_line_punctuation(self):
     line = "On the bus? On the bus."
     out = meow.meow_meow(line, no.no)
     self.assertEqual(out, "No noo noo? No noo noo.")
     self.assertEqual(out, "No noo noo? No noo noo.")
Ejemplo n.º 9
0
 def test_line(self):
     line = "On the bus"
     out = meow.meow_meow(line, no.no)
     self.assertEqual(out, "No noo noo")