CUVQhj dZddlmZmZddlZddlmZmZmZddl Z ddl m Z ddl m Z ddlZddlZddlmZmZmZddlmZmZmZmZmZmZmZmZmZmZmZmZm Z m!Z!dd l"m#Z#m$Z$m%Z%er7dd l&m'Z'm(Z(d d l)m*Z*d d l+m,Z,d dl-m.Z.d dl/m0Z0m1Z1ddl2m3Z3d dl4m5Z5ddl"m6Z6m7Z7neZ6dZ7GddeZ8eddZ9e ee ddfdfZ:dZ;edZfde?fdZ@d e=de ed!ed"ed#ed$ffd%ZAd&e>de?fd'ZBd(e?de>fd)ZCd*e>de>fd+ZDGd,d-eZEeEdd.ZFd/eGd0eGdefd1ZHd2e e>efdee?e?ffd3ZIe jJd4ZKe jJd5ZLd6e>deee?e?ffd7ZMGd8d9eNZOe7Gd:de6ZPe7Gd;dz$Module for general utility functions)ABCabstractmethodN) IterableList IterableObjActor)deque)digits)datetime timedeltatzinfo)AnyCallableDequeIteratorGeneric NamedTupleoverloadSequence TYPE_CHECKINGTupleTypeTypeVarUnioncast)Has_id_attributeLiteral_T)BytesIOStringIO)Commit)Blob) TagObject)TreeTraversedTreeTup)Popen) Submodule)Protocolruntime_checkablec|SN)fs /srv/buildsys-work-dir/castor/build_node/builder-2/WGSG1/unpkd_srcs/cloudlinux-venv-1.0.6/venv/lib/python3.11/site-packages/git/objects/util.pyr)r)7scFeZdZUeed<eded<eded<dS) TraverseNTdepth Traversabler"itemr4NsrcN)__name__ __module__ __qualname__int__annotations__rr,r/r.r1r1;s? JJJ % &&&& " ######r/r1T_TIobjTraversableIterableObj)boundr6r4r%) get_object_type_by_name parse_dateparse_actor_and_dateProcessStreamAdapterr4altz_to_utctz_str utctz_to_altz verify_utctzrtzoffsetutcmodestrreturncd}tt|ddD]D\}}tttt f|}|t ||dzzz }E|S)a_ :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 stat module regarding the rwx permissions for user, group and other, special flags and file system flags, i.e. whether it is a symlink for example.rN) enumeratereversedrrstrr;)rImode iterationchars r.mode_str_to_intrT]sk D$Xgbccl%;%;<<++ 4E#s(OT** D Y]** Kr/object_type_namer!r#r$r"c|dkr ddlm}|jS|dkr ddlm}|jS|dkr ddlm}|jS|dkr dd lm}|jStd | z) z :return: type suitable to handle the given object type name. Use the type to create new instances. :param object_type_name: Member of TYPES :raise ValueError: In case object_type_name is unknownscommitr )commitstag)tagsblob)blobstree)treez%Cannot handle unknown object type: %s) rWr!rXr#rYr"rZr$ ValueErrordecode)rUrWrXrYrZs r.r@r@ms9$$} V # #} W $ $y W $ $y@CSCZCZC\C\\]]]r/utctzct|}t|dzdzt|dzdzz}|dkr|n| S)zConvert a git timezone offset into a timezone offset west of UTC in seconds (compatible with time.altzone). :param utctz: git utc timezone string, i.e. +0200 d<r)r;abs)r^ int_utctzsecondss r.rErEsM E II#%-Y#1E0KKG!mm77'1r/altzct|dz}t|dzdz}|dkrdnd}d|||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 rarb-+z {}{:02}{:02})rcformat)rfhoursminutessigns r.rDrDsR II E4yy4B&G"**33#D  ug 6 66r/offsetctd|z}t|dkr||ddvr||dtvs-|dtvs|dtvs|dtvr||S) z=:raise ValueError: if offset is incorrect :return: offsetz"Invalid timezone offset format: %srz+-r rM)r\lenr )rnfmt_excs r.rFrFs=FGGG 6{{a  ay  ay&)6"9"9VAYf=T=TX^_`XaioXoXo Mr/ceZdZd dededefddfdZdeedeeefffdZ dee dfde fdZ dee dfdefd Z dee dfde fd ZdS) rGNsecs_west_of_utcnamerJcDt| |_|pd|_dS)N)refixed)r _offset_name)selfrvrws r.__init__ztzoffset.__init__s' *:):;;; _W r/cRt|j |jffSr+)rGrz total_secondsr{r|s r. __reduce__ztzoffset.__reduce__s%4<55777DDDr/dtc|jSr+)rzr|rs r. utcoffsetztzoffset.utcoffsets |r/c|jSr+)r{rs r.tznameztzoffset.tznames zr/ctSr+)ZEROrs r.dstz tzoffset.dsts r/r+)r8r9r:floatrrPr}rrrr r rrrr,r/r.rGrGs%%%eD#I6F%RV%%%%EE$z"2E%*4E"EFEEEEE(D.1ix~.3eHdN+ r/rGUTC timestamp tz_offsetctj|t} |t |}|S#t $r|cYSwxYw)zAConverts a timestamp + tz_offset into an aware datetime instance.)r fromtimestamprH astimezonerGr\)rrutc_dtlocal_dts r.from_timestamprs]  #Is 3 3F$$Xi%8%899  s#A AA string_datec vt|tr|jrtt|}t | }t |t |fStd| | ddkr|| ddkrc|\}}|dr |dd}t |}|t!t#|fSd}|d d vr!t#|d d}|dd }t!|}g}d}d |vr+|d | d}n|d|d|d|d| d}|dkr| d}|dksJ||dzd}|d|} t'j|d} |D]} t'j| | } t+j| j| j| j| j| j| j| j| j| jf } t | |fcS#t$rYwxYwtd#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-+rL,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=)" isinstancer r rr rr;rrrHrr\countrfindsplit startswithrErFappendtimestrptimecalendartimegmtm_yeartm_montm_mdaytm_hourtm_mintm_sectm_wdaytm_ydaytm_isdst Exceptiontype)rrrnr offset_str timestamp_int date_formatssplitter time_part date_parttstructfmtdtstructutctimees r.rArAs+x(([   [Y (=(=(?(?@@I)1133444F{--c22<<>>??G GYKYYZZ ZEm   S ! !Q & &;+<+>*0055Hb====$HqLNN3I#IXI.ImIz::G#  #}Y< 1191999972 -0700 :return: [Actor, int_seconds_since_epoch, int_timezone_offset])r[0rr r[) _re_actor_epochsearchgroups_re_only_actorgroupr _from_stringr;rE)ractorepochrnms r.rBrB3s (E5&t$$A0 xxzzuff  ! !$ ' '/ TZR  u % %s5zz=3H3H IIr/c:eZdZdZdZdddeddfdZd edefd ZdS) rCa Class wireing 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 AutoInterrupt class to kill it if the instance goes out of scope.)_proc_streamprocessr& stream_namerJNc>||_t|||_dSr+)rgetattrr)r|rrs r.r}zProcessStreamAdapter.__init__Ss !(+!>!> r/attrc,t|j|Sr+)rr)r|rs r. __getattr__z ProcessStreamAdapter.__getattr__Wst|T***r/) r8r9r:__doc__ __slots__rPr}r rr,r/r.rCrCIsp-- %I??c?d????++++++++r/rCceZdZdZdZeedededfdZ edededefdZ dd e dedede e d fd Zedededefd Zddddddd fdee ddefege fdee ddefege fdede de ded e de ee deeffdZdS)r4zSimple interface to perform depth-first or breadth-first traversals into one direction. Subclasses only need to implement one function. Instances of the Subclass must be hashable Defined subclasses = [Commit, Tree, SubModule] r,r5rJc td)a@ Returns: 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)clsr5s r._get_intermediate_itemsz#Traversable._get_intermediate_itemshs""ABBBr/argskwargscTtjdtd|j|i|S)rzlist_traverse() method should only be called from subclasses.Calling from Traversable abstract class will raise NotImplementedError in 3.1.20Builtin sublclasses are 'Submodule', 'Tree' and 'Commitrq stacklevel)warningswarnDeprecationWarning_list_traverser|rrs r. list_traversezTraversable.list_traversevsE   F      #t"D3F333r/Fas_edge)r!r'r$r"ct|tr|j}nd}|s3t|}||j|d|i||St|j|i|}|S)a :return: IterableList with the results of the traversal as produced by traverse() Commit -> IterableList['Commit'] Submodule -> IterableList['Submodule'] Tree -> IterableList[Union['Submodule', 'Tree', 'Blob']] r[r)rr_id_attribute_rextendtraverse)r|rrridoutout_lists r.rzTraversable._list_traverses d, - - $BBB NZ[]N^N^C JJ}t}tFWFvFF G G GJ &2-$-2P2P2P%Q%QHOr/cTtjdtd|j|i|S)rztraverse() method should only be called from subclasses.Calling from Traversable abstract class will raise NotImplementedError in 3.1.20Builtin sublclasses are 'Submodule', 'Tree' and 'Commitrqr)rrr _traversers r.rzTraversable.traversesD   F      t~t.v...r/cdSNTr,ids r.zTraversable.sdhr/cdSNFr,rs r.rzTraversable.s`er/rTr predicater"pruner2 branch_first visit_once ignore_selfr3c #K t}t} | tdddttdddt dt ddf fd } | r| \} } |r|vr!|r||r| f} n} || | rN|ou}|s|| | r| V| d z}|d kr||krx| | ||| dSdS) aF:return: iterator yielding of items found when traversing self :param predicate: f(i,d) returns False if item i at depth d should not be included in the result :param prune: f(i,d) return True if the search should stop at item i at depth d. Item i will not be returned. :param depth: define 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 i.e. 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 destinationrNstacksrc_itemr4rr2rJcsdS|r$|fdDdSfdttdz ddD}||dS)Nc3:K|]}t|VdSr+r1).0rr2rs r. z.addToStack..s/ M MAE1h!?!? M M M M M Mr/c3FK|]}t|VdSr+r)rrr2lstrs r.rz.addToStack..s3dd1:eSVX>>ddddddr/r r)r extendleftrangersr)rrrr2reviterrr5r|s ` ` @r. addToStackz)Traversable._traverse..addToStacks ..t44C t &  M M M M M M M MMMMMMddddddcRUhhYZl\^`bHcHcddd W%%%%%r/r r) setrrr1rboolr;popadd)r|rrr2rrrrvisitedrr rr7rval skipStartItemndr5s` @r.rzTraversable._traversesP L%%#(77 Z4../// &$ &# & & &  & & & & & & &" 6 99;;LAtS dgoo " D!!! T{uT1~~ ':TT\M  YYtQ%7%7  QBrzzb5jj JudL" 5 5 57 6 6 6 6 6r/N)F)r8r9r:rr classmethodrr rrrrrrrrr TraversedTupr;rrr,r/r.r4r4[sI C3 C8M3J C C C^[ C 43 4# 4# 4 4 4^ 4$,/;> eAB C: /c /S /S / / /^ /XiWhSeSe!c6c6U=&,#FGMtSTc6}flBCSI4OPc6 c6  c6  c6c6c6 x345x 7MM Nc6c6c6c6c6c6r/c&eZdZdZdZd dZd dZdS) SerializablezPDefines methods to serialize and deserialize objects from and into a data streamr,streamrrJc td)zSerialize the data of this object into the given data stream :note: a serialized object would ``_deserialize`` into the same object :param stream: a file-like object :return: selfrrr|rs r. _serializezSerializable._serializes ""ABBBr/c td)zDeserialize all information regarding this object from the stream :param stream: a file-like object :return: selfrrrs r. _deserializezSerializable._deserialize"s""ABBBr/N)rrrJr)r8r9r:rrrrr,r/r.rrsT[ZICCCCCCCCCCr/rc eZdZdZeeedfefZdededede 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)r>r,Nr|rrrJcDtt|j|i|Sr+)superr>r)r|rr __class__s r.rz$TraversableIterableObj.list_traverse.s&Au+T22A4R6RRRr/cdSr+r,rs r.rzTraversableIterableObj.traverse1s r/rrr2rrrTrFcdSr+r,r|rrr2rrrrs r.rzTraversableIterableObj.traverse5  r/cdSr+r,r%s r.rzTraversableIterableObj.traverseBr&r/cdSr+r,r%s r.rzTraversableIterableObj.traverseOr&r/cdSrr,rs r.rzTraversableIterableObj.^sUYr/cdSrr,rs r.rzTraversableIterableObj._sQVr/rr c  tttttttdtftfft t ||||||||S)z3For documentation, see util.Traversable._traverse()N)rrrr=rr!r>r) r|rrr2rrrrr"s r.rzTraversableIterableObj.traverse\st  (7#XeE$-4H'4Q.R%SS T ($ / / 9 95%z;PW     r/)r8r9r:rrrr= TIobj_tupler rrrrrrr;rr __classcell__)r"s@r.r>r>)s6Igtm,g56KSGSCS3SDE  w 34c:D@A        T]     %() *    X  IZHYDVDV!! ! ! U7K#78#>DE! w 34c:D@A!  !  !  ! ! !  x (5'1A+B"CXkEZZ [! ! ! ! ! ! ! ! ! ! r/)Srabcrrrgit.utilrrrre collectionsrstringr rrr r r typingr rrrrrrrrrrrrr git.typesrrriorrrWr!rYr"rXr#rZr$r% subprocessr&submodule.baser'r(r)r1r=r__all__rbytesrPr;rTr@rErDrFrGrHrrrAcompilerrrBobjectrCr4rr>r,r/r.r<sk +*$#######5555555555  0000000000"4333333333$$$$$$$$,,,,,,,,      ))))))555555555H$$$$$$$$ ')#; < < < %# $m 34  y|| U5#:. 3     ^^ 4>4 ,d6lDL HI^^^^<2222227C7C7777      v$hq%e(\mE#x-0\mU38_\m\m\m\mB"*<==M** Js JuUC_'= J J J J,+++++6+++$r6r6r6r6r6(r6r6r6lCCCCC8CCC,T T T T T [+T T T T T r/