def getRemoteFile(item, setName=''):

	# Get the URL
	response = web.urlopen(item)

	# Get the filename from the URL
	if setName != '':
		name = setName
		fetchName = item.split('/')[-1]
	else:
		name = item.split('/')[-1]
		fetchName = name

	# Enable transferring to target directory
	transfer = 1

	# Display an error message if the file is unavailable because of a 404	
	if response.getcode() == 404:

		vOutput('\rError 404: Failed to fetch ' + name + '\n\n')
		vFlush()
		return

	# Get the "last-modified" information of the file from the file header
	time_data = str(response.info().get('last-modified'))

 	# Output a status message
	vOutput('\rFetching ' + fetchName + '...\n')

	# OS-based delimiter for FS pathnames
	delimit = '/'

	# Set delimiter for Windows
	if platform.system() == 'Windows':
		delimit = '\\'

	# Strip the extension from the filename
	fileID = os.path.splitext(workDir + name)[0].split(delimit)[-1]

	# Check to see if we already have the file in the target directory
	if os.path.isfile(targetDir + fileID + '.tar.gz') != 1:

		targetPath = 0

	else:

		targetPath = 1

	if os.path.isfile(workDir + name) == 1:

		# Get the "last-modified" information of the file from the remote file
		local = os.stat(workDir + name).st_mtime

		# Make sure the response value is set before we attempt to download the file
		if time_data != 'None':

			# Convert the "time_data" output to an number thats compatible with the local file
			server = time.mktime(time.strptime(time_data, "%a, %d %b %Y %H:%M:%S GMT"))

		else:

			server = int(local + 1)

		# Compare the "last-modified" dates of the local file and the remote file
		if server < local:

			# Fetch the file if the remote version is newer than the local version
			web.urlretrieve(response.geturl(), workDir + name, reporthook=report)

		else:

			# Turn off transfer mode if the compressed file exits in the targetDir path. If not we will transfer.
			if targetPath != 0: 

				# Turn off transfer because we dont need it.
				transfer = 0

		# Output a status message
		vOutput('\r' + name + ' is up-to-date.\n\n')

	else:
		# Fetch the file
		web.urlretrieve(response.geturl(), workDir + name, reporthook=report)
		vOutput("\rDownload complete, saved as %s" % (name) + '\n\n')

	# Transfer & compress the files
	if transfer != 0:

		# Copy the files in the temp directory to the target directory
		allFiles = glob.glob(workDir + '*.*')
		filePath = workDir + name
		vOutput('\rTransferring ' + name + '...\n');
		shutil.copy(filePath,targetDir);
		vOutput("\rTransfer complete, saved as %s" % (name) + '\n\n');
	
		# Create a list with list comprehension & compress files in the target directory
		allFiles = glob.glob(targetDir + '*.*')

		for filePath in allFiles:

			if "tar.gz" not in filePath:

				thisFile = filePath.split(delimit)[-1]
				tarHandler = tarfile.open(targetDir + fileID + ".tar.gz", "w:gz")
				vOutput('\rCompressing ' + thisFile + '...\n');
				tarHandler.add(filePath);
				os.remove(filePath); vOutput("\rCompression complete, saved as %s" % (fileID + '.tar.gz') + '\n\n');

	# Flush vOutput
	vFlush()

# Most items can be added to the list without preprocesing
dataset/ETHPy150Open abbotto/comsys/comsys.py/getRemoteFile/swapped operands of `<`