Server IP : 68.65.120.251 / Your IP : 18.216.230.65 [ Web Server : LiteSpeed System : Linux server105.web-hosting.com 4.18.0-513.18.1.lve.el8.x86_64 #1 SMP Thu Feb 22 12:55:50 UTC 2024 x86_64 User : travtpib ( 6521) PHP Version : 7.4.33 Disable Function : NONE Domains : 1 Domains MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /opt/cloudlinux/venv/lib64/python3.11/site-packages/setuptools/_vendor/jaraco/text/ |
Upload File : |
import autocommand import inflect from more_itertools import always_iterable import jaraco.text def report_newlines(filename): r""" Report the newlines in the indicated file. >>> tmp_path = getfixture('tmp_path') >>> filename = tmp_path / 'out.txt' >>> _ = filename.write_text('foo\nbar\n', newline='', encoding='utf-8') >>> report_newlines(filename) newline is '\n' >>> filename = tmp_path / 'out.txt' >>> _ = filename.write_text('foo\nbar\r\n', newline='', encoding='utf-8') >>> report_newlines(filename) newlines are ('\n', '\r\n') """ newlines = jaraco.text.read_newlines(filename) count = len(tuple(always_iterable(newlines))) engine = inflect.engine() print( engine.plural_noun("newline", count), engine.plural_verb("is", count), repr(newlines), ) autocommand.autocommand(__name__)(report_newlines)