コード例 #1
0
 def test_line(self):
     line = "On the bus"
     out = meow.meow_meow(line, no.no)
     self.assertEqual(out, "No noo noo")
コード例 #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.")
コード例 #3
0
 def test_line(self):
     line = "On the bus"
     out = meow.meow_meow(line, meow.meow)
     self.assertEqual(out, "Me mew mew")
コード例 #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.")
コード例 #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
コード例 #6
0
ファイル: test_meow.py プロジェクト: hugovk/meow.py
 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.")
コード例 #7
0
ファイル: test_meow.py プロジェクト: hugovk/meow.py
 def test_line(self):
     line = "On the bus"
     out = meow.meow_meow(line, meow.meow)
     self.assertEqual(out, "Me mew mew")
コード例 #8
0
ファイル: test_no.py プロジェクト: hugovk/meow.py
 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.")
コード例 #9
0
ファイル: test_no.py プロジェクト: hugovk/meow.py
 def test_line(self):
     line = "On the bus"
     out = meow.meow_meow(line, no.no)
     self.assertEqual(out, "No noo noo")