def unpack_file_url(link, location, download_dir=None, hashes=None):
 link_path = url_to_path(link.url_without_fragment)
 if is_dir_url(link):
  if os.path.isdir(location):
   rmtree(location)
  shutil.copytree(link_path, location, symlinks=True)
  if download_dir:
   logger.info('Link is a directory, ignoring download_dir')
  return
 if hashes:
  hashes.check_against_path(link_path)
 already_downloaded_path = None
 if download_dir:
  already_downloaded_path = _check_download_dir(link, download_dir, hashes)
 if already_downloaded_path:
  from_path = already_downloaded_path
 else:
  from_path = link_path
 content_type = mimetypes.guess_type(from_path)[0]
 unpack_file(from_path, location, content_type, link)
 if (download_dir and (not already_downloaded_path)):
  _copy_file(from_path, download_dir, link)

def unpack_file_url ( link , location , download_dir = None , hashes = None ) : link_path = url_to_path ( link . url_without_fragment ) if is_dir_url ( link ) : if os . path . isdir ( location ) : rmtree ( location ) shutil . copytree ( link_path , location , symlinks = True ) if download_dir : logger . info ( 'Link is a directory, ignoring download_dir' ) return if hashes : hashes . check_against_path ( link_path ) already_downloaded_path = None if download_dir : already_downloaded_path = _check_download_dir ( link , download_dir , hashes ) if already_downloaded_path : from_path = already_downloaded_path else : from_path = link_path content_type = mimetypes . guess_type ( from_path ) [ 0 ] unpack_file ( from_path , location , content_type , link ) if ( download_dir and ( not already_downloaded_path ) ) : _copy_file ( from_path , download_dir , link )
unpack link into location .