When doing ls | pyp 'pp.sort()' each line of the output is prefixed with the index, and color escape codes are used. However, when the output is further sent to be processed like
ls | pyp 'pp.sort()' | my_cool_cmd
the indices and escape codes are unwanted. This could be worked around by doing pyp 'pp.sort() | p' but it would be cleaner if we only pretty-printed the output if isatty is true.
This can be done by changing
#update actual output
for out in user_input:
traced_output = self.array_tracer(out,analysis_mode, power_pipe) if sys.stdout.isatty() else out
output_array.append(traced_output) # for output
Arguably the same could be done for list outputs of non power-pipe:
echo 'this is a test' | pyp '[p[0], p[1]]'
where you assume that if the output is a list and stdout is not a tty, then we should try to join the list back together. This can be done via
if sys.stdout.isatty():
traced_output = self.array_tracer(out,analysis_mode, power_pipe)
elif contains_list:
traced_output = ' '.join([str(x) for x in out])
but it probably needs more thought as to the handling of arrays, as you mentioned in #1
When doing
ls | pyp 'pp.sort()'
each line of the output is prefixed with the index, and color escape codes are used. However, when the output is further sent to be processed likethe indices and escape codes are unwanted. This could be worked around by doing
pyp 'pp.sort() | p'
but it would be cleaner if we only pretty-printed the output ifisatty
is true.This can be done by changing
Arguably the same could be done for list outputs of non power-pipe:
where you assume that if the output is a list and stdout is not a tty, then we should try to join the list back together. This can be done via
but it probably needs more thought as to the handling of arrays, as you mentioned in #1