strip-prefix.py 412 B

123456789101112131415161718192021
  1. import sys
  2. import autocommand
  3. from jaraco.text import Stripper
  4. def strip_prefix():
  5. r"""
  6. Strip any common prefix from stdin.
  7. >>> import io, pytest
  8. >>> getfixture('monkeypatch').setattr('sys.stdin', io.StringIO('abcdef\nabc123'))
  9. >>> strip_prefix()
  10. def
  11. 123
  12. """
  13. sys.stdout.writelines(Stripper.strip_prefix(sys.stdin).lines)
  14. autocommand.autocommand(__name__)(strip_prefix)