code: def expand_filenames(self, filenames):
          
          results = []
          for filename in filenames:
              result = filename
              if "$" in filename:
                  template = Template(filename)
                  result = template.substitute(**self.environment)
                  logging.debug(
                      "Expanding {} to {}.".format(filename, result))
              if any([pattern in result for pattern in "*[]?"]):
                  expanded = glob.glob(result)
                  if len(expanded) > 0:
                      result = expanded
                  else:
                      result = "NONEXISTENT"
              if isinstance(result, list):
                  results.extend(result)
              else:
                  results.append(result)
          return sorted(list(set(results)))
docs: Expand a list of filenames using environment variables,
          followed by expansion of shell-style wildcards.