def template_format(template):
    """Parse template string to identify digit formatting,
    e.g. a template med#####.xml.gz will give output (#####, {:05})
    """

    num_hashes = sum([1 for c in template if c == "#"])
    return "#"*num_hashes, "{:0" + str(num_hashes) + "}"