code: def GetAPFSFileEntryByPathSpec(self, path_spec):
      
      # Opening a file by identifier is faster than opening a file by location.
      location = getattr(path_spec, 'location', None)
      identifier = getattr(path_spec, 'identifier', None)
  
      if identifier is not None:
        fsapfs_file_entry = self._fsapfs_volume.get_file_entry_by_identifier(
            identifier)
      elif location is not None:
        fsapfs_file_entry = self._fsapfs_volume.get_file_entry_by_path(location)
      else:
        raise errors.PathSpecError(
            'Path specification missing location and identifier.')
  
      return fsapfs_file_entry
docs: Retrieves the APFS file entry for a path specification.
  
      Args:
        path_spec (PathSpec): a path specification.
  
      Returns:
        pyfsapfs.file_entry: file entry.
  
      Raises:
        PathSpecError: if the path specification is missing location and
            identifier.