Esempio n. 1
0
 def __init__(self, apitrace, callNos=False):
     Differ.__init__(self, apitrace)
     self.a = None
     self.b = None
     if self.isatty:
         self.highlighter = LessHighlighter()
     else:
         self.highlighter = PlainHighlighter()
     self.delete_color = self.highlighter.red
     self.insert_color = self.highlighter.green
     self.callNos = callNos
     self.aSpace = 0
     self.bSpace = 0
     self.dumper = Dumper()
Esempio n. 2
0
 def __init__(self, apitrace, options):
     Differ.__init__(self, apitrace)
     self.a = None
     self.b = None
     if self.isatty:
         self.highlighter = LessHighlighter()
     else:
         self.highlighter = PlainHighlighter()
     self.delete_color = self.highlighter.red
     self.insert_color = self.highlighter.green
     self.callNos = options.callNos
     self.suppressCommonLines = options.suppressCommonLines
     self.aSpace = 0
     self.bSpace = 0
     self.dumper = Dumper()
Esempio n. 3
0
def main():
    '''Main program.
    '''

    # Parse command line options
    optparser = optparse.OptionParser(usage='\n\t%prog <trace> <trace>',
                                      version='%%prog')
    optparser.add_option('-a',
                         '--apitrace',
                         metavar='PROGRAM',
                         type='string',
                         dest='apitrace',
                         default='apitrace',
                         help='apitrace command [default: %default]')
    optparser.add_option('-c',
                         '--calls',
                         metavar='CALLSET',
                         type="string",
                         dest="calls",
                         default='*',
                         help="calls to compare [default: %default]")
    optparser.add_option('--ref-calls',
                         metavar='CALLSET',
                         type="string",
                         dest="ref_calls",
                         default=None,
                         help="calls to compare from reference trace")
    optparser.add_option('--src-calls',
                         metavar='CALLSET',
                         type="string",
                         dest="src_calls",
                         default=None,
                         help="calls to compare from source trace")
    optparser.add_option('--call-nos',
                         action="store_true",
                         dest="call_nos",
                         default=False,
                         help="dump call numbers")
    global options
    (options, args) = optparser.parse_args(sys.argv[1:])
    if len(args) != 2:
        optparser.error("incorrect number of arguments")

    if options.ref_calls is None:
        options.ref_calls = options.calls
    if options.src_calls is None:
        options.src_calls = options.calls

    ref_calls = readtrace(args[0], options.ref_calls)
    src_calls = readtrace(args[1], options.src_calls)

    if sys.stdout.isatty():
        highlighter = LessHighlighter()
    else:
        highlighter = ColorHighlighter()

    differ = SDiffer(ref_calls, src_calls, highlighter, options.call_nos)
    try:
        differ.diff()
    except IOError:
        pass