o ʎ_@spddlZddlmZmZmZddlmZddlmZGdddeZ Gddde Z d d Z d d Z d dZ dS)N)BytesIOStringIOUnsupportedOperation)FileProxyMixin)cached_propertyc@seZdZdZdddZddZddZd d Zd d Ze d dZ dddZ dddZ ddZ ddZddZdddZddZdS)FileiNcCs:||_|dur t|dd}||_t|dr|j|_dSdS)Nnamemode)filegetattrrhasattrr )selfr rr8/usr/lib/python3/dist-packages/django/core/files/base.py__init__ s   z File.__init__cCs |jpdS)Nrr rrr__str__ z File.__str__cCsd|jj|pdfS)Nz<%s: %s>None) __class____name__rrrr__repr__sz File.__repr__cCs t|jSN)boolrrrrr__bool__rz File.__bool__cCs|jSr)sizerrrr__len__sz File.__len__c Cst|jdr |jjSt|jdr%z tj|jjWSttfy$Ynwt|jdrKt|jdrK|j }|j dtj |j }|j ||St d)Nrrtellseekrz$Unable to determine the file's size.) r r rospathgetsizerOSError TypeErrorrr SEEK_ENDAttributeError)r posrrrrrs     z File.sizec csN|p|j}z|dWn ttfyYnw ||}|s#dS|Vq)z{ Read the file and yield chunks of ``chunk_size`` bytes (defaults to ``File.DEFAULT_CHUNK_SIZE``). rTN)DEFAULT_CHUNK_SIZEr r'rread)r chunk_sizedatarrrchunks0s  z File.chunkscCs|j|p|jkS)z Return ``True`` if you can expect multiple chunks. NB: If a particular file representation is in memory, subclasses should always return ``False`` -- there's no good reason to read from memory in chunks. )rr))r r+rrrmultiple_chunksAszFile.multiple_chunksccsvd}|D](}|dD] }|r$t|rt|s|Vn||}d}t|r,|Vq|}qq|dur9|VdSdSNT)r- splitlines endswith_cr equals_lf endswith_lf)r buffer_chunklinerrr__iter__Ks   z File.__iter__cCs|Srrrrrr __enter__fzFile.__enter__cCs |dSr)close)r exc_type exc_valuetbrrr__exit__is z File.__exit__cCsH|js |d|S|jr tj|jr t|j|p|j|_|St d)NrzThe file cannot be reopened.) closedr rr!r"existsopenr r ValueErrorr r rrrrAls z File.opencCs|jdSr)r r:rrrrr:usz File.closer)r __module__ __qualname__r)rrrrrrrr-r.r7r8r>rAr:rrrrrs        rcsLeZdZdZdfdd ZddZddZdd d Zd d Zd dZ Z S) ContentFilezU A File-like object that takes just raw content, rather than an actual file. Ncs4t|trtnt}tj|||dt||_dS)Nr) isinstancestrrrsuperrlenr)r contentr stream_classrrrr}szContentFile.__init__cCdS)Nz Raw contentrrrrrrr9zContentFile.__str__cCrNr/rrrrrrr9zContentFile.__bool__cCs|d|S)Nr)r rCrrrrAs zContentFile.opencCsdSrrrrrrr:r9zContentFile.closecCs|jdd|j|S)Nr)__dict__popr write)r r,rrrrQs zContentFile.writer) rrDrE__doc__rrrrAr:rQ __classcell__rrrMrrFys rFcC|t|tr dSdS)z9Return True if line (a text or bytestring) ends with ' '.  endswithrGrHr6rrrr1r1cCrT)z9Return True if line (a text or bytestring) ends with ' '.  rWrYrrrr3rZr3cCs|t|tr dkSdkS)z6Return True if line (a text or bytestring) equals ' '.r[r\)rGrHrYrrrr2sr2)r!iorrrdjango.core.files.utilsrdjango.utils.functionalrrrFr1r3r2rrrrs  q