Files
witness-fracture/.venv/lib/python3.12/site-packages/internetarchive/__pycache__/files.cpython-312.pyc
T

192 lines
20 KiB
Plaintext
Raw Normal View History

2025-06-23 17:55:02 -05:00
Ë
“»Yh•Lãó—dZddlZddlZddlZddlZddlmZmZddlm Z ddl
m Z ddl m
Z
ddlmZmZmZmZmZddlmZdd lmZmZmZmZej4e«ZGd
„d «ZGd „d
e«ZGd„de«Zy)z�
internetarchive.files
~~~~~~~~~~~~~~~~~~~~~
:copyright: (C) 2012-2024 by Internet Archive.
:license: AGPL 3, see LICENSE for more details.
éN)Ú nullcontextÚsuppress)Úparsedate_to_datetime)Úsleep)Úquote)ÚConnectionErrorÚConnectTimeoutÚ HTTPErrorÚ ReadTimeoutÚ
RetryError)Útqdm)ÚauthÚ
exceptionsÚ iarequestÚutilscó—eZdZdd„Zy)ÚBaseFileNcóT—|€i}|jd«}|s/|jdg«D]}|jd«|k(sŒ|}n|jdi«jd«|_||_d|_d|_d|_d|_d|_d|_ d|_
t|«|_ |D]}t||||«Œ||_|jrt|j«nd|_ |jrt!|j«|_yd|_y)Nú/ÚfilesÚnameÚmetadataÚ
identifierr)ÚstripÚgetrrÚsizeÚsourceÚformatÚmd5Úsha1ÚmtimeÚcrc32ÚboolÚexistsÚsetattrrÚfloatÚint)ÚselfÚ
item_metadatarÚ
file_metadataÚfÚkeys ú^/mnt/c/fieldcraft/witness-fracture/.venv/lib/python3.12/site-packages/internetarchive/files.pyÚ__init__zBaseFile.__init__3s€Ø Р؈MØ�z‰z˜#‹ˆÙØ"×&Ñ& w°Ó3ò
�Ø—5‘5˜“= DÓ(Ø$%�MÙð
ð
(×+Ñ+¨J¸Ó;×?Ñ?À ÓMˆŒØˆŒ ؈Œ ؈Œ ؈Œ ؈ŒØˆŒ ؈Œ
؈Œ
ä˜=Ó)ˆŒ à ò 3ˆCÜ �D˜#˜}¨SÑ1Õ 2ð 3ð&ˆŒ
Ø*.¯*ª*”U˜4Ÿ:™:Ô&¸!ˆŒ
Ø&*§i¢i”C˜Ÿ ™ “Nˆ� °Qˆ� ó©N)Ú__name__Ú
__module__Ú __qualname__r.©r/r-rr1s„ô7r/rcó^‡—eZdZdZdˆfd„ Zd„Z dd„Z dd„ZˆxZS) ÚFileaPThis class represents a file in an archive.org item. You
can use this class to access the file metadata::
>>> import internetarchive
>>> item = internetarchive.Item('stairs')
>>> file = internetarchive.File(item, 'stairs.avi')
>>> print(f.format, f.size)
('Cinepack', '3786730')
Or to download a file::
>>> file.download()
>>> file.download('fabulous_movie_of_stairs.avi')
This class also uses IA's S3-like interface to delete a file
from an item. You need to supply your IAS3 credentials in
environment variables in order to delete::
>>> file.delete(access_key='Y6oUrAcCEs4sK8ey',
... secret_key='youRSECRETKEYzZzZ')
You can retrieve S3 keys here: `https://archive.org/account/s3.php
<https://archive.org/account/s3.php>`__
cóX•—t‰|�|j||«||_|jj
|j t|jd««|jjdœ}djdi|¤Ž|_ |jjjrx|jjjrXtj|jjj|jjj«|_yd|_y)a3
:type item: Item
:param item: The item that the file is part of.
:type name: str
:param name: The filename of the file.
:type file_metadata: dict
:param file_metadata: (optional) a dict of metadata for the
given file.
úutf-8)ÚprotocolÚidrÚhostz'{protocol}//{host}/download/{id}/{name}Nr4)Úsuperr.r)ÚitemÚsessionr9rrÚencoder;rÚurlÚ
access_keyÚ
secret_keyrÚS3Auth)r(r=rr*Ú url_partsÚ __class__s €r-r.z
File.__init__lsÛø€ô ‰Ñ˜×+Ñ+¨T°=ÔA؈Œ àŸ ™ ×-Ñ-Ø—/‘/ܘ$Ÿ+™+ gÓ.Ó/Ø—L‘L×%Ñ%ñ 
ˆ ð DÐ<×CÑCÑPÀiÑPˆŒØ �9‰9× Ñ × 'Ò '¨D¯I©I×,=Ñ,=×,HÒ,HÜŸ ™  D§I¡I×$5Ñ$5×$@Ñ$@Ø$(§I¡I×$5Ñ$5×$@Ñ$@óBˆD�IðˆD�Ir/c óp—d|j›d|j›d|j›d|j›d� S)NzFile(identifier=z , filename=z, size=z , format=ú))rrrr)r(s r-Ú__repr__z
File.__repr__‡sD€Ø" 4§?¡?Ð"5ð6Ø ŸI™I˜=ð)ØŸ ™ �}ð%ØŸ+™+˜¨ð+ð ,r/cóœ—|€dn|}|€dn|}|€dn|}|€dn|}|xsd}|xsd}|
xsd}
| xsd} | xsd} |sdn|}i}d}d}|jjj|¬«|xs |j}|rg|
dur t j
|«tjj|«rt|›d�«‚tjj||«}tjj|«}|
�sÃtjj|jd ««�r”|r­d
}tjj|«st|d d ¬ «5} ddd«t|d ¬ «5}|j«j!«}ddd«|vr<d
|›d�}t"j%|«|rt'd|›�t(j*¬«y|r<d
|›d�}t"j%|«|rt'd|›�t(j*¬«y|s|r£t|d«5}t-j.|«}ddd«|j0k(rjd
|›d�}t"j%|«|rt'd|›�t(j*¬«|r,tdd ¬ «5}|j3|›d�«ddd«yy |dk7r|
durt j4|d¬«|
sŸ|s�|j|j6›d�k7r�tjj|jd ««rSt j8|jd ««}|j:|j<k7r|s|sdd|j:›d�i}|jjj?|j@d||jB| |¬«}|jDj?d«}|rtG|«}|jI«}n |jJ}|jM«| sÔ|
sÒtjj|jd ««r¤t j8|jd ««}|jN|k(ru|j|j6›d�k(s|j:|j<k(r@d
|›d�}t"j%|«|rt'd|›�t(j*¬«y|
r|S|rGtQ|jDj?dd ««xsd} tSd!|j›�| d"dd#¬$«}!n
tU«}!|
sd%}
|r4t jVt(jXj[«d&d¬'«} | r|r;d|vrt|jd «d(«} nt|jd «d&«} | 5|!5}"d|vr| j]j:«|j_|
¬)«D]*}#|#sŒ| j3|#«}$|"€Œ|"ja|$«Œ,|r>| j3tjbj?d*d«jd ««ddd«ddd«d|vr=t|d«5}%t-j.|%«}&ddd« &|j0k(sJ‚ | s?t{t«5t j||jd «d |f«ddd«d3|j6›d4|j›d5|›�}t"j%|«y#t $rY�Œ§wxYw#1swY�ŒÜxYw#1swY�ŒµxYw#1swY�ŒxYw#1swYyxYw#1swY�Œ
xYw#1swY�ŒxYw#1swYŒðxYw#td$r@d+|›d,�}t jf|jd ««tijj|«‚wxYw#tltntpttrthjjf$r¬}'|d kDr6d}|d-z}d.|›d/|›d0�}t"ju|«tw|«Yd}'~'�Œ†d1|›d2|'›�}t"jy|« t jf|«n#t$rYnwxYw|rt'd|›�t(j*¬«|rYd}'~'y|'‚d}'~'wwxYw#1swY�ŒÐxYw)6aT Download the file into the current working directory.
:type file_path: str
:param file_path: Download file to the given file_path.
:type verbose: bool
:param verbose: (optional) Turn on verbose output.
:type ignore_existing: bool
:param ignore_existing: Overwrite local files if they already
exist.
:type checksum: bool
:param checksum: (optional) Skip downloading file based on checksum.
:type checksum_archive: bool
:param checksum_archive: (optional) Skip downloading file based on checksum, and
skip checksum validation if it already succeeded
(will create and use _checksum_archive.txt).
:type destdir: str
:param destdir: (optional) The directory to download files to.
:type retries: int
:param retries: (optional) The number of times to retry on failed
requests.
:type ignore_errors: bool
:param ignore_errors: (optional) Don't fail if a single file fails to
download, continue to download other files.
:type fileobj: file-like object
:param fileobj: (optional) Write data to the given file-like object
(e.g. sys.stdout).
:type return_responses: bool
:param return_responses: (optional) Rather than downloading files to disk, return
a list of response objects.
:type no_change_timestamp: bool
:param no_change_timestamp: (optional) If True, leave the time stamp as the
current time instead of changing it to that given in
the original archive.
:type stdout: bool
:param stdout: (optional) Print contents of file to stdout instead of downloading
to file.
:type ors: bool
:param ors: (optional) Append a newline or $ORS to the end of file.
This is mainly intended to be used internally with `stdout`.
:type params: dict
:param params: (optional) URL parameters to send with
download request (e.g. `cnt=0`).
:rtype: bool
:returns: True if file was successfully downloaded.
NFéé é)Ú max_retriesTz is not a directory!r8z_checksum_archive.txtÚw)Úencodingz skipping z0, file already exists based on checksum_archive.ú ©Úfilez, file already exists.Úrbz(, file already exists based on checksum.Úaú
Ú)Úexist_okz
_files.xmlÚRangezbytes=ú-)ÚstreamÚtimeoutrÚparamsÚheadersz
Last-Modifiedz/, file already exists based on length and date.zcontent-lengthrz
downloading ÚiBi)ÚdescÚtotalÚunitÚ
unit_scaleÚ unit_divisoriÚwb)Úclosefdzrb+)Ú
chunk_sizeÚORSú"zV" corrupt, checksums do not match. Remote file may have been modified, retry download.ézdownload failed, sleeping for z seconds and retrying. z retries left.zerror downloading file z, exception raised: z downloaded rz to )?r=r>Úmount_http_adapterrÚosÚmkdirÚFileExistsErrorÚpathÚisfileÚOSErrorÚjoinÚdirnamer$r?ÚopenÚreadÚ
splitlinesÚlogÚinfoÚprintÚsysÚstderrrÚget_md5rÚwriteÚmakedirsrÚstatÚst_sizerrr@rr]rÚ timestampr!Úraise_for_statusÚst_mtimer'r
rÚfdopenÚstdoutÚfilenoÚseekÚ iter_contentÚupdateÚenvironÚAssertionErrorÚremoverÚInvalidChecksumErrorr r
r r ÚwarningrÚerrorrÚutime)(r(Ú file_pathÚverboseÚignore_existingÚchecksumÚchecksum_archiveÚdestdirÚretriesÚ
ignore_errorsÚfileobjÚreturn_responsesÚno_change_timestampr\rfr„Úorsr[r]Ú
retries_sleepÚretryingÚ
parent_dirÚchecksum_archive_filenamer+Úchecksum_archive_dataÚmsgÚfpÚmd5_sumÚstÚresponseÚlast_mod_headerÚdtÚlast_mod_mtimer`Ú progress_barÚbarÚchunkrÚfhÚlocal_checksumÚexcs( r-Údownloadz
File.download�s%€ð\#˜?‘%°ˆØ#2Ð#:™%ÀˆØ$Ð,‘5°(ˆØ$4Ð$<™5ÐBRÐØ’,˜QˆØ%Ò.¨ˆ
Ø+Ò4¨uÐØ1Ò:°UÐØ’˜4ˆÙ#‘"¨ˆØˆØˆ
؈à � ‰ ×Ñ×,Ñ,¸Ð,ÔAØÒ* §¡ˆ á Ø tÑ+ðÜ—H‘H˜WÔ%ô�w‰w�~‰~˜gÔ&Ü   Ð)=Ð>Ó?Ð?ÜŸ™Ÿ ™  W¨iÓ8ˆIä—W‘W—_‘_ YÓ/ˆ
ò ¤B§G¡G§N¡N°9×3CÑ3CÀGÓ3LÕ$MÙØ,CÐ)Ü—w‘w—~‘~Ð&?Ô@ÜÐ7¸ÀwÔOðÐSTØ÷äÐ3¸gÔFðBÈ!Ø,-¯F©F«H×,?Ñ,?Ó,AÐ)÷BàÐ 5Ñ5à# I ;ð/IðJðô—H‘H˜S”MÙÜ  # ˜i¬c¯j©jÕ9ØÙØ! ) Ð,BÐC�Ü—‘˜”
ÙܘA˜c˜U˜)¬#¯*©*Õ5ØÙÑ-ܘ) TÓ*ð0¨bÜ#Ÿm™m¨BÓ/�G÷0ð˜dŸh™hÒ&Ø% i [Ð0XÐY�CÜ—H‘H˜S”MÙÜ  # ˜i¬c¯j©jÕ9Ù'ä!Ð";¸SÈ7ÔSð6ÐWXØŸG™G y k°Ð$4Ô5÷6áððo
Ø Ò#Ð(8ÀÑ(DÜ—K‘K 
°TÕ:á'Ù /Ø ŸI™I¨D¯O©OÐ+<¸JÐ)GÒGÜŸG™GŸN™N¨9×+;Ñ+;¸GÓ+DÔEÜŸ™ ×!1Ñ!1°'Ó!:Ó;�BØ—z‘z T§Y¡YÒ.¹ÑDTØ#*¨f°R·Z±Z°LÀÐ,BÐ"C˜àŸ9™9×,Ñ,×0Ñ0Ø—H‘HØØ#ØŸ™Ø!Ø#ð
1ó�ð#+×"2Ñ"2×"6Ñ"6°Ó"G�Ù"Ü.¨Ó?�BØ%'§\¡\£^‘Nà%)§Z¡Z�Nà×)Ñ)Ô+ñÑ'7¼B¿G¹G¿N¹NÈ9×K[ÑK[Ð\cÓKdÔ<eÜŸ™ ×!1Ñ!1°'Ó!:Ó;�BØ—{‘{ nÒ4ØŸ9™9¨4¯?©?Ð*;¸:Ð(FÒFÈ2Ï:É:ÐY]×YbÑYbÒKbØ%.¨y¨kð:7ð$7˜CäŸH™H SœMÙ&Ü %¨¨#¨ i´c·j±jÕ AØ"á%Ø#�OáÜ × 0Ñ 0× 4Ñ 4Ð5EÀqÓ IÓJÒRÈd�EÜ#'¨}¸T¿Y¹Y¸KÐ-HØ.3Ø-1Ø37Ø59ô $;‘Lô $/£=�Lá!Ø!(�JÙÜ Ÿi™i¬¯
©
×(9Ñ(9Ó(;¸TÈ5ÔQ�GÙ¡(Ø 'Ñ)Ü"& y×'7Ñ'7¸Ó'@À%Ó"H™ä"& y×'7Ñ'7¸Ó'@À$Ó"G˜àñ S˜lð S¨cØ 'Ñ)ØŸ ™  R§Z¡ZÔ0Ø!)×!6Ñ!6À*Ð!6Ó!Mò1˜Ú Ø#*§=¡=°Ó#7˜DØ"™Ø #§
¡
¨4Õ 0ð 1ñ
ØŸ
™
¤b§j¡j§n¡n°U¸DÓ&A×&HÑ&HÈÓ&QÔR÷ S÷ Sð˜gÑ%ܘi¨Ó.ð;°"Ü).¯©°rÓ):˜÷;ðCØ-°·±Ò9Ð9Ñ9ðñ4#äœ'Ó"ñ
HÜ—‘˜×)Ñ)¨'Ó2°Q°~Ð4FÔG÷
Hð˜DŸO™OÐ,¨A¨d¯i©i¨[¸¸Y¸KÐHˆÜ �‰�Œ
ØøôU'òÚðú÷ñú÷BñBú÷$0ñ0ú÷6àú÷J Sñ Sú÷ Sñ Sú÷;ð;ûô*òCØ!# I ;ð/1ð 1˜ôŸ ™  )×"2Ñ"2°7Ó";Ô<Ü(×=Ñ=¸cÓBÐBð
Cûô¤ ¬>¼7ÄKÜ×3Ñ3ð5ò
à˜Q’;Ø#�Hؘq‘L�GØ;Ø+˜_Ð,CØ%˜Y nð6�Cô—K‘K Ô$ܘ-Ô(ÝØ/° ¨{Ð:NÈsÈeÐT�Ü— ‘ ˜#”ðÜ—I‘I˜iÕ(øÜòÙðúáܘA˜c˜U˜)¬#¯*©*Õ5Ù Ü à�Iûð-
ú÷6
Hñ
HúsÂ\0Å$]Å;]
È0]Ê(]'Ë H*_%Ó4_%Ó8C_%×^× 7]3Ø]3ØA]3Ù(^Ù0_%Ú^
Ú_%Ú'^Ú8_%Û (cÜ0 \=Ü<\=Ý]
Ý
]Ý]$Ý']0Ý3]= Ý8^Þ^
Þ_%Þ
^Þ_%ÞA _"ß"_%ß%-b>à5b9á
b9á+bâb9â b
â
b9â b
â
%b9â7b9â9b>ãc cóº—|sdnd}|s |jjjn|}|s |jjjn|}|xsd}|xsd}|xsd}|xsi}d|vr||d<|jjj›d|j
›dt
|j«›�} |jjj|dgd ¬