<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def Scan(self, scan_context, auto_recurse=True, scan_path_spec=None):
 """Scans for supported formats. Args: scan_context (SourceScannerContext):
 source scanner context. auto_recurse (Optional[bool]):
 True if the scan should automatically recurse as far as possible. scan_path_spec (Optional[PathSpec]):
 path specification to indicate where the source scanner should continue scanning, where None indicates the scanner will start with the sources. Raises: ValueError: if the scan context is invalid. """

    if not scan_context:
      raise ValueError('Invalid scan context.')

    scan_context.updated = False

    if scan_path_spec:
      scan_node = scan_context.GetScanNode(scan_path_spec)

    else:
      scan_node = scan_context.GetUnscannedScanNode()

    if scan_node:
      self._ScanNode(scan_context, scan_node, auto_recurse=auto_recurse)