mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2024-11-14 17:40:24 -08:00
f98d6fff65
* Added Python3.12 and future 3.13 * Fix Radarr result handling * remove py2.7 and py3.7 support
34 lines
904 B
Python
34 lines
904 B
Python
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)
|