Skip to content

Commit

Permalink
Add script to strip a prefix from a stream.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaraco committed Nov 20, 2022
1 parent 28e994a commit be6b598
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
5 changes: 5 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
v3.11.0
=======

Added ``strip-prefix`` script.

v3.10.0
=======

Expand Down
21 changes: 21 additions & 0 deletions jaraco/text/strip-prefix.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import sys

import autocommand

from jaraco.text import Stripper


def strip_prefix():
r"""
Strip any common prefix from stdin.
>>> import io, pytest
>>> getfixture('monkeypatch').setattr('sys.stdin', io.StringIO('abcdef\nabc123'))
>>> strip_prefix()
def
123
"""
sys.stdout.writelines(Stripper.strip_prefix(sys.stdin).lines)


autocommand.autocommand(__name__)(strip_prefix)

0 comments on commit be6b598

Please sign in to comment.