We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent a195489 commit 9151505Copy full SHA for 9151505
2 files changed
ferramentas/sembreak.py
@@ -0,0 +1,22 @@
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()
ferramentas/test_sembreak.py
@@ -0,0 +1,13 @@
+import pytest
+from sembreak import sembreak
+@pytest.mark.parametrize("given,expected", [
+ ('aaa bbb.', 'aaa bbb.'),
+ ('aaa bbb. Ccc', 'aaa bbb.\nCcc'),
+ ('aaa bbb. ccc', 'aaa bbb. ccc'),
+])
+def test_sembreak(given:str, expected:str):
+ res = sembreak(given)
+ assert res == expected
0 commit comments