parameters: (filename)
docstring: Search file for Amiga AGI game palettes and return any found unique palettes
docstring_summary: Search file for Amiga AGI game palettes and return any found unique palettes
docstring_tokens: Search file for Amiga AGI game palettes and return any found unique palettes
function: def searchForAmigaPalettes(filename):
  	"""Search file for Amiga AGI game palettes and return any found unique palettes"""
  	try:
  		file = None
  		foundPalettes = []
  		# Open file and read it into memory
  		file = open(filename, 'rb')
  		data = file.read()
  		palette = [decodedBlack for x in range(colorsPerPalette)]
  		# Search through the whole file
  		for searchPosition in range(len(data) - bytesPerPalette + 1):
  			if preliminaryPaletteTest(data, searchPosition):
  				# Parse possible palette from byte data
  				for colorNum in range(colorsPerPalette):
  					colorStart = searchPosition + colorNum * bytesPerColor
  					colorEnd   = colorStart + bytesPerColor
  					# Parse color components as unsigned 16-bit big endian integers
  					color = struct.unpack('>' + 'H' * componentsPerColor, data[colorStart:colorEnd])
  					palette[colorNum] = color
  				# Save good candidates to a list
  				if isAmigaPalette(palette):
  					foundPalettes.append(tuple(palette))
  		# Close source file and return unique found palettes
  		file.close()
  		return set(foundPalettes)
  	except IOError:
  		if file != None:
  			file.close()
  		return None
function_tokens: def searchForAmigaPalettes ( filename ) : try : file = None foundPalettes = [ ] # Open file and read it into memory file = open ( filename , 'rb' ) data = file . read ( ) palette = [ decodedBlack for x in range ( colorsPerPalette ) ] # Search through the whole file for searchPosition in range ( len ( data ) - bytesPerPalette + 1 ) : if preliminaryPaletteTest ( data , searchPosition ) : # Parse possible palette from byte data for colorNum in range ( colorsPerPalette ) : colorStart = searchPosition + colorNum * bytesPerColor colorEnd = colorStart + bytesPerColor # Parse color components as unsigned 16-bit big endian integers color = struct . unpack ( '>' + 'H' * componentsPerColor , data [ colorStart : colorEnd ] ) palette [ colorNum ] = color # Save good candidates to a list if isAmigaPalette ( palette ) : foundPalettes . append ( tuple ( palette ) ) # Close source file and return unique found palettes file . close ( ) return set ( foundPalettes ) except IOError : if file != None : file . close ( ) return None