˓)k <UdZddlZddlZddlmZddlZddlmZmZddl Z ddl Z ddl Z ddl Z ddl mZmZmZddlmZddlmZddlZddlmZmZmZmZmZmZmZm Z m!Z!m"Z"m#Z#m$Z$ddl%m&Z&m'Z'm(Z(m)Z)m*Z*e r dd l+m,Z,dd lm-Z-e"d d Z.e"de/e0e1e2e3Z4ej5dddkr ddl6m7Z7e7Z8nddlm7Z7e7e/ee4fZ8dZ9e j:dZ;e;<e j=dZ>e'e?d<e j@dZAGddejBZCdede*fdede*ffdZDdede*fdede*ffdZEGdd ee.ZFGd!d"e8ZGd#e&de/fd$ZHGd%d ejIeC&ZJdS)'zbModule containing module parser implementation able to properly read and write configuration filesN)wraps)BufferedReaderIOBase)defenc force_textis_win)LockFile) AnyCallableGenericIOListDictSequence TYPE_CHECKINGTupleTypeVarUnioncast)Lit_config_levelsConfigLevels_TupPathLike assert_never_T)Repo)BytesIOT_ConfigParserGitConfigParser)bound T_OMD_value)r!) OrderedDict)rSectionConstraintz git.config)systemuserglobal repository CONFIG_LEVELSz2(?<=includeIf )\"(gitdir|gitdir/i|onbranch):(.+)\"cDeZdZdZdededeeefddffd ZxZ S)MetaParserBuilderzZUtility class wrapping base-class methods into decorators that assure read-only propertiesnamebasesclsdictreturnc>d}||vrj||}|D]_}dtj|tjD}|D]1\}}||vr t|} ||vrt | } | ||<2`t t |||||} | S)z Equip all base-class methods with a needs_values decorator, and all non-const methods with a set_dirty_and_flush_changes decorator in addition to that._mutating_methods_c3PK|]!}|dd|V"dS)r_N startswith).0ts /srv/buildsys-work-dir/castor/build_node/builder-2/WGSG1/unpkd_srcs/cloudlinux-venv-1.0.6/venv/lib/python3.11/site-packages/git/config.py z,MetaParserBuilder.__new__..bs=nnYZ[\Y]YhYhilYmYmn1nnnnnn)inspect getmembers isroutine needs_valuesset_dirty_and_flush_changessuperr,__new__) clsr-r.r/kmmmutating_methodsbasemethodsmethodmethod_with_valuesnew_type __class__s r9rBzMetaParserBuilder.__new__Zs# '>>&s|  7 7nng&8w?P&Q&Qnnn$+77LD&w )5f)=)=&///-HI[-\-\*%7GDMM7*C0088dE7SSr;) __name__ __module__ __qualname____doc__strrrr rB __classcell__rKs@r9r,r,Wshdd3utCH~J]r;r,func.r0c ltdddtdtdtffd }|S)zOReturns method assuring we read values (on demand) before we try to access themselfrargskwargsr0cD||g|Ri|SN)read)rUrVrWrSs r9assure_data_presentz)needs_values..assure_data_presentws0 tD*4***6***r;)rr r)rSr[s` r9r?r?tsY 4[[+"3+C+3+SU+++++[+ r;non_const_funccZdddtdtdtffd }j|_|S)zReturn method that checks whether given non constant function may be called. If so, the instance will be set dirty. Additionally, we flush the changes right to diskrUrrVrWr0cV|g|Ri|}d|_||S)NT)_dirtywrite)rUrVrWrvalr\s r9 flush_changesz2set_dirty_and_flush_changes..flush_changess;~d4T444V44   r;)r rrL)r\rbs` r9r@r@sQ -cSR,4M r;ceZdZdZdZdZdededdfdZdd Z d ede ffd Z d ed e de de fdZ e defdZddZddZdedededdfdZxZS)r%a"Constrains a ConfigParser to only option commands which are constrained to always use the section we have been initialized with. It supports all ConfigParser methods that operate on an option. :note: If used as a context manager, will release the wrapped ConfigParser._config _section_name) get_value set_valuegetsetgetintgetfloat getboolean has_optionremove_section remove_optionoptionsconfigsectionr0Nc"||_||_dSrYrd)rUrrrss r9__init__zSectionConstraint.__init__s $r;c8|jdSrYrereleaserUs r9__del__zSectionConstraint.__del__s r;attrcvjvrfdSttS)Nc&jg|Ri|SrY) _call_config)rVrWr{rUs r9z/SectionConstraint.__getattr__..s%+<4+>tDDDr;rHrVrWcJt|j||jg|Ri|S)zcCall the configuration at the given method which must take a section name as first argument)getattrrerf)rUrHrVrWs r9r~zSectionConstraint._call_configs3-wt|V,,T-?Q$QQQ&QQQr;c|jS)z*return: Configparser instance we constrain)rerys r9rrzSectionConstraint.configs |r;c4|jS)zZEquivalent to GitConfigParser.release(), which is called on our underlying parser instancerwrys r9rxzSectionConstraint.releases|##%%%r;!SectionConstraint[T_ConfigParser]c8|j|SrY)re __enter__rys r9rzSectionConstraint.__enter__s     r;exception_typeexception_value tracebackc>|j|||dSrY)re__exit__)rUrrrs r9rzSectionConstraint.__exit__s" noyIIIIIr;r0N)r0r)rLrMrNrO __slots__rrrPrurzr rr~propertyrrrxrrrQrRs@r9r%r%snPP-I M%~%%%%%% EEEEEEEE R3RsRcRcRRRR X&&&&JsJSJSJUYJJJJJJJJr;r%c beZdZdZdededdffd Zdededdffd Zdede eddffd Z dedeffd Z dedeffd Z dededdffd Z dded eedfdeedfffd Zdede effd Zde eeeffdZde eee effdZxZS)_OMDzOrdered multi-dict.keyvaluer0Nc\tt|||gdSrYrAr __setitem__rUrrrKs r9rz_OMD.__setitem__s+ dD%%cE733333r;c||vr,tt|||gdStt|||dSrY)rArr __getitem__appendrs r9addz_OMD.addse d?? $   ) )#w 7 7 74 dD%%c**11%88888r;valuescZtt|||dSrYr)rUrrrKs r9setallz _OMD.setalls) dD%%c622222r;c`tt||dSNrArrrUrrKs r9rz_OMD.__getitem__&T4  ,,S11"55r;c`tt||dSrrrs r9getlastz _OMD.getlastrr;c||vr,tt|||gdStt||}||d<dSr)rArrr)rUrrpriorrKs r9setlastz _OMD.setlasts] d?? $   ) )#w 7 7 7 FdD!!--c22b r;defaultcdtt|||gdSr)rArri)rUrrrKs r9riz_OMD.gets*T4  $$S7)44R88r;cTtt||SrYrrs r9getallz _OMD.getalls!T4  ,,S111r;c fdDS)z"List of (key, last value for key).c$g|] }||f Srr7krUs r9 z_OMD.items..s!+++DG +++r;rrys`r9itemsz _OMD.itemss++++d++++r;c fdDS)z&List of (key, list of values for key).c>g|]}||fSr)rrs r9rz"_OMD.items_all..s(222DKKNN#222r;rrys`r9 items_allz_OMD.items_alls2222T2222r;rY)rLrMrNrOrPrrr rrrrrrrrirrrrrQrRs@r9rrs4s424$4444449s9394999999 3#3tBx3D3333336s6s66666663636666663st99s9U2t8_9b$h9999992#2$r(222222,tE#r'N+,,,,34c48m 4533333333r;r config_levelc tr|dkrd}|dkrdS|dkrtjdp2t jtjddd}t jt jt j|d d S|dkr&t jt jd S|d krtd t|td|dS)Nr&r(z/etc/gitconfigr'XDG_CONFIG_HOMEHOME~z.configgitrrz ~/.gitconfigr)zGNo repo to get repository configuration from. Use Repo._get_config_pathzInvalid configuration level: ) rosenvironriospjoinnormpath expanduser ValueErrorr)r config_homes r9get_config_pathrs  ,(** x   jnn%677k38BJNNSY[^D_D_aj;k;k |CN38K+Q+QRRSSS  ! !|CN>::;;;  % %bccc   G|GG H H     r;c,eZdZdZeZejdZdZ eje Z eje dzdzZ [ dZ d6d e ded ee ed ffd ed ed e edfde dddf dZd7dZd7dZd8dZdeddfdZd7dZdedefdZde eeefdeddfdZde eeffdZ de!e"eeffdZ#d7dZ$deddfd Z%d!ede!e"eefffd" Z&d!ede!e"ee!effd#Z'e(d7d$Z)d%eddfd&Z*d'eddffd( Z+e,defd)Z- d9d'ed*ed+e ee.eedfde ee.eeffd,Z/ d9d'ed*ed+e ee.eedfde!e ee.eeffd-Z0d.ede ee.eeffd/Z1d0e eeee.efdefd1Z2e(e3d'ed*ed0e eeee.efddfd2Z4e(e3d'ed*ed0e eeee.efddfd3Z5d'ed4eddffd5 Z6xZ7S):raImplements specifics required to read git style configuration files. This variation behaves much like the git.config command such that the configuration will be read on demand based on the filepath given during initialization. The changes will automatically be written once the instance goes out of scope, but can be triggered manually as well. The configuration file will be locked if you intend to change values preventing other instances to write concurrently. :note: The config is case-sensitive even when queried, hence section and option names must match perfectly. If used as a context manager, will release the locked file.z^\s*[#;]z\s*(?P