yL i&] PdZgdZddlmZmZddlZddlmZddlmZm Z m Z ddl Z ddl m Z ddlZddlZddlmZmZmZdd lmZmZmZmZmZmZmZmZmZmZmZm Z m!Z!dd l"m#Z#m$Z$er7dd l%m&Z&m'Z'dd l(m)Z)dd l"m*Z*m+Z+ddl,m-Z-ddl.m/Z/ddl0m1Z1ddl2m3Z3ddl4m5Z5m6Z6neZ*dZ+GddeZ7eddZ8eeeddfdfZ9e dZ:dee;ed e;deed!ed"ed#ed$ffd%Z?d&ez/Utility functions for working with git objects.) get_object_type_by_name parse_dateparse_actor_and_dateProcessStreamAdapter Traversablealtz_to_utctz_str utctz_to_altz verify_utctzActortzoffsetutc)ABCabstractmethodN)deque)datetime timedeltatzinfo)digits)r IterableList IterableObj) AnyCallableDequeIterator NamedTupleSequence TYPE_CHECKINGTupleTypeTypeVarUnioncastoverload)Has_id_attributeLiteral)BytesIOStringIO)Popen)Protocolruntime_checkable)Blob)Commit) Submodule) TagObject)TraversedTreeTupTreec|SN)fs V/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/git/objects/util.pyr*r*Csc8eZdZUeed<eded<eded<y) TraverseNTdepthrr,itemrNsrcN)__name__ __module__ __qualname__int__annotations__r!r4r7r6r9r9Gs J % && " ##r7r9T_TIobjTraversableIterableObj)boundr=rr0modestrreturncd}tt|ddD]6\}}tttt f|}|t ||dzzz }8|S)aConvert mode bits from an octal mode string to an integer mode for git. :param modestr: String like ``755`` or ``644`` or ``100644`` - only the last 6 chars will be used. :return: String identifying a mode compatible to the mode methods ids of the :mod:`stat` module regarding the rwx permissions for user, group and other, special flags and file system flags, such as whether it is a symlink. r N) enumeratereversedr"r!strrB)rGmode iterationchars r6mode_str_to_intrR[s^ D$Xgbcl%;<+ 4E#s(OT* D Y]**+ Kr7object_type_namer-r/r1r,c|dk(rddlm}|jS|dk(rddlm}|jS|dk(rddlm}|j S|dk(rdd lm}|jStd |jz) aRetrieve the Python class GitPython uses to represent a kind of Git object. :return: A type suitable to handle the given as `object_type_name`. This type can be called create new instances. :param object_type_name: Member of :attr:`Object.TYPES `. :raise ValueError: If `object_type_name` is unknown. scommitr+)commitstag)tagsblob)blobstree)treez%Cannot handle unknown object type: %s) rUr-rVr/rWr,rXr1 ValueErrordecode)rSrUrVrWrXs r6rross9$}} V #}} W $yy W $yy@CSCZCZC\\]]r7utctzcrt|}t|dzdzt|dzdzz}|dkr|S| S)zConvert a git timezone offset into a timezone offset west of UTC in seconds (compatible with :attr:`time.altzone`). :param utctz: git utc timezone string, e.g. +0200 d<r )rBabs)r\ int_utctzsecondss r6rrsFE I9~$,I0D/JJG!m71'1r7altzcxt|dz}t|dzdz}|dk\rdnd}dj|||S)zConvert a timezone offset west of UTC in seconds into a Git timezone offset string. :param altz: Timezone offset in seconds west of UTC. r_r`-+z {}{:02}{:02})raformat)rdhoursminutessigns r6rrsG I E4y4B&G"*3#D  ug 66r7offsetctd|z}t|dk7r||ddvr||dtvs!|dtvs|dtvs |dtvr||S) z] :raise ValueError: If `offset` is incorrect. :return: `offset` z"Invalid timezone offset format: %sr z+-r+rK)rZlenr)rlfmt_excs r6r r sq=FGG 6{a  ay  ay&)6"9VAYf=TX^_`XaioXo Mr7ceZdZd dededefddfdZdeedeeefffdZ dee dfde fdZ dee dfdefd Z dee dfde fd Zy) r Nsecs_west_of_utcnamerHc>t| |_|xsd|_y)N)rcfixed)r_offset_name)selfrtrus r6__init__ztzoffset.__init__s *:):; _W r7c\t|jj |jffSr3)r rx total_secondsryrzs r6 __reduce__ztzoffset.__reduce__s&4<<5577DDDr7dtc|jSr3)rxrzrs r6 utcoffsetztzoffset.utcoffsets ||r7c|jSr3)ryrs r6tznameztzoffset.tznames zzr7ctSr3)ZEROrs r6dstz tzoffset.dsts r7r3)r?r@rAfloatr!rNr{rrrrrrrrr4r7r6r r s%%eD#I6F%RV%EE$z"2E%*4E"EFEE(D.1ix~.3eHdN+ r7r UTC timestamp tz_offsetctj|t} |jt |}|S#t $r|cYSwxYw)z[Convert a `timestamp` + `tz_offset` into an aware :class:`~datetime.datetime` instance.)r fromtimestampr astimezoner rZ)rrutc_dtlocal_dts r6from_timestamprsI # #Is 3F$$Xi%89  s8 AA string_datec t|tr|jrftt|j }t |j }t |jtj|fStd| |jddk(r^|jddk(rJ|j\}}|jdr|dd}t |}|t!t#|fSd}|d d vrt#|d d}|dd }t!|}g}d}d |vr#|j%d |jd}nk|j%d|j%d|j%d|j%d|jd}|dk(r|jd}|dkDsJ||dzd}|d|} t'j(|d} |D]} t'j(| | } t+j,| j.| j0| j2| j4| j6| j8| j:| j<| j>f } t | |fcStd#t$rYwxYw#t@$r }td|dtC||d}~wwxYw)a Parse the given date as one of the following: * Aware datetime instance * Git internal format: timestamp offset * :rfc:`2822`: ``Thu, 07 Apr 2005 22:13:13 +0200`` * ISO 8601: ``2005-04-07T22:13:13`` - The ``T`` can be a space as well. :return: Tuple(int(timestamp_UTC), int(offset)), both in seconds since epoch :raise ValueError: If the format could not be understood. :note: Date can also be ``YYYY.MM.DD``, ``MM/DD/YYYY`` and ``DD.MM.YYYY``. z,string_date datetime object without tzinfo,  r+:@Nz+0000z-+rJ,z %a, %d %b %Yz%Y-%m-%dz%Y.%m.%dz%m/%d/%Yz%d.%m.%YTz%H:%M:%Szno format matchedz!Unsupported date format or type: z, type=)" isinstancerrr"rrrBr}rr rrZcountrfindsplit startswithrr appendtimestrptimecalendartimegmtm_yeartm_montm_mdaytm_hourtm_mintm_sectm_wdaytm_ydaytm_isdst Exceptiontype)rrrlr offset_str timestamp_int date_formatssplitter time_part date_parttstructfmtdtstructutctimees r6rrs"+x(   Y (=(=(?@I)11344F{--c2<<>?G GKK=YZ ZEm   S !Q &;+<+*005Hb= =$HqLN3I#IX.ImmIz:G# #}}Y 1191999972 -0700 :return: [Actor, int_seconds_since_epoch, int_timezone_offset] )rY0rr+rY) _re_actor_epochsearchgroups_re_only_actorgroupr _from_stringrBr)ractorepochrlms r6rrFs{(E5&t$A xxzuf  ! !$ ' TZR   u %s5z=3H IIr7c8eZdZdZdZdddeddfdZd edefd Zy) ra%Class wiring all calls to the contained Process instance. Use this type to hide the underlying process to provide access only to a specified stream. The process is usually wrapped into an :class:`~git.cmd.Git.AutoInterrupt` class to kill it if the instance goes out of scope. )_proc_streamprocessr( stream_namerHNc4||_t|||_yr3)rgetattrr)rzrrs r6r{zProcessStreamAdapter.__init__hs !(+!> r7attrc.t|j|Sr3)rr)rzrs r6 __getattr__z ProcessStreamAdapter.__getattr__lst||T**r7) r?r@rA__doc__ __slots__rNr{rrr4r7r6rr^s;%I??c?d?+++r7rc.eZdZdZdZeedededfdZ edededefdZ dd e dedede e d fd Zedededefd Zddddddd fdee ddefege fdee ddefege fdede de ded e de ee deeffdZy)rauSimple interface to perform depth-first or breadth-first traversals in one direction. Subclasses only need to implement one function. Instances of the subclass must be hashable. Defined subclasses: * :class:`Commit ` * :class:`Tree ` * :class:`Submodule ` r4r<rHctd)aA :return: Tuple of items connected to the given item. Must be implemented in subclass. class Commit:: (cls, Commit) -> Tuple[Commit, ...] class Submodule:: (cls, Submodule) -> Iterablelist[Submodule] class Tree:: (cls, Tree) -> Tuple[Tree, ...] To be implemented in subclassNotImplementedError)clsr<s r6_get_intermediate_itemsz#Traversable._get_intermediate_items""ABBr7argskwargsc^tjdtd|j|i|S)zTraverse self and collect all items found. Calling this directly on the abstract base class, including via a ``super()`` proxy, is deprecated. Only overridden implementations should be called. zlist_traverse() method should only be called from subclasses. Calling from Traversable abstract class will raise NotImplementedError in 4.0.0. The concrete subclasses in GitPython itself are 'Commit', 'RootModule', 'Submodule', and 'Tree'.ro stacklevel)warningswarnDeprecationWarning_list_traverserzrrs r6 list_traversezTraversable.list_traverses8   p   #t""D3F33r7Fas_edge)r-r.r1r,ct|tr |j}nd}|s0t|}|j |j |d|i||St|j |i|}|S)ajTraverse self and collect all items found. :return: :class:`~git.util.IterableList` with the results of the traversal as produced by :meth:`traverse`:: Commit -> IterableList[Commit] Submodule -> IterableList[Submodule] Tree -> IterableList[Union[Submodule, Tree, Blob]] rYr)rr$_id_attribute_rextendtraverse)rzrrridoutout_lists r6rzTraversable._list_traversesx d, -$$BBNZ[]N^C JJ}t}}tFWFvF GJ &2-$--2P2P%QHOr7c^tjdtd|j|i|S)zIterator yielding items found when traversing self. Calling this directly on the abstract base class, including via a ``super()`` proxy, is deprecated. Only overridden implementations should be called. ztraverse() method should only be called from subclasses. Calling from Traversable abstract class will raise NotImplementedError in 4.0.0. The concrete subclasses in GitPython itself are 'Commit', 'RootModule', 'Submodule', and 'Tree'.ror)rrr _traversers r6rzTraversable.traverses6   p   t~~t.v..r7cyNTr4ids r6zTraversable.r7cyNFr4rs r6rzTraversable.rr7rTr+ predicater,pruner: branch_first visit_once ignore_selfr;c #Kt}t} | jtdddttdddt dt ddf fd } | rw| j\} } |r|vr|r|j|r| f} n} || | rC|xru}|s || | r| | d z}|d kDr||kDrj| | ||| rvyyw) aIterator yielding items found when traversing `self`. :param predicate: A function ``f(i,d)`` that returns ``False`` if item i at depth ``d`` should not be included in the result. :param prune: A function ``f(i,d)`` that returns ``True`` if the search should stop at item ``i`` at depth ``d``. Item ``i`` will not be returned. :param depth: Defines at which level the iteration should not go deeper if -1. There is no limit if 0, you would effectively only get `self`, the root of the iteration. If 1, you would only get the first level of predecessors/successors. :param branch_first: If ``True``, items will be returned branch first, otherwise depth first. :param visit_once: If ``True``, items will only be returned once, although they might be encountered several times. Loops are prevented that way. :param ignore_self: If ``True``, `self` will be ignored and automatically pruned from the result. Otherwise it will be the first item to be returned. If `as_edge` is ``True``, the source of the first edge is ``None``. :param as_edge: If ``True``, return a pair of items, first being the source, second the destination, i.e. tuple(src, dest) with the edge spanning from source to destination. :return: Iterator yielding items found when traversing `self`:: Commit -> Iterator[Union[Commit, Tuple[Commit, Commit]] Submodule -> Iterator[Submodule, Tuple[Submodule, Submodule]] Tree -> Iterator[Union[Blob, Tree, Submodule, Tuple[Union[Submodule, Tree], Union[Blob, Tree, Submodule]]] ignore_self=True is_edge=True -> Iterator[item] ignore_self=True is_edge=False --> Iterator[item] ignore_self=False is_edge=True -> Iterator[item] | Iterator[Tuple[src, item]] ignore_self=False is_edge=False -> Iterator[Tuple[src, item]] r Nstacksrc_itemrrr:rHcjsy|r|jfdDyfdttdz ddD}|j |y)Nc38K|]}t|ywr3r9).0rr:rs r6 z.addToStack..s MAE1h!? Msc3>K|]}t|ywr3r)rrr:lstrs r6rz.addToStack..sd1:eSVX>dsr+r)r extendleftrangerqr)rrrr:reviterrr<rzs ` ` @r6 addToStackz)Traversable._traverse..addToStacks] ..t4C  M MMdcRUhYZl\^`bHcd W%r7r+r) setrrr9rboolrBpopadd)rzrrr:rrrrvisitedrr rr>rval skipStartItemnext_dr<s` @r6rzTraversable._traversest%#(7 Z4./ &$ &# & & &  &" 99;LAtSdgo D!T{T1~':TT\M YtQ%7 UFrzfun udL& 9;s C CCN)F)r?r@rArr classmethodrrrrrrrr!rrr TraversedTuprBrrr4r7r6rrps I C3 C8M3J C C 43 4# 4# 4 4 $!!,/!;>! eAB C!F /c /S /S / /"XiSe!l:U=&,#FGMtSTl:}flBCSI4OPl: l:  l:  l:l:l: x345x 7MM Nl:r7c$eZdZdZdZddZddZy) SerializablezUDefines methods to serialize and deserialize objects from and into a data stream.r4ctd)aSerialize the data of this object into the given data stream. :note: A serialized object would :meth:`_deserialize` into the same object. :param stream: A file-like object. :return: self rrrzstreams r6 _serializezSerializable._serializeKrr7ctd)zDeserialize all information regarding this object from the stream. :param stream: A file-like object. :return: self rrrs r6 _deserializezSerializable._deserializeZs""ABBr7N)rr&rHr)r?r@rArrrrr4r7r6rrCsI C Cr7rceZdZdZeeedfefZdededede effd Z e dede efdZ e ded eeeeeedfeffegefd eeeeeedfeffegefd ed ed ededdedde efdZ e ded eeeeeedfeffegefd eeeeeedfeffegefd ed ed ededdedde eeedfeffdZ e ded eeeefegefd eeeefegefd ed ed ededdedde eeeffdZ dddddddfded eeeefegefd eeeefegefd ed ed edededee ee eeefe efffd Z xZS)rEr4NrzrrrHc"t||i|Sr3)superr)rzrr __class__s r6rz$TraversableIterableObj.list_traverseksw%t6v66r7cyr3r4r~s r6rzTraversableIterableObj.traversens69r7rrr:rrrTrFcyr3r4rzrrr:rrrrs r6rzTraversableIterableObj.traverseqs r7cyr3r4r%s r6rzTraversableIterableObj.traverse}s:=r7cyr3r4r%s r6rzTraversableIterableObj.traverses-0r7cyrr4rs r6rzTraversableIterableObj.rr7cyrr4rs r6rzTraversableIterableObj.rr7rr+c tttttttdtftfft ||||||||S)z5For documentation, see :meth:`Traversable._traverse`.N)r"r!rrDrr!r) rzrrr:rrrrr"s r6rzTraversableIterableObj.traverses^8 (7#XeE$-4H'4Q.R%SS T G    r7)r?r@rArrr!rD TIobj_tuplerrrr#rrrrBrr% __classcell__)r"s@r6rErEfsIgtm,g56K7G7C737DE 0w 34c:D@A 0 0  0  0T] 0 0 %() * 0 0IZDV!' ' U7K#78#>DE' w 34c:D@A'  '  '  ' ' '  x (5'1A+B"CXkEZZ [' ' r7)Pr__all__abcrrr collectionsrrrrrestringrrrgit.utilr rrtypingrrrrrrrrrr r!r"r# git.typesr$r%ior&r' subprocessr(r)r*rWr,rUr-submodule.baser.rVr/rXr0r1r9rDrrbytesrNrBrRrrrrr r r rrcompilerrrrrrrEr4r7r6r:sH 6 $00  55 0$ 5),,H$$ )#; < %# $m 34 | U5#:.3( ^ ^ 4>4 ,d6lDL HI ^F 2 2 2 7E 7c 7&v$q%e(_mE#x-0_mU38__mH"**<=M*JsJuUC_'=J0++$N:(N:N:dC8CCDV [+V r7