73a74
> import gzip
75a77,100
> def openFileRd(in_file):
> """
> This opens the file passed as argument for reading using an appropriate
> function depending on if it is gzipped or not. It returns the file
> handle.
> """
> try:
> # First see if this file is gzipped
> try:
> # Opening the file works even if it is not a gzip file
> proto_in = gzip.open(in_file, 'rb')
>
> # Force a check of the magic number by seeking in the
> # file. If we do not do it here the error will occur when
> # reading the first message.
> proto_in.seek(1)
> proto_in.seek(0)
> except IOError:
> proto_in = open(in_file, 'rb')
> except IOError:
> print "Failed to open ", in_file, " for reading"
> exit(-1)
> return proto_in
>