def OpenFileForRead(path, logtext):
  """ Opens a text file, be it GZip or plain """

  frame = None
  file  = None

  if not path:
    return (frame, file)

  try:
    if path.endswith('.gz'):
      frame = open(path, 'rb')
      file = gzip.GzipFile(fileobj=frame, mode='rt')
    else:
      file = open(path, 'rt')

    if logtext:
      output.Log('Opened %s file: %s' % (logtext, path), 1)
    else:
      output.Log('Opened file: %s' % path, 1)
  except __HOLE__:
    output.Error('Can not open file: %s' % path)

  return (frame, file)
#end def OpenFileForRead
dataset/ETHPy150Open benoitc/restkit/doc/sitemap_gen.py/OpenFileForRead