K idZddlmZmZmZmZmZmZmZm Z m Z m Z ddl m Z ddlmZddlmZmZddlmZedd Z Gd d e Zy ) zV This module provides :class:`.GitIgnoreSpec` which replicates *.gitignore* behavior. ) AnyStrCallableIterableOptionalTupleTypeTypeVarUnioncastoverload)PathSpec)Pattern)GitWildMatchPattern _DIR_MARK) _is_iterableSelf GitIgnoreSpec)boundc `eZdZdZdedeffd Zeede e de e e egeffdeede fdZee dde e deede e e egefd fde fd Ze dde e deede e e egefd fde ffd Zed eeeefd e deeeeeffdZxZS)rzu The :class:`GitIgnoreSpec` class extends :class:`pathspec.pathspec.PathSpec` to replicate *.gitignore* behavior. otherreturncpt|trt| |St|tryt S)z Tests the equality of this gitignore-spec with *other* (:class:`GitIgnoreSpec`) by comparing their :attr:`~pathspec.pattern.Pattern` attributes. A non-:class:`GitIgnoreSpec` will not compare equal. F) isinstancersuper__eq__rNotImplemented)selfr __class__s X/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/pathspec/gitignore.pyrzGitIgnoreSpec.__eq__)s1 }% '. %"  clspattern_factorylinescyN)r"r#r$s r from_lineszGitIgnoreSpec.from_lines7r!Ncyr&r')r"r$r#s r r(zGitIgnoreSpec.from_lines@r)r!c|t}n0t|ttfs t |rt |r||}}t |||}tt|S)a Compiles the pattern lines. *lines* (:class:`~collections.abc.Iterable`) yields each uncompiled pattern (:class:`str`). This simply has to yield each line so it can be a :class:`io.TextIOBase` (e.g., from :func:`open` or :class:`io.StringIO`) or the result from :meth:`str.splitlines`. *pattern_factory* can be :data:`None`, the name of a registered pattern factory (:class:`str`), or a :class:`~collections.abc.Callable` used to compile patterns. The callable must accept an uncompiled pattern (:class:`str`) and return the compiled pattern (:class:`pathspec.pattern.Pattern`). Default is :data:`None` for :class:`.GitWildMatchPattern`). Returns the :class:`GitIgnoreSpec` instance. ) rrstrbytescallablerrr(r r)r"r$r#rrs r r(zGitIgnoreSpec.from_linesIsR.(?53,'8E? _@]!?E?  OU 3$ dD r!patternsfilec>d}d}d}|D]\}}|j|j|}|'|jjj t }|rd} nd} |jr|r|j}|}| }z| |k\s|j}|}| }||fS)a 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`). Nrr )include match_filematch groupdictgetr) r/r0 out_include out_index out_priorityindexpatternr5dir_markprioritys r _match_filezGitIgnoreSpec._match_filejs.!%+!), neW oo!   t $E  %%'++I6XhhHOOkil l "OOkil/2 i r!r&)__name__ __module__ __qualname____doc__objectboolrr classmethodrrr r,rrrrr( staticmethodrintrrr? __classcell__)rs@r rr#s  D    Dzhx'899: &     DH Dz & hx'894?@  DH Dz & hx'894?@ @2 U3 334 52  2  HTNHSM )*2 2 r!N)rCtypingrrrrrrr r r r pathspecrr<rpatterns.gitwildmatchrrutilrrrr'r!r rNsN       v_- z Hz r!