# on the original import, for the wfpdb id, only the plate number
# was used.  This processor fixes the wfpdb ids in place.

from gavo import api

class WFPDBIDFixer(api.ImmediateHeaderProcessor):
	def _isProcessed(self, srcName, hdr):
		return "WFPDB-ID" in hdr and len(hdr["WFPDB-ID"])!=5

	def _changeHeader(self, srcName, hdr):
		plateno = hdr["WFPDB-ID"]
		assert len(plateno)==5
		hdr["WFPDB-ID"] = "PAL122 6a0%s"%plateno


if __name__=="__main__":
	api.procmain(WFPDBIDFixer, "plts/q.rd", "import")
