def METHOD_NAME(spotfinder,key):
  nwildcard = spotfinder.pd['template'].count('#')
  template_f='#'*nwildcard
  extensn_f='%%0%dd'%nwildcard
  if nwildcard > 0:
    return spotfinder.pd['template'].replace(template_f,extensn_f%key)
  else:
    return spotfinder.pd['template']