code: def ext_from_filename(filename):
      
      try:
          base, ext = filename.lower().rsplit(".", 1)
      except ValueError:
          return ''
      ext = ".{0}".format(ext)
      all_exts = [x.extension for x in chain(magic_header_array,
                                             magic_footer_array)]
  
      if base[-4:].startswith("."):
          # For double extensions like like .tar.gz
          long_ext = base[-4:] + ext
          if long_ext in all_exts:
              return long_ext
      return ext
docs: Scan a filename for it's extension.
  
      :param filename: string of the filename
      :return: the extension off the end (empty string if it can't find one)