parameters: ()
docstring: Main program
docstring_summary: Main program
docstring_tokens: Main program
function: def main():
      """Main program"""
      truncate_last = 0
      reverse = 0
      branch = None
      opts, args = getopt.getopt(sys.argv[1:], "trb:h")
      for o, a in opts:
          if o == '-t':
              truncate_last = 1
          elif o == '-r':
              reverse = 1
          elif o == '-b':
              branch = a
          elif o == '-h':
              print __doc__
              sys.exit(0)
      database = []
      while 1:
          chunk = read_chunk(sys.stdin)
          if not chunk:
              break
          records = digest_chunk(chunk, branch)
          if truncate_last:
              del records[-1]
          database[len(database):] = records
      database.sort()
      if not reverse:
          database.reverse()
      format_output(database)
function_tokens: def main ( ) : truncate_last = 0 reverse = 0 branch = None opts , args = getopt . getopt ( sys . argv [ 1 : ] , "trb:h" ) for o , a in opts : if o == '-t' : truncate_last = 1 elif o == '-r' : reverse = 1 elif o == '-b' : branch = a elif o == '-h' : print __doc__ sys . exit ( 0 ) database = [ ] while 1 : chunk = read_chunk ( sys . stdin ) if not chunk : break records = digest_chunk ( chunk , branch ) if truncate_last : del records [ - 1 ] database [ len ( database ) : ] = records database . sort ( ) if not reverse : database . reverse ( ) format_output ( database )