def ResolveSubjectDestination(subject, regexes):
  components = Components(subject)
  if not components:
    # No components to work with.
    return "aff4", ""
  # Make all the components safe to use.
  path = utils.JoinPath(*[ConvertStringToFilename(x) for x in components])
  for route in regexes:
    m = route.match(path)
    if m:
      value = m.group("path")
      if value:
        base = os.path.basename(value)
        dirname = os.path.dirname(value)
        return base, dirname
  # Default value if nothing else matches.
  return "aff4", ""
Returns the directory/filename where the subject will be stored.
dataset/ETHPy150Open google/grr/grr/lib/data_stores/common.py/ResolveSubjectDestination