pgtools/pgdiff.py
changeset 6 4ab077c93b2d
parent 0 eaae9539e910
equal deleted inserted replaced
5:57cf8fdff5ed 6:4ab077c93b2d
    27 
    27 
    28 from common.highlight import *
    28 from common.highlight import *
    29 
    29 
    30 
    30 
    31 class DiffBase:
    31 class DiffBase:
       
    32     COLORS = {
       
    33         '+' : BOLD | GREEN,
       
    34         '-' : BOLD | RED,
       
    35         '*' : BOLD | YELLOW}
       
    36     
    32     def __init__(self):
    37     def __init__(self):
    33         self.changes = None
    38         self.changes = None
    34 
    39 
    35     def format(self):
    40     def format(self):
    36         out = ['  ' * self.level]
    41         out = ['  ' * self.level]
    37 
    42 
    38         if self.change == '+':
    43         out.append(highlight(1, self.COLORS[self.change]))
    39             out.append(highlight(1, BOLD | GREEN))
       
    40         elif self.change == '-':
       
    41             out.append(highlight(1, BOLD | RED))
       
    42         else:
       
    43             out.append(highlight(1, BOLD | YELLOW))
       
    44         out.append(self.change)
    44         out.append(self.change)
    45         
    45         
    46         out += [' ', self.type, ' ', self.name, highlight(0)]
    46         out += [' ', self.type, ' ', self.name, highlight(0)]
    47         
    47         
    48         if self.changes:
    48         if self.changes: