PHP 8.2.30
Preview: show-newlines.py Size: 904 B
/proc/self/root/opt/cloudlinux/venv/lib64/python3.11/site-packages/setuptools/_vendor/jaraco/text/show-newlines.py

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)

Directory Contents

Dirs: 1 × Files: 7

Name Size Perms Modified Actions
- drwxr-xr-x 2026-02-06 08:05:34
Edit Download
643 B lrw-r--r-- 2026-01-20 13:01:47
Edit Download
1.30 KB lrw-r--r-- 2026-01-20 13:01:47
Edit Download
904 B lrw-r--r-- 2026-01-20 13:01:47
Edit Download
412 B lrw-r--r-- 2026-01-20 13:01:47
Edit Download
119 B lrw-r--r-- 2026-01-20 13:01:47
Edit Download
119 B lrw-r--r-- 2026-01-20 13:01:47
Edit Download
15.87 KB lrw-r--r-- 2026-01-20 13:01:47
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).