3 \0@s"ddlZddlZGdddZdS)Nc@speZdZddddddddZdddZdd Zd d Zdd d ZdddZdddZ ddZ ddZ ddZ dS)TextFilerstrict)strip_comments skip_blanks lstrip_ws rstrip_ws join_lines collapse_joinerrorsNcKs|dkr|dkrtdx>|jjD]0}||krBt||||q$t|||j|q$Wx&|jD]}||jkrbtd|qbW|dkr|j|n||_||_d|_g|_ dS)Nz7you must supply either or both of 'filename' and 'file'zinvalid TextFile option '%s'r) RuntimeErrordefault_optionskeyssetattrKeyErroropenfilenamefile current_linelinebuf)selfrrZoptionsoptr+/usr/lib64/python3.6/distutils/text_file.py__init__Ns  zTextFile.__init__cCs&||_tj|jd|jd|_d|_dS)Nr)r r)riorr rr)rrrrrrosz TextFile.opencCs$|j}d|_d|_d|_|jdS)N)rrrclose)rrrrrrvs zTextFile.closecCsjg}|dkr|j}|j|jdt|ttfrD|jdt|n|jd||jt|dj|S)Nz, z lines %d-%d: z line %d: )rappendr isinstancelisttuplestrjoin)rmsglineZoutmsgrrr gen_errorszTextFile.gen_errorcCstd|j||dS)Nzerror: ) ValueErrorr')rr%r&rrrerrorszTextFile.errorcCs tjjd|j||ddS)Nz warning:  )sysstderrwriter')rr%r&rrrwarnsz TextFile.warncCs|jr|jd }|jd =|Sd}x|jj}|dkr:d}|jr|r|jd}|d krXnX|dksp||ddkr|ddkrdpd}|d||}|jdkrq$n |jdd}|jo|r |dkr|jd|S|j r|j }||}t |j t r |j dd|j d<n|j |j dg|_ n:|dkr.dSt |j t rN|j dd|_ n |j d|_ |jrt|jrt|j}n"|jr|j }n|jr|j}|dks|dkr|jrq$|jr|ddkr|dd}q$|ddd kr|ddd}q$|SdS)Nrr#r\r*z\#z2continuation line immediately precedes end-of-filez\ r2r2r2r2r2r3)rrreadlinerfindstripreplacer r.r lstripr rr!rrrstripr)rr&Z buildup_lineposZeolrrrr4sf            zTextFile.readlinecCs,g}x"|j}|dkr|S|j|qWdS)N)r4r)rlinesr&rrr readliness zTextFile.readlinescCs|jj|dS)N)rr)rr&rrr unreadlineszTextFile.unreadline)NN)N)N)N) __name__ __module__ __qualname__r rrrr'r)r.r4r<r=rrrrr s ; !  x r)r+rrrrrrs