diff --git a/confluent_client/bin/collate b/confluent_client/bin/collate index 0f72afe0..0efa9ffd 100755 --- a/confluent_client/bin/collate +++ b/confluent_client/bin/collate @@ -35,6 +35,9 @@ import confluent.client argparser = optparse.OptionParser(usage="Usage: | %prog [options]") argparser.add_option('-a', '--abbreviate', action='store_true', help='Attempt to use confluent server to shorten noderanges') +argparser.add_option('-b', '--base', + help='Use given node as reference for comparison when ' + 'using -d, instead of using the most common result') argparser.add_option('-d', '--diff', action='store_true', help='Show what differs between most common ' 'output group and others') @@ -65,7 +68,7 @@ else: def print_current(): if options.diff: grouped.print_deviants(skipmodal=options.skipcommon, count=options.count, - reverse=options.reverse) + reverse=options.reverse, basenode=options.base) else: grouped.print_all(skipmodal=options.skipcommon, count=options.count, diff --git a/confluent_client/confluent/textgroup.py b/confluent_client/confluent/textgroup.py index d1a87523..cd35b6fa 100644 --- a/confluent_client/confluent/textgroup.py +++ b/confluent_client/confluent/textgroup.py @@ -169,13 +169,18 @@ class GroupedData(object): output.flush() def print_deviants(self, output=sys.stdout, skipmodal=False, reverse=False, - count=False): + count=False, basenode=None): self.generate_byoutput() modaloutput = None ismodal = True revoutput = [] + if basenode: + for checkout in self.byoutput: + if basenode in self.byoutput[checkout]: + modaloutput = checkout for outdata in sorted( - self.byoutput, key=lambda x: [0 - len(self.byoutput[x]), + self.byoutput, key=lambda x: [0 if modaloutput == x else 1, + 0 - len(self.byoutput[x]), humanify_nodename( self.get_group_text( self.byoutput[x]