code: def guess_archive_type(name):
      '''
      Guess an archive type (tar, zip, or rar) by its file extension
      '''
      name = name.lower()
      for ending in ('tar', 'tar.gz', 'tgz',
                     'tar.bz2', 'tbz2', 'tbz',
                     'tar.xz', 'txz',
                     'tar.lzma', 'tlz'):
          if name.endswith('.' + ending):
              return 'tar'
      for ending in ('zip', 'rar'):
          if name.endswith('.' + ending):
              return ending
      return Nonf guess_archive_type(name):
      '''
      Guess an archive type (tar, zip, or rar) by its file extension
      '''
      name = name.lower()
      for ending in ('tar', 'tar.gz', 'tgz',
                     'tar.bz2', 'tbz2', 'tbz',
                     'tar.xz', 'txz',
                     'tar.lzma', 'tlz'):
          if name.endswith('.' + ending):
              return 'tar'
      for ending in ('zip', 'rar'):
          if name.endswith('.' + ending):
              return ending
      return None
docs: Guess an archive type (tar, zip, or rar) by its file extension