#!/usr/bin/env python #************************************************************************** # Copyright (C) 2009 by Walter Brisken * # * # This program is free software; you can redistribute it and/or modify * # it under the terms of the GNU General Public License as published by * # the Free Software Foundation; either version 3 of the License, or * # (at your option) any later version. * # * # This program is distributed in the hope that it will be useful, * # but WITHOUT ANY WARRANTY; without even the implied warranty of * # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * # GNU General Public License for more details. * # * # You should have received a copy of the GNU General Public License * # along with this program; if not, write to the * # Free Software Foundation, Inc., * # 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * #************************************************************************** #=========================================================================== # SVN properties (DO NOT CHANGE) # # $Id$ # $HeadURL$ # $LastChangedRevision$ # $Author$ # $LastChangedDate$ # #============================================================================ from sys import argv, exit from string import split, strip, lower format = [1, 2, 3, 4] def parsehead(str): s = split(strip(str)) return [s[0], int(s[1])] def parsescan(str): s = split(strip(str)) return [int(s[0]), int(s[1]), int(s[2]), int(s[3]), int(s[4]), int(s[5]), float(s[6]), int(s[7]), int(s[8]), int(s[9]), int(s[10]), lower(s[11])] def getstart(s): return float(s[2]) + (float(s[3]) + float(s[4])/float(s[5]))/86400.0 def getstop(s): return float(s[2]) + (float(s[3]) + float(s[4])/float(s[5]) + s[6])/86400.0 if len(argv) < 2: print 'Usage: %s ' exit(0) d = open(argv[1], 'r').readlines() scans = [] header = parsehead(d[0]) if header[1] != len(d)-1: print 'Warning -- directory size mismatch' header[1] = len(d)-1 first = 100000 last = 0 for i in d[1:]: scan = parsescan(i) start = getstart(scan) stop = getstop(scan) scans.append(scan) if start < first: first = start if stop > last: last = stop print '%d %14.8f %14.8f %s' % (header[1], first, last, header[0]) for s in scans: print '%d %d %14.8f %14.8f %d %d %s' % (s[0], s[0]+s[1], getstart(s), getstop(s), format[s[10]], s[9], s[11])