File tree Expand file tree Collapse file tree 2 files changed +35
-0
lines changed
Expand file tree Collapse file tree 2 files changed +35
-0
lines changed Original file line number Diff line number Diff line change 1+ #!/usr/bin/env python3
2+
3+ import fileinput
4+ import re
5+
6+
7+ RE_PERIOD = re .compile (r'(\w\w)\. +([A-Z])' )
8+
9+
10+ def sembreak (text ):
11+ return RE_PERIOD .sub (r'\1.\n\2' , text )
12+
13+
14+ def main ():
15+ for line in fileinput .input (encoding = "utf-8" ):
16+ if line [0 ] != '.' :
17+ line = sembreak (line )
18+ print (line , end = '' )
19+
20+
21+ if __name__ == '__main__' :
22+ main ()
Original file line number Diff line number Diff line change 1+ import pytest
2+
3+ from sembreak import sembreak
4+
5+ @pytest .mark .parametrize ("given,expected" , [
6+ ('aaa bbb.' , 'aaa bbb.' ),
7+ ('aaa bbb. Ccc' , 'aaa bbb.\n Ccc' ),
8+ ('aaa bbb. Ccc' , 'aaa bbb.\n Ccc' ),
9+ ('aaa bbb. ccc' , 'aaa bbb. ccc' ),
10+ ])
11+ def test_sembreak (given :str , expected :str ):
12+ res = sembreak (given )
13+ assert res == expected
You can’t perform that action at this time.
0 commit comments