# HG changeset patch # User Jeff Hammel # Date 1376087039 25200 # Node ID 3982b7ad596bf6c8d9c002ce751897d558ab8a9d # Parent f81fdc6926fdb4f1bf1b704f5960e51465c87f50 python/stripirssi.py diff -r f81fdc6926fd -r 3982b7ad596b python/stripirssi.py --- a/python/stripirssi.py Fri Aug 09 14:22:27 2013 -0700 +++ b/python/stripirssi.py Fri Aug 09 15:23:59 2013 -0700 @@ -39,7 +39,11 @@ for line in lines: if not line: continue # XXX desirable? - prefix, rest = line.split(separator, 1) + try: + prefix, rest = line.split(separator, 1) + except ValueError: + import pdb; pdb.set_trace() + prefix, rest = None, None if length is None: length = len(prefix) else: @@ -56,9 +60,9 @@ # really, one could take most functions for str and map -> lines @splitlines -def remove_time(lines): - """removes leading 24 hour timestamp: HH:MM""" - # XXX :ss? +def remove_prefix_stamp(lines, stamp): + """removes leading stamp: HH:MM""" + return [line[len(stamp):] for line in lines] @splitlines def join(lines): @@ -88,8 +92,11 @@ ### CLI + + def main(args=sys.argv[1:]): + # parse command line usage = '%prog [options]' parser = optparse.OptionParser(usage=usage, description=__doc__) parser.add_option('-i', '--in-place', dest='in_place', @@ -104,6 +111,7 @@ lines = strip_first_column(log) import pdb; pdb.set_trace() + print '\n'.join(lines)