U e5d0@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|dkrtd|jD]0}||kr@t||||q"t|||j|q"|D]}||jkr\td|q\|dkr||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.8/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|_|dSN)rrrclose)rrrrrrvs zTextFile.closecCsjg}|dkr|j}||jdt|ttfrD|dt|n|d||t|d|S)Nz, z lines %d-%d: z line %d: )rappendr isinstancelisttuplestrjoin)rmsglineZoutmsgrrr gen_errorszTextFile.gen_errorcCstd|||dS)Nzerror: ) ValueErrorr(rr&r'rrrerrorszTextFile.errorcCs tjd|||ddS)Nz warning:  )sysstderrwriter(r*rrrwarnsz TextFile.warncCs|jr|jd}|jd=|Sd}|j}|dkr6d}|jr|r|d}|dkrTnX|dksl||ddkr|ddkr|dp~d}|d||}|dkrq n |dd}|jr|r|dkr|d |S|j r| }||}t |j t r |j dd|j d<n|j |j dg|_ n:|dkr,dSt |j t rL|j dd|_ n |j d|_ |jrr|jrr|}n"|jr| }n|jr|}|dks|dkr|jrq |jr|ddkr|dd}q |d dd kr|dd d}q |S) Nr#rr\r,z\#z2continuation line immediately precedes end-of-filez\ )rrreadlinerfindstripreplacer r0r lstripr!rr"rrrstripr)rr'Z buildup_lineposZeolrrrr5sf           zTextFile.readlinecCs(g}|}|dkr|S||qdSr)r5r )rlinesr'rrr readliness zTextFile.readlinescCs|j|dSr)rr )rr'rrr unreadlineszTextFile.unreadline)NN)N)N)N) __name__ __module__ __qualname__r rrrr(r+r0r5r=r>rrrrr s"; !  x r)r-rrrrrrs