L iGddlmZddlZddlmZddlmZmZmZddl m Z ddl m Z er ddl mZddlmZGd d eZGd d eZGd deZGddej*ZGdde eZy)) annotationsN)abstractmethod) TYPE_CHECKING NamedTupleProtocol)util)CacheStatsProvider)Sequence)FileURLsc:eZdZUdZded<ded<ded<ded<y) UploadedFileRecz7Metadata and raw bytes for an uploaded file. Immutable.strfile_idnametypebytesdataN__name__ __module__ __qualname____doc____annotations__m/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/streamlit/runtime/uploaded_file_manager.pyr r sA L I I Krr c0eZdZUdZded<ded<ded<y)UploadFileUrlInfoz:Information we provide for single file in get_upload_urls.rr upload_url delete_urlNrrrrrr'sD LOOrrceZdZUdZded<y) DeletedFileaRepresents a deleted file in deserialized values for st.file_uploader and st.camera_input. Return this from st.file_uploader and st.camera_input deserialize (so they can be used in session_state), when widget value contains file record that is missing from the storage. DeleteFile instances filtered out before return final value to the user in script, or before sending to frontend. rrNrrrrr"r"/sLrr"c<eZdZdZdfd ZddZddZd dZxZS) UploadedFilezA mutable uploaded file. This class extends BytesIO, which has copy-on-write semantics when initialized with `bytes`. ct||j|j|_|j|_|j |_t |j|_||_yN) super__init__rrrrlensize _file_urls)selfrecord file_urls __class__s rr(zUploadedFile.__init__DsN %~~ KK KK  $ #rc`t|tstS|j|jk(Sr&) isinstancer$NotImplementedr)r,others r__eq__zUploadedFile.__eq__Ps%%.! !||u}},,rc,t|jSr&)hashrr,s r__hash__zUploadedFile.__hash__UsDLL!!rc,tj|Sr&)rrepr_r7s r__repr__zUploadedFile.__repr__Xszz$r)r-r r. FileURLsProtoreturnNone)r3objectr=bool)r=int)r=r) rrrrr(r4r8r; __classcell__)r/s@rr$r$=s $- " rr$cTeZdZdZe ddZeddZ ddZy) UploadedFileManageraUploadedFileManager protocol, that should be implemented by the concrete uploaded file managers. It is responsible for: - retrieving files by session_id and file_id for st.file_uploader and st.camera_input - cleaning up uploaded files associated with session on session end It should be created during Runtime initialization. Optionally UploadedFileManager could be responsible for issuing URLs which will be used by frontend to upload files to. ct)aReturn a list of UploadedFileRec for a given sequence of file_ids. Parameters ---------- session_id The ID of the session that owns the files. file_ids The sequence of ids associated with files to retrieve. Returns ------- List[UploadedFileRec] A list of URL UploadedFileRec instances, each instance contains information about uploaded file. NotImplementedError)r, session_idfile_idss r get_fileszUploadedFileManager.get_filesk &"!rct)z1Remove all files associated with a given session.rF)r,rHs rremove_session_filesz(UploadedFileManager.remove_session_filess "!rct)a!Return a list of UploadFileUrlInfo for a given sequence of file_names. Optional to implement, issuing of URLs could be done by other service. Parameters ---------- session_id The ID of the session that request URLs. file_names The sequence of file names for which URLs are requested Returns ------- List[UploadFileUrlInfo] A list of UploadFileUrlInfo instances, each instance contains information about uploaded file URLs. rF)r,rH file_namess rget_upload_urlsz#UploadedFileManager.get_upload_urlsrKrN)rHrrI Sequence[str]r=zlist[UploadedFileRec])rHrr=r>)rHrrOrQr=zlist[UploadFileUrlInfo])rrrrrrJrMrPrrrrDrD\sd "")6" ""(""""+8" "rrD) __future__rioabcrtypingrrr streamlitrstreamlit.runtime.statsr collections.abcr streamlit.proto.Common_pb2r r<r rr"BytesIOr$rDrrrr[sh# 666(Dj  *  2:: ><",h<"r