Package: pyin
It’s like sed, but Python!Why?There are plenty of Unix tools, likesedandawkfor processing text
data from stdin or a file on disk, but the syntax can be unfriendly and
sometimes its just easier to write a really simple script with a for loop
and some if statements.  This project seeks to drop you in the middle of that
for loop and let you write your own Python expressions to quickly get the job
done without actually writing a script, handle I/O, etc.Command Line InterfaceThis project is intended to be used from the included utilitypyin, although
the underlyingpyin.core.pmap()function could be used elsewhere with
non-string objects.Usage: pyin [OPTIONS] EXPRESSIONS...

  It's like sed, but Python!

  Map Python expressions across lines of text.  If an expression evaluates as
  'False' or 'None' then the current line is thrown away.  If an expression
  evaluates as 'True' then the next expression is evaluated.  If a list or
  dictionary is encountered it is JSON encoded.  All other objects are cast
  to string.

  Newline characters are stripped from the end of each line before processing
  and are added on write unless disabled with '--no-newline'.

  This utility employs 'eval()' internally but uses a limited scope to help
  prevent accidental side effects, but there are plenty of ways to get around
  this so don't pass anything through pyin that you wouldn't pass through
  'eval()'.

  Remove lines that do not contain a specific word:$catINFILE|pyin"'word' in line"Capitalize lines containing a specific word:$catINFILE|pyin"line.upper() if 'word' in line else line"Only print every other word from lines that contain a specific word:$catINFILE|pyin\>"'word' in line"\# Get lines with 'word' in them> "line.split()[::2])" \  # Grab every other word
      > "' '.join(line)"         # Convert list from previous expr to str

  Process all input text as though it was a single line to replace carriage
  returns with the system newline character:$catINFILE|pyin--block\>"line.replace('\r\n', os.newline)"For a more in-depth explanation about exactly what's going on under the
  hood, see the the docstring in 'pyin.core.pmap()':$python-c"help('pyin.core.pmap')"Options:
  --version           Show the version and exit.
  -i, --infile PATH   Input text file. [default: stdin]
  -o, --outfile PATH  Output text file. [default: stdout]
  --block             Operate on all input text as though it was a single
                      line.
  --no-newline        Don't ensure each line ends with a newline character.
  --help              Show this message and exit.InstallingVia pip:$pipinstallpyinFrom master branch:$gitclonehttps://github.com/geowurster/pyin$cdpyin&&pythonsetup.pyinstallWhat aboutpy -x?Most of this project was written with very little knowledge ofpyand no
knowledge ofpy-x, which serves almost exactly the same purpose.  The
primary difference between the two projects is thatpyinrequires I/O and
has some smarter filtering for expressions that evaluate asTrueorFalse.DevelopingInstall:$gitclonehttps://github.com/geowurster/pyin$cdpyin$virtualenvvenv&&sourcevenv/bin/activate$pipinstall-e.\[dev\]$py.testtests--covpyin--cov-reportterm-missingLicenseSeeLICENSE.txt