Questions tagged [pyp]

Pyp is a linux command line text manipulation tool similar to awk or sed, but which uses standard python string and list methods as well as custom functions evolved to generate fast results in an intense production environment. Pyed Pyper was developed at Sony Pictures Imageworks to facilitate the construction of complex image manipulation "one-liner" commands during visual effects work on Alice in Wonderland, Green Lantern, and the The Amazing Spiderman.

Project Homepage: The Pyed Piper

Because pyp employs it's own internal piping syntax ("|") similar to unix pipes, complex operations can be proceduralized by feeding the output of one python command to the input of the next. This greatly simplifies the generation and troubleshooting of multistep operations without the use of temporary variables or nested parentheses. The variable "p" represents each line as a string, while "pp" is entire input as python list:

\> ls | pyp "p[0] | pp.sort() | p + ' first letter, sorted!'" #gives sorted list of first letters of every line

In practice, the ability to easily construct complicated command sequences can largely replace "for each" loops on the command line, thus significantly speeding up work-flow using standard unix command recycling.

pyp output has been optimized for typical production scenarios. For example, if text is broken up into an array using the "split()" method, the output will be automatically numbered by field making selecting a particular field trivial. Numerous other conveniences have been included, such as an accessible history of all inter-pipe sub-results, an ability to perform mathematical operations, and a complement of variables based on common metacharcter split/join operations.

For power users, commands can be easily saved and recalled from disk as macros, providing an alternative to quick and dirty scripting. For the truly advanced user, additional methods can be added to the pyp class via a config file, allowing tight integration with larger facilities data structures or custom toolsets.

4 questions
6
votes
1 answer

Python one-liner (converting perl to pyp)

I was wondering if its possible to make a one-liner with pyp that has the same functionality as this. perl -l -a -F',' -p -e'if ($. > 1) { $F[6] %= 12; $F[7] %= 12;$_ = join(q{,}, @F[6,7]) }' This takes in a comma separated list of numbers with 8…
marshall
  • 2,443
  • 7
  • 25
  • 45
1
vote
1 answer

Unable to import pyperclip module

I used pip3 install pyperclip and it successfully installed pyperclip: user@user:~$ pip3 install pyperclip Collecting pyperclip Installing collected packages: pyperclip Successfully installed pyperclip-1.6.2 When I tried to import pyperclip in…
vApor
  • 23
  • 1
  • 5
0
votes
1 answer

Alias "python script" to a specified name so as to present a command for a python cli application

I currently writing a python cli application that takes in a CSV file as an argument and various options from the cli. python .\test.py data.csv usage: test.py [-h] [-v | -q] [-o] filepath I want to alias or replace the python ./test in the cli…
Omar Jarkas
  • 100
  • 5
0
votes
2 answers

Why is pyp (python) one-liner so slow?

I am trying to convert my perl one-liners to pyp. My first attempt was given to me kindly as the answer to another question as pyp "mm | p if n==0 else (p[:-2] + [(int(x)%12) for x in p[-2:]]) | mm" However this turns out to be amazingly slow. If…
marshall
  • 2,443
  • 7
  • 25
  • 45