<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def rewrite_policy(self,cspDefaultHeaders):
 		""" fresh csp policy """

		try:
			self.check_valid(cspDefaultHeaders)
			if self.inputs is not None:
				for p,l in cspDefaultHeaders.items():
					if p in self.inputs:
						cspDefaultHeaders[p] = self.inputs[p]
					else:
						cspDefaultHeaders[p] = []
				return cspDefaultHeaders
			else:
				return self.inputs
		except Exception, e:
			raise