import re


def IsValidFolderForType(path, component_type):
  """Checks a folder is named correctly and in a valid tree for component type.

  Args:
    path: a relative path from ontology root with no leading or trailing
      slashes. Path should be the top level for the component.
    component_type: the base_lib.ComponentType that this folder is for.

  Returns:
    True if the path is valid.
  """
  m = re.match(r'(\w*)[/\\]?{0}'.format(component_type.value),
               path)
  if m is None:
    return False
  return True