def guess_archive_type(name):
 name = name.lower()
 for ending in ('tar', 'tar.gz', 'tar.bz2', 'tar.xz', 'tgz', 'tbz2', 'txz', 'tar.lzma', 'tlz'):
  if name.endswith(('.' + ending)):
   return 'tar'
 for ending in ('zip', 'rar'):
  if name.endswith(('.' + ending)):
   return ending
 return None

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