o ?Og:@@s ddlZddlZddlZddlmZgdZdad$ddddddd Zd d Zd d Z ddZ ddZ ddZ ddZ ddZddZGdddZdddddZd%dd Zd!d"Zed#kreedSdS)&N) GenericAlias) inputclosenextfilefilenamelineno filelinenofileno isfirstlineisstdin FileInputhook_compressed hook_encodedFrmodeopenhookencodingerrorsc Cs. tr tjr tdt|||||||datS)Nzinput() already activer)_state_file RuntimeErrorr )filesinplacebackuprrrrr0/opt/alt/python310/lib64/python3.10/fileinput.pyrNs  rcCs t}da|r |dSdSN)rr)staterrrr]s  rcC tstdtSNzno active input())rrrrrrrres rcCr r!)rrrrrrrrsrcCr r!)rrrrrrrr|rcCr r!)rrrrrrrrr#rcCr r!)rrr rrrrr r"r cCr r!)rrr rrrrr r"r cCr r!)rrr rrrrr r"r c@seZdZ d(dddddddZdd Zd d Zd d ZddZddZddZ ddZ ddZ ddZ ddZ ddZddZd d!Zd"d#Zd$d%Zd&d'ZeeZdS))r NFrrrc CsPt|tr |f}n!t|tjrt|f}n|dur!tjdd}|s&d}nt|}||_||_ ||_ d|_ d|_ d|_ d|_d|_d|_d|_d|_||_||_tjjrld|vrl|durl|durlddl}|dtd|dvrttd d |vrddl}|d td||_d |vr|d d nd |_|r|rtdt|std||_ dS)N)-rFbz"'encoding' argument not specified.)rZrUUrbz=FileInput opening mode must be one of 'r', 'rU', 'U' and 'rb'r(z'U' mode is deprecatedrwz4FileInput cannot use an opening hook in inplace modez#FileInput openhook must be callable)! isinstancestrosPathLikefspathsysargvtuple_files_inplace_backup _savestdout_output _filename _startlineno _filelinenor_isstdin_backupfilename _encoding_errorsflagswarn_default_encodingwarningswarnEncodingWarning ValueErrorDeprecationWarning_modereplace _write_modecallable _openhook) selfrrrrrrrrArrr__init__sV   zFileInput.__init__cC |dSrrrKrrr__del__ zFileInput.__del__cCsz |Wd|_dSd|_w)Nr)rr3rOrrrrs zFileInput.closecC|SrrrOrrr __enter__zFileInput.__enter__cCrMrrN)rKtypevalue tracebackrrr__exit__rQzFileInput.__exit__cCrRrrrOrrr__iter__rTzFileInput.__iter__cCs4 |}|r|jd7_|S|jst|qNTr$) _readliner:r StopIterationrrKlinerrr__next__zFileInput.__next__cCsNddl}|jdtdd||krtdz|WSty&tdw)NrzTSupport for indexing FileInput objects is deprecated. Use iterator protocol instead.r') stacklevelzaccessing lines out of orderzend of input reached)rArBrErrr_r\ IndexError)rKirArrr __getitem__ s   zFileInput.__getitem__cCs|j}d|_|r |t_|j}d|_zm|r|W|j}d|_z|`Wn ty,Ynwz+|r7|js7|W|j }d|_ |rT|j sTzt |Wn t ySYnwd|_dS|j }d|_ |r{|j s{z t |Wd|_wt yzYd|_wwd|_w|j}d|_z|`Wn tyYnwz0|r|js|W|j }d|_ |r|j sz t |Wd|_wt yYd|_wwd|_w|j }d|_ |r|j sz t |Wd|_wt yYd|_wwd|_w)NF)r6r0stdoutr7rrr[AttributeErrorr;r<r5r-unlinkOSError)rKZ savestdoutoutputfileZbackupfilenamerrrrs         zFileInput.nextfilecCs4 |}|r|jd7_|S|js|S|qrZ)r[r:rrr]rrrreadline6r`zFileInput.readlinec CsP|js d|jvr dSdS|jd|_|jdd|_||_d|_d|_d|_d|_d|jvr6|j p4d}nd}|jdkrWd |_d|jvrOt t j d t j |_nt j |_d |_n|j rt|j|jpcd |_zt|jWn tywYnwt|j|jt|j|j||jd |_z t|jj}Wntyt|j|j||jd |_Yn;wtjtjBtjB}ttdr|tjO}t|j||}tj ||j||jd |_z t!|j|Wn tyYnwt j"|_#|jt _"n/|j$r|j dur|$|j|j|_n|j$|j|j|j |jd |_n t|j|j||jd |_|jj%|_&|&S)Nr&rrr$Flocaler%zbufferTz.bakrrO_BINARY)'r3rFr8rr9r:rr;r<r=getattrr0stdinr4r-r/r5rgrhrenameopenr>fstatr st_moderHr7O_CREATO_WRONLYO_TRUNChasattrrpfdopenchmodrer6rJrkr[)rKrZpermrfdrrrr[As|                    zFileInput._readlinecC|jSr)r8rOrrrrzFileInput.filenamecCs |j|jSr)r9r:rOrrrrrQzFileInput.linenocCr~rr:rOrrrrrzFileInput.filelinenocCs,|jrz|jWStyYdSwdS)N)rr rDrOrrrr s  zFileInput.filenocCs |jdkS)Nr$rrOrrrr s zFileInput.isfirstlinecCr~r)r;rOrrrr rzFileInput.isstdinNFr)__name__ __module__ __qualname__rLrPrrSrXrYr_rdrrkr[rrrr r r classmethodr__class_getitem__rrrrr s,  4  I  r rocCs|dur d|vr d}tj|d}|dkr!ddl}|||}n|dkr0ddl}|||}nt||||dSd|vrDtj|||d}|S)Nr&rmr$z.gzrz.bz2ro) r-pathsplitextgziprtbz2ZBZ2Fileio TextIOWrapper)rrrrZextrstreamrrrrr sr csfdd}|S)Ncst||dS)Nro)rt)rrrorrrszhook_encoded..openhookr)rrrrrorrsrcCsddl}d}d}|tjddd\}}|D]\}}|dkr!d}|dkr'|}qt|||dD]1}|d dd kr?|dd }|d dd krM|dd }td ttttrZd p[d|fq/tdtttfdS)NrFr$zib:z-iTz-b)rrr  z%d: %s[%d]%s %s*rz %d: %s[%d]) getoptr0r1rprintrrrr )rrrZoptsargsoar^rrr_tests    r__main__rr)rr0r-typesr__all__rrrrrrrr r r r r rrrrrrrs2C        {