class_docstr: The :class:`GitIgnoreSpec` class extends :class:`pathspec.pathspec.PathSpec` to
  replicate *.gitignore* behavior.
class_docstr_tok: ["The",":","class",":","`","GitIgnoreSpec","`","class","extends",":","class",":","`","pathspec.pathspec.PathSpec","`","to","replicate","*",".gitignore","*","behavior","."]
docstr: Check the file against the patterns.
  
  .. NOTE:: Subclasses of :class:`~pathspec.pathspec.PathSpec` may override
     this method as an instance method. It does not have to be a static
     method. The signature for this method is subject to change.
  
  *patterns* (:class:`~collections.abc.Iterable`) yields each indexed pattern
  (:class:`tuple`) which contains the pattern index (:class:`int`) and actual
  pattern (:class:`~pathspec.pattern.Pattern`).
  
  *file* (:class:`str`) is the normalized file path to be matched against
  *patterns*.
  
  Returns a :class:`tuple` containing whether to include *file* (:class:`bool`
  or :data:`None`), and the index of the last matched pattern (:class:`int` or
  :data:`None`).
docstr_tok: ["Check","the","file","against","the","patterns",".","..","NOTE",":",":","Subclasses","of",":","class",":","`","~pathspec.pathspec.PathSpec","`","may","override","this","method","as","an","instance","method",".","It","does","not","have","to","be","a","static","method",".","The","signature","for","this","method","is","subject","to","change",".","*","patterns","*","(",":","class",":","`","~collections.abc.Iterable","`",")","yields","each","indexed","pattern","(",":","class",":","`","tuple","`",")","which","contains","the","pattern","index","(",":","class",":","`","int","`",")","and","actual","pattern","(",":","class",":","`","~pathspec.pattern.Pattern","`",")",".","*","file","*","(",":","class",":","`","str","`",")","is","the","normalized","file","path","to","be","matched","against","*","patterns","*",".","Returns","a",":","class",":","`","tuple","`","containing","whether","to","include","*","file","*","(",":","class",":","`","bool","`","or",":","data",":","`","None","`",")",",","and","the","index","of","the","last","matched","pattern","(",":","class",":","`","int","`","or",":","data",":","`","None","`",")","."]
code: def _match_file(
      patterns: Iterable[Tuple[int, GitWildMatchPattern]],
      file: str,
  ) -> Tuple[Optional[bool], Optional[int]]:
      """
      Check the file against the patterns.
  
      .. NOTE:: Subclasses of :class:`~pathspec.pathspec.PathSpec` may override
         this method as an instance method. It does not have to be a static
         method. The signature for this method is subject to change.
  
      *patterns* (:class:`~collections.abc.Iterable`) yields each indexed pattern
      (:class:`tuple`) which contains the pattern index (:class:`int`) and actual
      pattern (:class:`~pathspec.pattern.Pattern`).
  
      *file* (:class:`str`) is the normalized file path to be matched against
      *patterns*.
  
      Returns a :class:`tuple` containing whether to include *file* (:class:`bool`
      or :data:`None`), and the index of the last matched pattern (:class:`int` or
      :data:`None`).
      """
      out_include: Optional[bool] = None
      out_index: Optional[int] = None
      out_priority = 0
      for index, pattern in patterns:
          if pattern.include is not None:
              match = pattern.match_file(file)
              if match is not None:
                  # Pattern matched.
  
                  # Check for directory marker.
                  dir_mark = match.match.groupdict().get(_DIR_MARK)
  
                  if dir_mark:
                      # Pattern matched by a directory pattern.
                      priority = 1
                  else:
                      # Pattern matched by a file pattern.
                      priority = 2
  
                  if pattern.include and dir_mark:
                      out_include = pattern.include
                      out_index = index
                      out_priority = priority
                  elif priority >= out_priority:
                      out_include = pattern.include
                      out_index = index
                      out_priority = priority
  
      return out_include, out_index
  
file_path: catboost/contrib/python/pathspec/pathspec/gitignore.py
imports: from typing import AnyStr, Callable, Iterable, Optional, Tuple, Type, TypeVar, Union, cast, overload
  from .pathspec import PathSpec
  from .pattern import Pattern
  from .patterns.gitwildmatch import GitWildMatchPattern, _DIR_MARK
  from .util import _is_iterable
label_desc: Use image node_id 5 for calling the GitIgnoreSpec obj's underlying member method code with example usage: obj._match_file(patterns, file) and returns: out_include,  out_index