From 5deae676b8a82a703a18959c6c07709dd05b5280 Mon Sep 17 00:00:00 2001 From: "tobyrosen@gmail.com" Date: Mon, 8 Aug 2011 14:28:54 +0000 Subject: fixed mac color issue git-svn-id: http://pyp.googlecode.com/svn/trunk@103 8ebc04a2-01ca-80aa-3703-73c302266661 --- pyp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/pyp b/pyp index 9e9b103..b840062 100644 --- a/pyp +++ b/pyp @@ -544,7 +544,7 @@ class Pyp(object): nf = 0 output = '' if power_pipe: - n_index = Colors.MAGENTA + '[%s]' % (self.n - 1) + Colors.OFF + n_index = Colors.MAGENTA + '[%s]' % (self.n - 1) + Colors.GREEN else: n_index = '' #DEALS WITH DIFFERENT TYPES OF INPUTS @@ -553,13 +553,13 @@ class Pyp(object): for field in input: if not nf == len(input): if type(field) in [str, PypStr]: - COLOR = Colors.OFF + COLOR = Colors.GREEN else: COLOR = Colors.MAGENTA - output = str(output) + Colors.BOLD + Colors.BLUE + "[%s]" % nf + Colors.OFF + COLOR + str(field) + Colors.OFF + output = str(output) + Colors.BOLD + Colors.BLUE + "[%s]" % nf + Colors.OFF + COLOR + str(field) + Colors.GREEN nf = nf + 1 - return n_index + Colors.OFF + Colors.BOLD + '[' + Colors.OFF + output + Colors.OFF + Colors.BOLD + ']' + Colors.OFF + return n_index + Colors.GREEN + Colors.BOLD + '[' + Colors.OFF + output + Colors.GREEN + Colors.BOLD + ']' + Colors.OFF elif type(input) in [str, int, PypStr] : @@ -568,8 +568,8 @@ class Pyp(object): elif type(input) is dict: #deals with dictionaries for field in sorted(input,key=lambda x : x.lower()): - output = output + Colors.OFF + Colors.BOLD + Colors.BLUE + "'" + field + "'" + Colors.OFF + ": " + Colors.OFF + Colors.OFF + str(input[field]) + Colors.BOLD + Colors.OFF + ',\n ' - return n_index + Colors.OFF + Colors.BOLD + '{' + output.strip().strip(' ,') + Colors.GREEN + Colors.BOLD + '}' + Colors.OFF + output = output + Colors.OFF + Colors.BOLD + Colors.BLUE + "'" + field + "'" + Colors.GREEN + ": " + Colors.OFF + Colors.GREEN + str(input[field]) + Colors.BOLD + Colors.GREEN + ',\n ' + return n_index + Colors.GREEN + Colors.BOLD + '{' + output.strip().strip(' ,') + Colors.GREEN + Colors.BOLD + '}' + Colors.OFF else: #catches every else return n_index + Colors.MAGENTA + str(input) + Colors.OFF @@ -1367,7 +1367,7 @@ used to enclose any strings. Here is a simple example for splitting the output of "ls" (unix file list) on '.':''' + Colors.YELLOW + ''' ls random_frame.jpg | pyp "p.split('.')" - ==> [''' + Colors.BLUE + '[0]' + Colors.YELLOW + 'random_frame' + Colors.BLUE + '[1]' + Colors.YELLOW + 'jpg] ''' + Colors.OFF + ''' + ==> [''' + Colors.BLUE + '[0]' + Colors.YELLOW + 'random_frame' + Colors.BLUE + '[1]' + Colors.YELLOW + 'jpg] ''' + Colors.GREEN + ''' The variable "p" represents each line piped in from "ls". Notice the output has index numbers, so it's trivial to pick a particular field or range of fields, -- cgit v1.3.1