def exportBlendShapes():
	"""Exports sparse blendShape data from the scene for each mesh with a
	blendShape deformer in its history. This is accomplished by duplicating
	the mesh and tagging vertices in the duplicate using vertex colors. The
	duplicate then stores all of the data as user properties."""
	
	# find all of the potential models in the scene
	models = om.MSelectionList()
	for model in cmds.ls(transforms=True): models.add(model)
	
	# store a dictionary mapping models whose shapes have a blendShape upstream to all of their blendShape nodes
	modelsWithBlendShapeDeformers = {}
	dagPath = om.MDagPath()
	iter = om.MItSelectionList(models)
	while not iter.isDone():
		iter.getDagPath(dagPath)
		model = om.MDagPath(dagPath)
		try:
			# ensure the current transform has a shape node
			dagPath.extendToShape()
			# search upstream from shape for all blendShape nodes
			dg = om.MItDependencyGraph(dagPath.node(), om.MFn.kBlendShape, om.MItDependencyGraph.kUpstream)
			while not dg.isDone():
				# add the blendShape nodes to a list in the dictionary
				if not modelsWithBlendShapeDeformers.has_key(model):
					modelsWithBlendShapeDeformers[model] = []
				modelsWithBlendShapeDeformers[model].append(dg.currentItem())
				dg.next()
		except: pass
		iter.next()
	
	# create tagged duplicates for each model with blendShapes and its targets
	for model in modelsWithBlendShapeDeformers.keys():
		
		# delete non-deformer history on the model in order to collapse intermediate nodes
		# model will come into Unity wrong, but at least not with ugly error
		cmds.select(model.partialPathName())
		mel.eval('doBakeNonDefHistory( 1, {"prePost" });')
		cmds.select(cl=True)
		
		# zero all blendShape target weights on the model
		for blendNode in modelsWithBlendShapeDeformers[model]:
			fn = om.MFnDependencyNode(blendNode)
			aliases = cmds.aliasAttr(fn.name(), q=True)
			for alias in aliases:
				# skip non-weight attributes
				if not re.match('weight\[[0-9]+\]', alias): continue
				dest = '%s.%s'%(fn.name(), alias)
				source = cmds.listConnections(dest, p=True)
				if source: cmds.disconnectAttr(source[0], dest)
				cmds.setAttr(dest, 0.0)
		
		# duplicate the base mesh and indicate that it is the base index map
		taggedBaseMesh = cmds.duplicate(model.partialPathName())[0]
		taggedBaseMesh = cmds.rename(taggedBaseMesh, model.partialPathName()+'__blendShapeIndexMap')
		customAttrs = cmds.listAttr(taggedBaseMesh, ud=True)
		if (customAttrs):	
			for attr in customAttrs:
				try: cmds.deleteAttr(taggedBaseMesh, at=attr)
				except: pass
		cmds.addAttr(taggedBaseMesh, ln='isBlendShapeMapFor', dt='string')
		cmds.setAttr('%s.isBlendShapeMapFor'%taggedBaseMesh, model.partialPathName(), type='string')
		
		# tag each vertex in the base shape duplicate
		dagPath = om.MDagPath()
		sel = om.MSelectionList()
		sel.add(taggedBaseMesh)
		sel.getDagPath(0, dagPath)
		dagPath.extendToShape()
		tagMesh(dagPath)
		
		# duplicate the tagged base mesh to create the seamless base mesh
		seamlessBaseMesh = cmds.duplicate(taggedBaseMesh)[0]
		seamlessBaseMesh = cmds.rename(seamlessBaseMesh, model.partialPathName()+'__seamlessBaseMesh')
		for attr in cmds.listAttr(seamlessBaseMesh, ud=True):
			try: cmds.deleteAttr(seamlessBaseMesh, at=attr)
			except: pass
		makeSeamless(seamlessBaseMesh)
		# link seamless mesh to tagged base shape
		cmds.addAttr(seamlessBaseMesh, ln='isSeamlessBaseMeshFor', dt='string')
		cmds.setAttr('%s.isSeamlessBaseMeshFor'%seamlessBaseMesh, taggedBaseMesh, type='string')
		# make the seamless base mesh a child of the tagged base mesh, in order to avoid creating additional roots
		cmds.parent(seamlessBaseMesh, taggedBaseMesh)
		
		# create a color-tagged copy of each target, linked back to the tagged base shape via user properties
		for blendNode in modelsWithBlendShapeDeformers[model]:
			fn = om.MFnDependencyNode(blendNode)
			aliases = cmds.aliasAttr(fn.name(), q=True)
			for alias in aliases:
				# skip weight attributes
				if re.match('weight\[[0-9]+\]', alias): continue
				# create a duplicate of the composite shape and convert it into a seamless mesh
				cmds.setAttr('%s.%s'%(fn.name(), alias), 1.0)
				taggedTarget = cmds.duplicate(model.partialPathName())[0]
				attrs = cmds.listAttr(taggedTarget, ud=True)
				if (attrs):
					for attr in attrs:
						try: cmds.deleteAttr(taggedTarget, at=attr)
						except: pass
				taggedTarget = cmds.rename(taggedTarget, (model.partialPathName(), alias)%'%s__blendShapeTarget__%s')
				makeSeamless(taggedTarget)
				cmds.setAttr('%s.%s'%(fn.name(), alias), 0.0)
				# tag the duplicated target
				dagPath = om.MDagPath()
				sel = om.MSelectionList()
				sel.add(taggedTarget)
				sel.getDagPath(0, dagPath)
				dagPath.extendToShape()
				tagMesh(dagPath)
				# link target to tagged base shape
				cmds.addAttr(taggedTarget, ln='isBlendShapeTargetFor', dt='string')
				cmds.setAttr('%s.isBlendShapeTargetFor'%taggedTarget, taggedBaseMesh, type='string')
				# make the tagged mesh a child of the tagged base mesh, in order to avoid creating additional roots
				cmds.parent(taggedTarget, taggedBaseMesh)
	
		# make the tagged mesh a child of the original, in order to avoid creating additional roots
		cmds.parent(taggedBaseMesh, model.partialPathName())
dataset/ETHPy150Open CountZer0/PipelineConstructionSet/python/maya/site-packages/amTools/unity/blendShapes.py/exportBlendShapes/swapped operands of `%`