@debugmcp/codelldb-linux-arm64 0.0.0-stage → 1.12.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (980) hide show
  1. package/LICENSE +28 -0
  2. package/README.md +21 -2
  3. package/adapter/codelldb +0 -0
  4. package/adapter/scripts/codelldb/__init__.py +7 -0
  5. package/adapter/scripts/codelldb/api.py +125 -0
  6. package/adapter/scripts/codelldb/commands/__init__.py +7 -0
  7. package/adapter/scripts/codelldb/commands/debug_info.py +63 -0
  8. package/adapter/scripts/codelldb/commands/nofail.py +8 -0
  9. package/adapter/scripts/codelldb/event.py +19 -0
  10. package/adapter/scripts/codelldb/interface.py +423 -0
  11. package/adapter/scripts/codelldb/value.py +364 -0
  12. package/adapter/scripts/codelldb/webview.py +57 -0
  13. package/adapter/scripts/console.py +23 -0
  14. package/adapter/scripts/debugger.py +1 -0
  15. package/lang_support/__init__.py +23 -0
  16. package/lang_support/rust.py +87 -0
  17. package/lldb/bin/lldb +0 -0
  18. package/lldb/bin/lldb-argdumper +0 -0
  19. package/lldb/bin/lldb-server +0 -0
  20. package/lldb/lib/liblldb.so +4 -0
  21. package/lldb/lib/libpython312.so +0 -0
  22. package/lldb/lib/lldb-python/lldb/__init__.py +19655 -0
  23. package/lldb/lib/lldb-python/lldb/embedded_interpreter.py +97 -0
  24. package/lldb/lib/lldb-python/lldb/formatters/Logger.py +133 -0
  25. package/lldb/lib/lldb-python/lldb/formatters/__init__.py +11 -0
  26. package/lldb/lib/lldb-python/lldb/formatters/attrib_fromdict.py +41 -0
  27. package/lldb/lib/lldb-python/lldb/formatters/cache.py +35 -0
  28. package/lldb/lib/lldb-python/lldb/formatters/cpp/__init__.py +11 -0
  29. package/lldb/lib/lldb-python/lldb/formatters/cpp/gnu_libstdcpp.py +939 -0
  30. package/lldb/lib/lldb-python/lldb/formatters/cpp/libcxx.py +987 -0
  31. package/lldb/lib/lldb-python/lldb/formatters/metrics.py +119 -0
  32. package/lldb/lib/lldb-python/lldb/formatters/synth.py +59 -0
  33. package/lldb/lib/lldb-python/lldb/lldb-argdumper +0 -0
  34. package/lldb/lib/lldb-python/lldb/native/__init__.py +11 -0
  35. package/lldb/lib/lldb-python/lldb/plugins/__init__.py +11 -0
  36. package/lldb/lib/lldb-python/lldb/plugins/operating_system.py +103 -0
  37. package/lldb/lib/lldb-python/lldb/plugins/parsed_cmd.py +463 -0
  38. package/lldb/lib/lldb-python/lldb/plugins/scripted_frame_provider.py +188 -0
  39. package/lldb/lib/lldb-python/lldb/plugins/scripted_platform.py +96 -0
  40. package/lldb/lib/lldb-python/lldb/plugins/scripted_process.py +1475 -0
  41. package/lldb/lib/lldb-python/lldb/plugins/scripted_thread_plan.py +70 -0
  42. package/lldb/lib/lldb-python/lldb/utils/__init__.py +11 -0
  43. package/lldb/lib/lldb-python/lldb/utils/in_call_stack.py +24 -0
  44. package/lldb/lib/lldb-python/lldb/utils/symbolication.py +810 -0
  45. package/lldb/lib/python3.12/__future__.py +147 -0
  46. package/lldb/lib/python3.12/__hello__.py +16 -0
  47. package/lldb/lib/python3.12/__phello__/__init__.py +7 -0
  48. package/lldb/lib/python3.12/__phello__/spam.py +7 -0
  49. package/lldb/lib/python3.12/_aix_support.py +108 -0
  50. package/lldb/lib/python3.12/_collections_abc.py +1173 -0
  51. package/lldb/lib/python3.12/_compat_pickle.py +252 -0
  52. package/lldb/lib/python3.12/_compression.py +162 -0
  53. package/lldb/lib/python3.12/_markupbase.py +396 -0
  54. package/lldb/lib/python3.12/_osx_support.py +579 -0
  55. package/lldb/lib/python3.12/_py_abc.py +147 -0
  56. package/lldb/lib/python3.12/_pydatetime.py +2645 -0
  57. package/lldb/lib/python3.12/_pydecimal.py +6339 -0
  58. package/lldb/lib/python3.12/_pyio.py +2698 -0
  59. package/lldb/lib/python3.12/_pylong.py +329 -0
  60. package/lldb/lib/python3.12/_sitebuiltins.py +103 -0
  61. package/lldb/lib/python3.12/_strptime.py +565 -0
  62. package/lldb/lib/python3.12/_sysconfigdata__linux_aarch64-linux-gnu.py +1230 -0
  63. package/lldb/lib/python3.12/_threading_local.py +242 -0
  64. package/lldb/lib/python3.12/_weakrefset.py +205 -0
  65. package/lldb/lib/python3.12/abc.py +188 -0
  66. package/lldb/lib/python3.12/aifc.py +984 -0
  67. package/lldb/lib/python3.12/antigravity.py +17 -0
  68. package/lldb/lib/python3.12/argparse.py +2672 -0
  69. package/lldb/lib/python3.12/ast.py +1835 -0
  70. package/lldb/lib/python3.12/asyncio/__init__.py +47 -0
  71. package/lldb/lib/python3.12/asyncio/__main__.py +126 -0
  72. package/lldb/lib/python3.12/asyncio/base_events.py +2011 -0
  73. package/lldb/lib/python3.12/asyncio/base_futures.py +67 -0
  74. package/lldb/lib/python3.12/asyncio/base_subprocess.py +285 -0
  75. package/lldb/lib/python3.12/asyncio/base_tasks.py +94 -0
  76. package/lldb/lib/python3.12/asyncio/constants.py +41 -0
  77. package/lldb/lib/python3.12/asyncio/coroutines.py +109 -0
  78. package/lldb/lib/python3.12/asyncio/events.py +868 -0
  79. package/lldb/lib/python3.12/asyncio/exceptions.py +62 -0
  80. package/lldb/lib/python3.12/asyncio/format_helpers.py +76 -0
  81. package/lldb/lib/python3.12/asyncio/futures.py +432 -0
  82. package/lldb/lib/python3.12/asyncio/locks.py +586 -0
  83. package/lldb/lib/python3.12/asyncio/log.py +7 -0
  84. package/lldb/lib/python3.12/asyncio/mixins.py +21 -0
  85. package/lldb/lib/python3.12/asyncio/proactor_events.py +897 -0
  86. package/lldb/lib/python3.12/asyncio/protocols.py +216 -0
  87. package/lldb/lib/python3.12/asyncio/queues.py +244 -0
  88. package/lldb/lib/python3.12/asyncio/runners.py +215 -0
  89. package/lldb/lib/python3.12/asyncio/selector_events.py +1321 -0
  90. package/lldb/lib/python3.12/asyncio/sslproto.py +926 -0
  91. package/lldb/lib/python3.12/asyncio/staggered.py +138 -0
  92. package/lldb/lib/python3.12/asyncio/streams.py +770 -0
  93. package/lldb/lib/python3.12/asyncio/subprocess.py +229 -0
  94. package/lldb/lib/python3.12/asyncio/taskgroups.py +240 -0
  95. package/lldb/lib/python3.12/asyncio/tasks.py +1065 -0
  96. package/lldb/lib/python3.12/asyncio/threads.py +25 -0
  97. package/lldb/lib/python3.12/asyncio/timeouts.py +168 -0
  98. package/lldb/lib/python3.12/asyncio/transports.py +335 -0
  99. package/lldb/lib/python3.12/asyncio/trsock.py +98 -0
  100. package/lldb/lib/python3.12/asyncio/unix_events.py +1500 -0
  101. package/lldb/lib/python3.12/asyncio/windows_events.py +901 -0
  102. package/lldb/lib/python3.12/asyncio/windows_utils.py +173 -0
  103. package/lldb/lib/python3.12/base64.py +586 -0
  104. package/lldb/lib/python3.12/bdb.py +899 -0
  105. package/lldb/lib/python3.12/bisect.py +118 -0
  106. package/lldb/lib/python3.12/bz2.py +344 -0
  107. package/lldb/lib/python3.12/cProfile.py +195 -0
  108. package/lldb/lib/python3.12/calendar.py +798 -0
  109. package/lldb/lib/python3.12/cgi.py +1013 -0
  110. package/lldb/lib/python3.12/cgitb.py +332 -0
  111. package/lldb/lib/python3.12/chunk.py +173 -0
  112. package/lldb/lib/python3.12/cmd.py +401 -0
  113. package/lldb/lib/python3.12/code.py +324 -0
  114. package/lldb/lib/python3.12/codecs.py +1129 -0
  115. package/lldb/lib/python3.12/codeop.py +161 -0
  116. package/lldb/lib/python3.12/collections/__init__.py +1592 -0
  117. package/lldb/lib/python3.12/collections/abc.py +3 -0
  118. package/lldb/lib/python3.12/colorsys.py +166 -0
  119. package/lldb/lib/python3.12/compileall.py +469 -0
  120. package/lldb/lib/python3.12/concurrent/__init__.py +1 -0
  121. package/lldb/lib/python3.12/concurrent/futures/__init__.py +54 -0
  122. package/lldb/lib/python3.12/concurrent/futures/_base.py +654 -0
  123. package/lldb/lib/python3.12/concurrent/futures/process.py +884 -0
  124. package/lldb/lib/python3.12/concurrent/futures/thread.py +239 -0
  125. package/lldb/lib/python3.12/configparser.py +1333 -0
  126. package/lldb/lib/python3.12/contextlib.py +800 -0
  127. package/lldb/lib/python3.12/contextvars.py +4 -0
  128. package/lldb/lib/python3.12/copy.py +292 -0
  129. package/lldb/lib/python3.12/copyreg.py +217 -0
  130. package/lldb/lib/python3.12/crypt.py +124 -0
  131. package/lldb/lib/python3.12/csv.py +451 -0
  132. package/lldb/lib/python3.12/ctypes/__init__.py +582 -0
  133. package/lldb/lib/python3.12/ctypes/_aix.py +327 -0
  134. package/lldb/lib/python3.12/ctypes/_endian.py +78 -0
  135. package/lldb/lib/python3.12/ctypes/macholib/__init__.py +9 -0
  136. package/lldb/lib/python3.12/ctypes/macholib/dyld.py +165 -0
  137. package/lldb/lib/python3.12/ctypes/macholib/dylib.py +42 -0
  138. package/lldb/lib/python3.12/ctypes/macholib/framework.py +42 -0
  139. package/lldb/lib/python3.12/ctypes/util.py +379 -0
  140. package/lldb/lib/python3.12/ctypes/wintypes.py +202 -0
  141. package/lldb/lib/python3.12/dataclasses.py +1588 -0
  142. package/lldb/lib/python3.12/datetime.py +9 -0
  143. package/lldb/lib/python3.12/dbm/__init__.py +190 -0
  144. package/lldb/lib/python3.12/dbm/dumb.py +317 -0
  145. package/lldb/lib/python3.12/dbm/gnu.py +3 -0
  146. package/lldb/lib/python3.12/dbm/ndbm.py +3 -0
  147. package/lldb/lib/python3.12/decimal.py +108 -0
  148. package/lldb/lib/python3.12/difflib.py +2056 -0
  149. package/lldb/lib/python3.12/dis.py +805 -0
  150. package/lldb/lib/python3.12/doctest.py +2845 -0
  151. package/lldb/lib/python3.12/email/__init__.py +61 -0
  152. package/lldb/lib/python3.12/email/_encoded_words.py +233 -0
  153. package/lldb/lib/python3.12/email/_header_value_parser.py +3078 -0
  154. package/lldb/lib/python3.12/email/_parseaddr.py +557 -0
  155. package/lldb/lib/python3.12/email/_policybase.py +382 -0
  156. package/lldb/lib/python3.12/email/base64mime.py +115 -0
  157. package/lldb/lib/python3.12/email/charset.py +398 -0
  158. package/lldb/lib/python3.12/email/contentmanager.py +251 -0
  159. package/lldb/lib/python3.12/email/encoders.py +65 -0
  160. package/lldb/lib/python3.12/email/errors.py +117 -0
  161. package/lldb/lib/python3.12/email/feedparser.py +534 -0
  162. package/lldb/lib/python3.12/email/generator.py +520 -0
  163. package/lldb/lib/python3.12/email/header.py +573 -0
  164. package/lldb/lib/python3.12/email/headerregistry.py +604 -0
  165. package/lldb/lib/python3.12/email/iterators.py +68 -0
  166. package/lldb/lib/python3.12/email/message.py +1205 -0
  167. package/lldb/lib/python3.12/email/mime/__init__.py +0 -0
  168. package/lldb/lib/python3.12/email/mime/application.py +37 -0
  169. package/lldb/lib/python3.12/email/mime/audio.py +100 -0
  170. package/lldb/lib/python3.12/email/mime/base.py +29 -0
  171. package/lldb/lib/python3.12/email/mime/image.py +152 -0
  172. package/lldb/lib/python3.12/email/mime/message.py +33 -0
  173. package/lldb/lib/python3.12/email/mime/multipart.py +47 -0
  174. package/lldb/lib/python3.12/email/mime/nonmultipart.py +21 -0
  175. package/lldb/lib/python3.12/email/mime/text.py +40 -0
  176. package/lldb/lib/python3.12/email/parser.py +127 -0
  177. package/lldb/lib/python3.12/email/policy.py +232 -0
  178. package/lldb/lib/python3.12/email/quoprimime.py +300 -0
  179. package/lldb/lib/python3.12/email/utils.py +486 -0
  180. package/lldb/lib/python3.12/encodings/__init__.py +174 -0
  181. package/lldb/lib/python3.12/encodings/aliases.py +551 -0
  182. package/lldb/lib/python3.12/encodings/ascii.py +50 -0
  183. package/lldb/lib/python3.12/encodings/base64_codec.py +55 -0
  184. package/lldb/lib/python3.12/encodings/big5.py +39 -0
  185. package/lldb/lib/python3.12/encodings/big5hkscs.py +39 -0
  186. package/lldb/lib/python3.12/encodings/bz2_codec.py +78 -0
  187. package/lldb/lib/python3.12/encodings/charmap.py +69 -0
  188. package/lldb/lib/python3.12/encodings/cp037.py +307 -0
  189. package/lldb/lib/python3.12/encodings/cp1006.py +307 -0
  190. package/lldb/lib/python3.12/encodings/cp1026.py +307 -0
  191. package/lldb/lib/python3.12/encodings/cp1125.py +698 -0
  192. package/lldb/lib/python3.12/encodings/cp1140.py +307 -0
  193. package/lldb/lib/python3.12/encodings/cp1250.py +307 -0
  194. package/lldb/lib/python3.12/encodings/cp1251.py +307 -0
  195. package/lldb/lib/python3.12/encodings/cp1252.py +307 -0
  196. package/lldb/lib/python3.12/encodings/cp1253.py +307 -0
  197. package/lldb/lib/python3.12/encodings/cp1254.py +307 -0
  198. package/lldb/lib/python3.12/encodings/cp1255.py +307 -0
  199. package/lldb/lib/python3.12/encodings/cp1256.py +307 -0
  200. package/lldb/lib/python3.12/encodings/cp1257.py +307 -0
  201. package/lldb/lib/python3.12/encodings/cp1258.py +307 -0
  202. package/lldb/lib/python3.12/encodings/cp273.py +307 -0
  203. package/lldb/lib/python3.12/encodings/cp424.py +307 -0
  204. package/lldb/lib/python3.12/encodings/cp437.py +698 -0
  205. package/lldb/lib/python3.12/encodings/cp500.py +307 -0
  206. package/lldb/lib/python3.12/encodings/cp720.py +309 -0
  207. package/lldb/lib/python3.12/encodings/cp737.py +698 -0
  208. package/lldb/lib/python3.12/encodings/cp775.py +697 -0
  209. package/lldb/lib/python3.12/encodings/cp850.py +698 -0
  210. package/lldb/lib/python3.12/encodings/cp852.py +698 -0
  211. package/lldb/lib/python3.12/encodings/cp855.py +698 -0
  212. package/lldb/lib/python3.12/encodings/cp856.py +307 -0
  213. package/lldb/lib/python3.12/encodings/cp857.py +694 -0
  214. package/lldb/lib/python3.12/encodings/cp858.py +698 -0
  215. package/lldb/lib/python3.12/encodings/cp860.py +698 -0
  216. package/lldb/lib/python3.12/encodings/cp861.py +698 -0
  217. package/lldb/lib/python3.12/encodings/cp862.py +698 -0
  218. package/lldb/lib/python3.12/encodings/cp863.py +698 -0
  219. package/lldb/lib/python3.12/encodings/cp864.py +690 -0
  220. package/lldb/lib/python3.12/encodings/cp865.py +698 -0
  221. package/lldb/lib/python3.12/encodings/cp866.py +698 -0
  222. package/lldb/lib/python3.12/encodings/cp869.py +689 -0
  223. package/lldb/lib/python3.12/encodings/cp874.py +307 -0
  224. package/lldb/lib/python3.12/encodings/cp875.py +307 -0
  225. package/lldb/lib/python3.12/encodings/cp932.py +39 -0
  226. package/lldb/lib/python3.12/encodings/cp949.py +39 -0
  227. package/lldb/lib/python3.12/encodings/cp950.py +39 -0
  228. package/lldb/lib/python3.12/encodings/euc_jis_2004.py +39 -0
  229. package/lldb/lib/python3.12/encodings/euc_jisx0213.py +39 -0
  230. package/lldb/lib/python3.12/encodings/euc_jp.py +39 -0
  231. package/lldb/lib/python3.12/encodings/euc_kr.py +39 -0
  232. package/lldb/lib/python3.12/encodings/gb18030.py +39 -0
  233. package/lldb/lib/python3.12/encodings/gb2312.py +39 -0
  234. package/lldb/lib/python3.12/encodings/gbk.py +39 -0
  235. package/lldb/lib/python3.12/encodings/hex_codec.py +55 -0
  236. package/lldb/lib/python3.12/encodings/hp_roman8.py +314 -0
  237. package/lldb/lib/python3.12/encodings/hz.py +39 -0
  238. package/lldb/lib/python3.12/encodings/idna.py +317 -0
  239. package/lldb/lib/python3.12/encodings/iso2022_jp.py +39 -0
  240. package/lldb/lib/python3.12/encodings/iso2022_jp_1.py +39 -0
  241. package/lldb/lib/python3.12/encodings/iso2022_jp_2.py +39 -0
  242. package/lldb/lib/python3.12/encodings/iso2022_jp_2004.py +39 -0
  243. package/lldb/lib/python3.12/encodings/iso2022_jp_3.py +39 -0
  244. package/lldb/lib/python3.12/encodings/iso2022_jp_ext.py +39 -0
  245. package/lldb/lib/python3.12/encodings/iso2022_kr.py +39 -0
  246. package/lldb/lib/python3.12/encodings/iso8859_1.py +307 -0
  247. package/lldb/lib/python3.12/encodings/iso8859_10.py +307 -0
  248. package/lldb/lib/python3.12/encodings/iso8859_11.py +307 -0
  249. package/lldb/lib/python3.12/encodings/iso8859_13.py +307 -0
  250. package/lldb/lib/python3.12/encodings/iso8859_14.py +307 -0
  251. package/lldb/lib/python3.12/encodings/iso8859_15.py +307 -0
  252. package/lldb/lib/python3.12/encodings/iso8859_16.py +307 -0
  253. package/lldb/lib/python3.12/encodings/iso8859_2.py +307 -0
  254. package/lldb/lib/python3.12/encodings/iso8859_3.py +307 -0
  255. package/lldb/lib/python3.12/encodings/iso8859_4.py +307 -0
  256. package/lldb/lib/python3.12/encodings/iso8859_5.py +307 -0
  257. package/lldb/lib/python3.12/encodings/iso8859_6.py +307 -0
  258. package/lldb/lib/python3.12/encodings/iso8859_7.py +307 -0
  259. package/lldb/lib/python3.12/encodings/iso8859_8.py +307 -0
  260. package/lldb/lib/python3.12/encodings/iso8859_9.py +307 -0
  261. package/lldb/lib/python3.12/encodings/johab.py +39 -0
  262. package/lldb/lib/python3.12/encodings/koi8_r.py +307 -0
  263. package/lldb/lib/python3.12/encodings/koi8_t.py +308 -0
  264. package/lldb/lib/python3.12/encodings/koi8_u.py +307 -0
  265. package/lldb/lib/python3.12/encodings/kz1048.py +307 -0
  266. package/lldb/lib/python3.12/encodings/latin_1.py +50 -0
  267. package/lldb/lib/python3.12/encodings/mac_arabic.py +698 -0
  268. package/lldb/lib/python3.12/encodings/mac_croatian.py +307 -0
  269. package/lldb/lib/python3.12/encodings/mac_cyrillic.py +307 -0
  270. package/lldb/lib/python3.12/encodings/mac_farsi.py +307 -0
  271. package/lldb/lib/python3.12/encodings/mac_greek.py +307 -0
  272. package/lldb/lib/python3.12/encodings/mac_iceland.py +307 -0
  273. package/lldb/lib/python3.12/encodings/mac_latin2.py +312 -0
  274. package/lldb/lib/python3.12/encodings/mac_roman.py +307 -0
  275. package/lldb/lib/python3.12/encodings/mac_romanian.py +307 -0
  276. package/lldb/lib/python3.12/encodings/mac_turkish.py +307 -0
  277. package/lldb/lib/python3.12/encodings/mbcs.py +47 -0
  278. package/lldb/lib/python3.12/encodings/oem.py +41 -0
  279. package/lldb/lib/python3.12/encodings/palmos.py +308 -0
  280. package/lldb/lib/python3.12/encodings/ptcp154.py +312 -0
  281. package/lldb/lib/python3.12/encodings/punycode.py +237 -0
  282. package/lldb/lib/python3.12/encodings/quopri_codec.py +56 -0
  283. package/lldb/lib/python3.12/encodings/raw_unicode_escape.py +46 -0
  284. package/lldb/lib/python3.12/encodings/rot_13.py +113 -0
  285. package/lldb/lib/python3.12/encodings/shift_jis.py +39 -0
  286. package/lldb/lib/python3.12/encodings/shift_jis_2004.py +39 -0
  287. package/lldb/lib/python3.12/encodings/shift_jisx0213.py +39 -0
  288. package/lldb/lib/python3.12/encodings/tis_620.py +307 -0
  289. package/lldb/lib/python3.12/encodings/undefined.py +49 -0
  290. package/lldb/lib/python3.12/encodings/unicode_escape.py +46 -0
  291. package/lldb/lib/python3.12/encodings/utf_16.py +155 -0
  292. package/lldb/lib/python3.12/encodings/utf_16_be.py +42 -0
  293. package/lldb/lib/python3.12/encodings/utf_16_le.py +42 -0
  294. package/lldb/lib/python3.12/encodings/utf_32.py +150 -0
  295. package/lldb/lib/python3.12/encodings/utf_32_be.py +37 -0
  296. package/lldb/lib/python3.12/encodings/utf_32_le.py +37 -0
  297. package/lldb/lib/python3.12/encodings/utf_7.py +38 -0
  298. package/lldb/lib/python3.12/encodings/utf_8.py +42 -0
  299. package/lldb/lib/python3.12/encodings/utf_8_sig.py +130 -0
  300. package/lldb/lib/python3.12/encodings/uu_codec.py +103 -0
  301. package/lldb/lib/python3.12/encodings/zlib_codec.py +77 -0
  302. package/lldb/lib/python3.12/ensurepip/__init__.py +291 -0
  303. package/lldb/lib/python3.12/ensurepip/__main__.py +5 -0
  304. package/lldb/lib/python3.12/ensurepip/_uninstall.py +31 -0
  305. package/lldb/lib/python3.12/enum.py +2109 -0
  306. package/lldb/lib/python3.12/filecmp.py +315 -0
  307. package/lldb/lib/python3.12/fileinput.py +442 -0
  308. package/lldb/lib/python3.12/fnmatch.py +185 -0
  309. package/lldb/lib/python3.12/fractions.py +990 -0
  310. package/lldb/lib/python3.12/ftplib.py +966 -0
  311. package/lldb/lib/python3.12/functools.py +1004 -0
  312. package/lldb/lib/python3.12/genericpath.py +167 -0
  313. package/lldb/lib/python3.12/getopt.py +215 -0
  314. package/lldb/lib/python3.12/getpass.py +185 -0
  315. package/lldb/lib/python3.12/gettext.py +646 -0
  316. package/lldb/lib/python3.12/glob.py +252 -0
  317. package/lldb/lib/python3.12/graphlib.py +250 -0
  318. package/lldb/lib/python3.12/gzip.py +694 -0
  319. package/lldb/lib/python3.12/hashlib.py +253 -0
  320. package/lldb/lib/python3.12/heapq.py +603 -0
  321. package/lldb/lib/python3.12/hmac.py +219 -0
  322. package/lldb/lib/python3.12/html/__init__.py +132 -0
  323. package/lldb/lib/python3.12/html/entities.py +2513 -0
  324. package/lldb/lib/python3.12/html/parser.py +456 -0
  325. package/lldb/lib/python3.12/http/__init__.py +200 -0
  326. package/lldb/lib/python3.12/http/client.py +1548 -0
  327. package/lldb/lib/python3.12/http/cookiejar.py +2121 -0
  328. package/lldb/lib/python3.12/http/cookies.py +594 -0
  329. package/lldb/lib/python3.12/http/server.py +1320 -0
  330. package/lldb/lib/python3.12/imaplib.py +1632 -0
  331. package/lldb/lib/python3.12/imghdr.py +180 -0
  332. package/lldb/lib/python3.12/importlib/__init__.py +138 -0
  333. package/lldb/lib/python3.12/importlib/_abc.py +39 -0
  334. package/lldb/lib/python3.12/importlib/_bootstrap.py +1551 -0
  335. package/lldb/lib/python3.12/importlib/_bootstrap_external.py +1745 -0
  336. package/lldb/lib/python3.12/importlib/abc.py +239 -0
  337. package/lldb/lib/python3.12/importlib/machinery.py +20 -0
  338. package/lldb/lib/python3.12/importlib/metadata/__init__.py +966 -0
  339. package/lldb/lib/python3.12/importlib/metadata/_adapters.py +89 -0
  340. package/lldb/lib/python3.12/importlib/metadata/_collections.py +30 -0
  341. package/lldb/lib/python3.12/importlib/metadata/_functools.py +104 -0
  342. package/lldb/lib/python3.12/importlib/metadata/_itertools.py +73 -0
  343. package/lldb/lib/python3.12/importlib/metadata/_meta.py +63 -0
  344. package/lldb/lib/python3.12/importlib/metadata/_text.py +99 -0
  345. package/lldb/lib/python3.12/importlib/readers.py +12 -0
  346. package/lldb/lib/python3.12/importlib/resources/__init__.py +36 -0
  347. package/lldb/lib/python3.12/importlib/resources/_adapters.py +168 -0
  348. package/lldb/lib/python3.12/importlib/resources/_common.py +207 -0
  349. package/lldb/lib/python3.12/importlib/resources/_itertools.py +38 -0
  350. package/lldb/lib/python3.12/importlib/resources/_legacy.py +120 -0
  351. package/lldb/lib/python3.12/importlib/resources/abc.py +173 -0
  352. package/lldb/lib/python3.12/importlib/resources/readers.py +146 -0
  353. package/lldb/lib/python3.12/importlib/resources/simple.py +106 -0
  354. package/lldb/lib/python3.12/importlib/simple.py +14 -0
  355. package/lldb/lib/python3.12/importlib/util.py +270 -0
  356. package/lldb/lib/python3.12/inspect.py +3426 -0
  357. package/lldb/lib/python3.12/io.py +99 -0
  358. package/lldb/lib/python3.12/ipaddress.py +2380 -0
  359. package/lldb/lib/python3.12/json/__init__.py +359 -0
  360. package/lldb/lib/python3.12/json/decoder.py +356 -0
  361. package/lldb/lib/python3.12/json/encoder.py +443 -0
  362. package/lldb/lib/python3.12/json/scanner.py +73 -0
  363. package/lldb/lib/python3.12/json/tool.py +85 -0
  364. package/lldb/lib/python3.12/keyword.py +64 -0
  365. package/lldb/lib/python3.12/linecache.py +182 -0
  366. package/lldb/lib/python3.12/locale.py +1779 -0
  367. package/lldb/lib/python3.12/logging/__init__.py +2345 -0
  368. package/lldb/lib/python3.12/logging/config.py +1078 -0
  369. package/lldb/lib/python3.12/logging/handlers.py +1608 -0
  370. package/lldb/lib/python3.12/lzma.py +356 -0
  371. package/lldb/lib/python3.12/mailbox.py +2153 -0
  372. package/lldb/lib/python3.12/mailcap.py +302 -0
  373. package/lldb/lib/python3.12/mimetypes.py +653 -0
  374. package/lldb/lib/python3.12/modulefinder.py +666 -0
  375. package/lldb/lib/python3.12/multiprocessing/__init__.py +37 -0
  376. package/lldb/lib/python3.12/multiprocessing/connection.py +1178 -0
  377. package/lldb/lib/python3.12/multiprocessing/context.py +377 -0
  378. package/lldb/lib/python3.12/multiprocessing/dummy/__init__.py +126 -0
  379. package/lldb/lib/python3.12/multiprocessing/dummy/connection.py +75 -0
  380. package/lldb/lib/python3.12/multiprocessing/forkserver.py +348 -0
  381. package/lldb/lib/python3.12/multiprocessing/heap.py +337 -0
  382. package/lldb/lib/python3.12/multiprocessing/managers.py +1380 -0
  383. package/lldb/lib/python3.12/multiprocessing/pool.py +957 -0
  384. package/lldb/lib/python3.12/multiprocessing/popen_fork.py +83 -0
  385. package/lldb/lib/python3.12/multiprocessing/popen_forkserver.py +74 -0
  386. package/lldb/lib/python3.12/multiprocessing/popen_spawn_posix.py +72 -0
  387. package/lldb/lib/python3.12/multiprocessing/popen_spawn_win32.py +145 -0
  388. package/lldb/lib/python3.12/multiprocessing/process.py +439 -0
  389. package/lldb/lib/python3.12/multiprocessing/queues.py +401 -0
  390. package/lldb/lib/python3.12/multiprocessing/reduction.py +281 -0
  391. package/lldb/lib/python3.12/multiprocessing/resource_sharer.py +154 -0
  392. package/lldb/lib/python3.12/multiprocessing/resource_tracker.py +269 -0
  393. package/lldb/lib/python3.12/multiprocessing/shared_memory.py +534 -0
  394. package/lldb/lib/python3.12/multiprocessing/sharedctypes.py +240 -0
  395. package/lldb/lib/python3.12/multiprocessing/spawn.py +307 -0
  396. package/lldb/lib/python3.12/multiprocessing/synchronize.py +404 -0
  397. package/lldb/lib/python3.12/multiprocessing/util.py +494 -0
  398. package/lldb/lib/python3.12/netrc.py +192 -0
  399. package/lldb/lib/python3.12/nntplib.py +1093 -0
  400. package/lldb/lib/python3.12/ntpath.py +889 -0
  401. package/lldb/lib/python3.12/nturl2path.py +81 -0
  402. package/lldb/lib/python3.12/numbers.py +418 -0
  403. package/lldb/lib/python3.12/opcode.py +493 -0
  404. package/lldb/lib/python3.12/operator.py +467 -0
  405. package/lldb/lib/python3.12/optparse.py +1681 -0
  406. package/lldb/lib/python3.12/os.py +1159 -0
  407. package/lldb/lib/python3.12/pathlib.py +1435 -0
  408. package/lldb/lib/python3.12/pdb.py +1987 -0
  409. package/lldb/lib/python3.12/pickle.py +1865 -0
  410. package/lldb/lib/python3.12/pickletools.py +2901 -0
  411. package/lldb/lib/python3.12/pipes.py +250 -0
  412. package/lldb/lib/python3.12/pkgutil.py +529 -0
  413. package/lldb/lib/python3.12/platform.py +1358 -0
  414. package/lldb/lib/python3.12/plistlib.py +911 -0
  415. package/lldb/lib/python3.12/poplib.py +467 -0
  416. package/lldb/lib/python3.12/posixpath.py +573 -0
  417. package/lldb/lib/python3.12/pprint.py +658 -0
  418. package/lldb/lib/python3.12/profile.py +615 -0
  419. package/lldb/lib/python3.12/pstats.py +778 -0
  420. package/lldb/lib/python3.12/pty.py +211 -0
  421. package/lldb/lib/python3.12/py_compile.py +212 -0
  422. package/lldb/lib/python3.12/pyclbr.py +314 -0
  423. package/lldb/lib/python3.12/pydoc.py +2941 -0
  424. package/lldb/lib/python3.12/pydoc_data/__init__.py +0 -0
  425. package/lldb/lib/python3.12/pydoc_data/topics.py +16777 -0
  426. package/lldb/lib/python3.12/queue.py +326 -0
  427. package/lldb/lib/python3.12/quopri.py +237 -0
  428. package/lldb/lib/python3.12/random.py +996 -0
  429. package/lldb/lib/python3.12/re/__init__.py +385 -0
  430. package/lldb/lib/python3.12/re/_casefix.py +106 -0
  431. package/lldb/lib/python3.12/re/_compiler.py +765 -0
  432. package/lldb/lib/python3.12/re/_constants.py +220 -0
  433. package/lldb/lib/python3.12/re/_parser.py +1080 -0
  434. package/lldb/lib/python3.12/reprlib.py +193 -0
  435. package/lldb/lib/python3.12/rlcompleter.py +219 -0
  436. package/lldb/lib/python3.12/runpy.py +319 -0
  437. package/lldb/lib/python3.12/sched.py +167 -0
  438. package/lldb/lib/python3.12/secrets.py +71 -0
  439. package/lldb/lib/python3.12/selectors.py +623 -0
  440. package/lldb/lib/python3.12/shelve.py +243 -0
  441. package/lldb/lib/python3.12/shlex.py +345 -0
  442. package/lldb/lib/python3.12/shutil.py +1566 -0
  443. package/lldb/lib/python3.12/signal.py +94 -0
  444. package/lldb/lib/python3.12/site-packages/pip/__init__.py +13 -0
  445. package/lldb/lib/python3.12/site-packages/pip/__main__.py +24 -0
  446. package/lldb/lib/python3.12/site-packages/pip/__pip-runner__.py +50 -0
  447. package/lldb/lib/python3.12/site-packages/pip/_internal/__init__.py +18 -0
  448. package/lldb/lib/python3.12/site-packages/pip/_internal/build_env.py +314 -0
  449. package/lldb/lib/python3.12/site-packages/pip/_internal/cache.py +290 -0
  450. package/lldb/lib/python3.12/site-packages/pip/_internal/cli/__init__.py +4 -0
  451. package/lldb/lib/python3.12/site-packages/pip/_internal/cli/autocompletion.py +176 -0
  452. package/lldb/lib/python3.12/site-packages/pip/_internal/cli/base_command.py +234 -0
  453. package/lldb/lib/python3.12/site-packages/pip/_internal/cli/cmdoptions.py +1074 -0
  454. package/lldb/lib/python3.12/site-packages/pip/_internal/cli/command_context.py +27 -0
  455. package/lldb/lib/python3.12/site-packages/pip/_internal/cli/index_command.py +172 -0
  456. package/lldb/lib/python3.12/site-packages/pip/_internal/cli/main.py +80 -0
  457. package/lldb/lib/python3.12/site-packages/pip/_internal/cli/main_parser.py +134 -0
  458. package/lldb/lib/python3.12/site-packages/pip/_internal/cli/parser.py +294 -0
  459. package/lldb/lib/python3.12/site-packages/pip/_internal/cli/progress_bars.py +94 -0
  460. package/lldb/lib/python3.12/site-packages/pip/_internal/cli/req_command.py +329 -0
  461. package/lldb/lib/python3.12/site-packages/pip/_internal/cli/spinners.py +159 -0
  462. package/lldb/lib/python3.12/site-packages/pip/_internal/cli/status_codes.py +6 -0
  463. package/lldb/lib/python3.12/site-packages/pip/_internal/commands/__init__.py +132 -0
  464. package/lldb/lib/python3.12/site-packages/pip/_internal/commands/cache.py +225 -0
  465. package/lldb/lib/python3.12/site-packages/pip/_internal/commands/check.py +52 -0
  466. package/lldb/lib/python3.12/site-packages/pip/_internal/commands/completion.py +130 -0
  467. package/lldb/lib/python3.12/site-packages/pip/_internal/commands/configuration.py +280 -0
  468. package/lldb/lib/python3.12/site-packages/pip/_internal/commands/debug.py +201 -0
  469. package/lldb/lib/python3.12/site-packages/pip/_internal/commands/download.py +146 -0
  470. package/lldb/lib/python3.12/site-packages/pip/_internal/commands/freeze.py +108 -0
  471. package/lldb/lib/python3.12/site-packages/pip/_internal/commands/hash.py +59 -0
  472. package/lldb/lib/python3.12/site-packages/pip/_internal/commands/help.py +41 -0
  473. package/lldb/lib/python3.12/site-packages/pip/_internal/commands/index.py +139 -0
  474. package/lldb/lib/python3.12/site-packages/pip/_internal/commands/inspect.py +92 -0
  475. package/lldb/lib/python3.12/site-packages/pip/_internal/commands/install.py +777 -0
  476. package/lldb/lib/python3.12/site-packages/pip/_internal/commands/list.py +375 -0
  477. package/lldb/lib/python3.12/site-packages/pip/_internal/commands/search.py +172 -0
  478. package/lldb/lib/python3.12/site-packages/pip/_internal/commands/show.py +217 -0
  479. package/lldb/lib/python3.12/site-packages/pip/_internal/commands/uninstall.py +114 -0
  480. package/lldb/lib/python3.12/site-packages/pip/_internal/commands/wheel.py +182 -0
  481. package/lldb/lib/python3.12/site-packages/pip/_internal/configuration.py +383 -0
  482. package/lldb/lib/python3.12/site-packages/pip/_internal/distributions/__init__.py +21 -0
  483. package/lldb/lib/python3.12/site-packages/pip/_internal/distributions/base.py +53 -0
  484. package/lldb/lib/python3.12/site-packages/pip/_internal/distributions/installed.py +29 -0
  485. package/lldb/lib/python3.12/site-packages/pip/_internal/distributions/sdist.py +158 -0
  486. package/lldb/lib/python3.12/site-packages/pip/_internal/distributions/wheel.py +42 -0
  487. package/lldb/lib/python3.12/site-packages/pip/_internal/exceptions.py +777 -0
  488. package/lldb/lib/python3.12/site-packages/pip/_internal/index/__init__.py +2 -0
  489. package/lldb/lib/python3.12/site-packages/pip/_internal/index/collector.py +494 -0
  490. package/lldb/lib/python3.12/site-packages/pip/_internal/index/package_finder.py +1021 -0
  491. package/lldb/lib/python3.12/site-packages/pip/_internal/index/sources.py +285 -0
  492. package/lldb/lib/python3.12/site-packages/pip/_internal/locations/__init__.py +456 -0
  493. package/lldb/lib/python3.12/site-packages/pip/_internal/locations/_distutils.py +172 -0
  494. package/lldb/lib/python3.12/site-packages/pip/_internal/locations/_sysconfig.py +214 -0
  495. package/lldb/lib/python3.12/site-packages/pip/_internal/locations/base.py +81 -0
  496. package/lldb/lib/python3.12/site-packages/pip/_internal/main.py +12 -0
  497. package/lldb/lib/python3.12/site-packages/pip/_internal/metadata/__init__.py +128 -0
  498. package/lldb/lib/python3.12/site-packages/pip/_internal/metadata/_json.py +84 -0
  499. package/lldb/lib/python3.12/site-packages/pip/_internal/metadata/base.py +688 -0
  500. package/lldb/lib/python3.12/site-packages/pip/_internal/metadata/importlib/__init__.py +6 -0
  501. package/lldb/lib/python3.12/site-packages/pip/_internal/metadata/importlib/_compat.py +55 -0
  502. package/lldb/lib/python3.12/site-packages/pip/_internal/metadata/importlib/_dists.py +228 -0
  503. package/lldb/lib/python3.12/site-packages/pip/_internal/metadata/importlib/_envs.py +189 -0
  504. package/lldb/lib/python3.12/site-packages/pip/_internal/metadata/pkg_resources.py +301 -0
  505. package/lldb/lib/python3.12/site-packages/pip/_internal/models/__init__.py +2 -0
  506. package/lldb/lib/python3.12/site-packages/pip/_internal/models/candidate.py +25 -0
  507. package/lldb/lib/python3.12/site-packages/pip/_internal/models/direct_url.py +224 -0
  508. package/lldb/lib/python3.12/site-packages/pip/_internal/models/format_control.py +78 -0
  509. package/lldb/lib/python3.12/site-packages/pip/_internal/models/index.py +28 -0
  510. package/lldb/lib/python3.12/site-packages/pip/_internal/models/installation_report.py +56 -0
  511. package/lldb/lib/python3.12/site-packages/pip/_internal/models/link.py +590 -0
  512. package/lldb/lib/python3.12/site-packages/pip/_internal/models/scheme.py +25 -0
  513. package/lldb/lib/python3.12/site-packages/pip/_internal/models/search_scope.py +127 -0
  514. package/lldb/lib/python3.12/site-packages/pip/_internal/models/selection_prefs.py +53 -0
  515. package/lldb/lib/python3.12/site-packages/pip/_internal/models/target_python.py +121 -0
  516. package/lldb/lib/python3.12/site-packages/pip/_internal/models/wheel.py +93 -0
  517. package/lldb/lib/python3.12/site-packages/pip/_internal/network/__init__.py +2 -0
  518. package/lldb/lib/python3.12/site-packages/pip/_internal/network/auth.py +562 -0
  519. package/lldb/lib/python3.12/site-packages/pip/_internal/network/cache.py +106 -0
  520. package/lldb/lib/python3.12/site-packages/pip/_internal/network/download.py +187 -0
  521. package/lldb/lib/python3.12/site-packages/pip/_internal/network/lazy_wheel.py +210 -0
  522. package/lldb/lib/python3.12/site-packages/pip/_internal/network/session.py +522 -0
  523. package/lldb/lib/python3.12/site-packages/pip/_internal/network/utils.py +96 -0
  524. package/lldb/lib/python3.12/site-packages/pip/_internal/network/xmlrpc.py +62 -0
  525. package/lldb/lib/python3.12/site-packages/pip/_internal/operations/__init__.py +0 -0
  526. package/lldb/lib/python3.12/site-packages/pip/_internal/operations/build/__init__.py +0 -0
  527. package/lldb/lib/python3.12/site-packages/pip/_internal/operations/build/build_tracker.py +138 -0
  528. package/lldb/lib/python3.12/site-packages/pip/_internal/operations/build/metadata.py +39 -0
  529. package/lldb/lib/python3.12/site-packages/pip/_internal/operations/build/metadata_editable.py +41 -0
  530. package/lldb/lib/python3.12/site-packages/pip/_internal/operations/build/metadata_legacy.py +74 -0
  531. package/lldb/lib/python3.12/site-packages/pip/_internal/operations/build/wheel.py +37 -0
  532. package/lldb/lib/python3.12/site-packages/pip/_internal/operations/build/wheel_editable.py +46 -0
  533. package/lldb/lib/python3.12/site-packages/pip/_internal/operations/build/wheel_legacy.py +102 -0
  534. package/lldb/lib/python3.12/site-packages/pip/_internal/operations/check.py +149 -0
  535. package/lldb/lib/python3.12/site-packages/pip/_internal/operations/freeze.py +258 -0
  536. package/lldb/lib/python3.12/site-packages/pip/_internal/operations/install/__init__.py +2 -0
  537. package/lldb/lib/python3.12/site-packages/pip/_internal/operations/install/editable_legacy.py +47 -0
  538. package/lldb/lib/python3.12/site-packages/pip/_internal/operations/install/wheel.py +735 -0
  539. package/lldb/lib/python3.12/site-packages/pip/_internal/operations/prepare.py +732 -0
  540. package/lldb/lib/python3.12/site-packages/pip/_internal/pyproject.py +179 -0
  541. package/lldb/lib/python3.12/site-packages/pip/_internal/req/__init__.py +90 -0
  542. package/lldb/lib/python3.12/site-packages/pip/_internal/req/constructors.py +560 -0
  543. package/lldb/lib/python3.12/site-packages/pip/_internal/req/req_file.py +551 -0
  544. package/lldb/lib/python3.12/site-packages/pip/_internal/req/req_install.py +918 -0
  545. package/lldb/lib/python3.12/site-packages/pip/_internal/req/req_set.py +82 -0
  546. package/lldb/lib/python3.12/site-packages/pip/_internal/req/req_uninstall.py +633 -0
  547. package/lldb/lib/python3.12/site-packages/pip/_internal/resolution/__init__.py +0 -0
  548. package/lldb/lib/python3.12/site-packages/pip/_internal/resolution/base.py +20 -0
  549. package/lldb/lib/python3.12/site-packages/pip/_internal/resolution/legacy/__init__.py +0 -0
  550. package/lldb/lib/python3.12/site-packages/pip/_internal/resolution/legacy/resolver.py +597 -0
  551. package/lldb/lib/python3.12/site-packages/pip/_internal/resolution/resolvelib/__init__.py +0 -0
  552. package/lldb/lib/python3.12/site-packages/pip/_internal/resolution/resolvelib/base.py +139 -0
  553. package/lldb/lib/python3.12/site-packages/pip/_internal/resolution/resolvelib/candidates.py +569 -0
  554. package/lldb/lib/python3.12/site-packages/pip/_internal/resolution/resolvelib/factory.py +816 -0
  555. package/lldb/lib/python3.12/site-packages/pip/_internal/resolution/resolvelib/found_candidates.py +174 -0
  556. package/lldb/lib/python3.12/site-packages/pip/_internal/resolution/resolvelib/provider.py +258 -0
  557. package/lldb/lib/python3.12/site-packages/pip/_internal/resolution/resolvelib/reporter.py +80 -0
  558. package/lldb/lib/python3.12/site-packages/pip/_internal/resolution/resolvelib/requirements.py +245 -0
  559. package/lldb/lib/python3.12/site-packages/pip/_internal/resolution/resolvelib/resolver.py +317 -0
  560. package/lldb/lib/python3.12/site-packages/pip/_internal/self_outdated_check.py +248 -0
  561. package/lldb/lib/python3.12/site-packages/pip/_internal/utils/__init__.py +0 -0
  562. package/lldb/lib/python3.12/site-packages/pip/_internal/utils/_jaraco_text.py +109 -0
  563. package/lldb/lib/python3.12/site-packages/pip/_internal/utils/_log.py +38 -0
  564. package/lldb/lib/python3.12/site-packages/pip/_internal/utils/appdirs.py +52 -0
  565. package/lldb/lib/python3.12/site-packages/pip/_internal/utils/compat.py +79 -0
  566. package/lldb/lib/python3.12/site-packages/pip/_internal/utils/compatibility_tags.py +165 -0
  567. package/lldb/lib/python3.12/site-packages/pip/_internal/utils/datetime.py +11 -0
  568. package/lldb/lib/python3.12/site-packages/pip/_internal/utils/deprecation.py +124 -0
  569. package/lldb/lib/python3.12/site-packages/pip/_internal/utils/direct_url_helpers.py +87 -0
  570. package/lldb/lib/python3.12/site-packages/pip/_internal/utils/egg_link.py +80 -0
  571. package/lldb/lib/python3.12/site-packages/pip/_internal/utils/encoding.py +36 -0
  572. package/lldb/lib/python3.12/site-packages/pip/_internal/utils/entrypoints.py +84 -0
  573. package/lldb/lib/python3.12/site-packages/pip/_internal/utils/filesystem.py +153 -0
  574. package/lldb/lib/python3.12/site-packages/pip/_internal/utils/filetypes.py +27 -0
  575. package/lldb/lib/python3.12/site-packages/pip/_internal/utils/glibc.py +91 -0
  576. package/lldb/lib/python3.12/site-packages/pip/_internal/utils/hashes.py +147 -0
  577. package/lldb/lib/python3.12/site-packages/pip/_internal/utils/logging.py +347 -0
  578. package/lldb/lib/python3.12/site-packages/pip/_internal/utils/misc.py +780 -0
  579. package/lldb/lib/python3.12/site-packages/pip/_internal/utils/packaging.py +57 -0
  580. package/lldb/lib/python3.12/site-packages/pip/_internal/utils/setuptools_build.py +146 -0
  581. package/lldb/lib/python3.12/site-packages/pip/_internal/utils/subprocess.py +245 -0
  582. package/lldb/lib/python3.12/site-packages/pip/_internal/utils/temp_dir.py +296 -0
  583. package/lldb/lib/python3.12/site-packages/pip/_internal/utils/unpacking.py +337 -0
  584. package/lldb/lib/python3.12/site-packages/pip/_internal/utils/urls.py +55 -0
  585. package/lldb/lib/python3.12/site-packages/pip/_internal/utils/virtualenv.py +104 -0
  586. package/lldb/lib/python3.12/site-packages/pip/_internal/utils/wheel.py +134 -0
  587. package/lldb/lib/python3.12/site-packages/pip/_internal/vcs/__init__.py +15 -0
  588. package/lldb/lib/python3.12/site-packages/pip/_internal/vcs/bazaar.py +112 -0
  589. package/lldb/lib/python3.12/site-packages/pip/_internal/vcs/git.py +527 -0
  590. package/lldb/lib/python3.12/site-packages/pip/_internal/vcs/mercurial.py +163 -0
  591. package/lldb/lib/python3.12/site-packages/pip/_internal/vcs/subversion.py +324 -0
  592. package/lldb/lib/python3.12/site-packages/pip/_internal/vcs/versioncontrol.py +688 -0
  593. package/lldb/lib/python3.12/site-packages/pip/_internal/wheel_builder.py +354 -0
  594. package/lldb/lib/python3.12/site-packages/pip/_vendor/__init__.py +116 -0
  595. package/lldb/lib/python3.12/site-packages/pip/_vendor/cachecontrol/__init__.py +28 -0
  596. package/lldb/lib/python3.12/site-packages/pip/_vendor/cachecontrol/_cmd.py +70 -0
  597. package/lldb/lib/python3.12/site-packages/pip/_vendor/cachecontrol/adapter.py +161 -0
  598. package/lldb/lib/python3.12/site-packages/pip/_vendor/cachecontrol/cache.py +74 -0
  599. package/lldb/lib/python3.12/site-packages/pip/_vendor/cachecontrol/caches/__init__.py +8 -0
  600. package/lldb/lib/python3.12/site-packages/pip/_vendor/cachecontrol/caches/file_cache.py +182 -0
  601. package/lldb/lib/python3.12/site-packages/pip/_vendor/cachecontrol/caches/redis_cache.py +48 -0
  602. package/lldb/lib/python3.12/site-packages/pip/_vendor/cachecontrol/controller.py +499 -0
  603. package/lldb/lib/python3.12/site-packages/pip/_vendor/cachecontrol/filewrapper.py +119 -0
  604. package/lldb/lib/python3.12/site-packages/pip/_vendor/cachecontrol/heuristics.py +154 -0
  605. package/lldb/lib/python3.12/site-packages/pip/_vendor/cachecontrol/serialize.py +146 -0
  606. package/lldb/lib/python3.12/site-packages/pip/_vendor/cachecontrol/wrapper.py +43 -0
  607. package/lldb/lib/python3.12/site-packages/pip/_vendor/certifi/__init__.py +4 -0
  608. package/lldb/lib/python3.12/site-packages/pip/_vendor/certifi/__main__.py +12 -0
  609. package/lldb/lib/python3.12/site-packages/pip/_vendor/certifi/cacert.pem +4814 -0
  610. package/lldb/lib/python3.12/site-packages/pip/_vendor/certifi/core.py +114 -0
  611. package/lldb/lib/python3.12/site-packages/pip/_vendor/distlib/__init__.py +33 -0
  612. package/lldb/lib/python3.12/site-packages/pip/_vendor/distlib/compat.py +1138 -0
  613. package/lldb/lib/python3.12/site-packages/pip/_vendor/distlib/database.py +1359 -0
  614. package/lldb/lib/python3.12/site-packages/pip/_vendor/distlib/index.py +508 -0
  615. package/lldb/lib/python3.12/site-packages/pip/_vendor/distlib/locators.py +1303 -0
  616. package/lldb/lib/python3.12/site-packages/pip/_vendor/distlib/manifest.py +384 -0
  617. package/lldb/lib/python3.12/site-packages/pip/_vendor/distlib/markers.py +167 -0
  618. package/lldb/lib/python3.12/site-packages/pip/_vendor/distlib/metadata.py +1068 -0
  619. package/lldb/lib/python3.12/site-packages/pip/_vendor/distlib/resources.py +358 -0
  620. package/lldb/lib/python3.12/site-packages/pip/_vendor/distlib/scripts.py +466 -0
  621. package/lldb/lib/python3.12/site-packages/pip/_vendor/distlib/t32.exe +0 -0
  622. package/lldb/lib/python3.12/site-packages/pip/_vendor/distlib/t64-arm.exe +0 -0
  623. package/lldb/lib/python3.12/site-packages/pip/_vendor/distlib/t64.exe +0 -0
  624. package/lldb/lib/python3.12/site-packages/pip/_vendor/distlib/util.py +2025 -0
  625. package/lldb/lib/python3.12/site-packages/pip/_vendor/distlib/version.py +751 -0
  626. package/lldb/lib/python3.12/site-packages/pip/_vendor/distlib/w32.exe +0 -0
  627. package/lldb/lib/python3.12/site-packages/pip/_vendor/distlib/w64-arm.exe +0 -0
  628. package/lldb/lib/python3.12/site-packages/pip/_vendor/distlib/w64.exe +0 -0
  629. package/lldb/lib/python3.12/site-packages/pip/_vendor/distlib/wheel.py +1099 -0
  630. package/lldb/lib/python3.12/site-packages/pip/_vendor/distro/__init__.py +54 -0
  631. package/lldb/lib/python3.12/site-packages/pip/_vendor/distro/__main__.py +4 -0
  632. package/lldb/lib/python3.12/site-packages/pip/_vendor/distro/distro.py +1403 -0
  633. package/lldb/lib/python3.12/site-packages/pip/_vendor/idna/__init__.py +44 -0
  634. package/lldb/lib/python3.12/site-packages/pip/_vendor/idna/codec.py +118 -0
  635. package/lldb/lib/python3.12/site-packages/pip/_vendor/idna/compat.py +13 -0
  636. package/lldb/lib/python3.12/site-packages/pip/_vendor/idna/core.py +395 -0
  637. package/lldb/lib/python3.12/site-packages/pip/_vendor/idna/idnadata.py +4245 -0
  638. package/lldb/lib/python3.12/site-packages/pip/_vendor/idna/intranges.py +54 -0
  639. package/lldb/lib/python3.12/site-packages/pip/_vendor/idna/package_data.py +2 -0
  640. package/lldb/lib/python3.12/site-packages/pip/_vendor/idna/uts46data.py +8598 -0
  641. package/lldb/lib/python3.12/site-packages/pip/_vendor/msgpack/__init__.py +55 -0
  642. package/lldb/lib/python3.12/site-packages/pip/_vendor/msgpack/exceptions.py +48 -0
  643. package/lldb/lib/python3.12/site-packages/pip/_vendor/msgpack/ext.py +168 -0
  644. package/lldb/lib/python3.12/site-packages/pip/_vendor/msgpack/fallback.py +951 -0
  645. package/lldb/lib/python3.12/site-packages/pip/_vendor/packaging/__init__.py +15 -0
  646. package/lldb/lib/python3.12/site-packages/pip/_vendor/packaging/_elffile.py +110 -0
  647. package/lldb/lib/python3.12/site-packages/pip/_vendor/packaging/_manylinux.py +262 -0
  648. package/lldb/lib/python3.12/site-packages/pip/_vendor/packaging/_musllinux.py +85 -0
  649. package/lldb/lib/python3.12/site-packages/pip/_vendor/packaging/_parser.py +354 -0
  650. package/lldb/lib/python3.12/site-packages/pip/_vendor/packaging/_structures.py +61 -0
  651. package/lldb/lib/python3.12/site-packages/pip/_vendor/packaging/_tokenizer.py +194 -0
  652. package/lldb/lib/python3.12/site-packages/pip/_vendor/packaging/markers.py +325 -0
  653. package/lldb/lib/python3.12/site-packages/pip/_vendor/packaging/metadata.py +804 -0
  654. package/lldb/lib/python3.12/site-packages/pip/_vendor/packaging/requirements.py +91 -0
  655. package/lldb/lib/python3.12/site-packages/pip/_vendor/packaging/specifiers.py +1009 -0
  656. package/lldb/lib/python3.12/site-packages/pip/_vendor/packaging/tags.py +568 -0
  657. package/lldb/lib/python3.12/site-packages/pip/_vendor/packaging/utils.py +174 -0
  658. package/lldb/lib/python3.12/site-packages/pip/_vendor/packaging/version.py +563 -0
  659. package/lldb/lib/python3.12/site-packages/pip/_vendor/pkg_resources/__init__.py +3325 -0
  660. package/lldb/lib/python3.12/site-packages/pip/_vendor/platformdirs/__init__.py +627 -0
  661. package/lldb/lib/python3.12/site-packages/pip/_vendor/platformdirs/__main__.py +55 -0
  662. package/lldb/lib/python3.12/site-packages/pip/_vendor/platformdirs/android.py +222 -0
  663. package/lldb/lib/python3.12/site-packages/pip/_vendor/platformdirs/api.py +292 -0
  664. package/lldb/lib/python3.12/site-packages/pip/_vendor/platformdirs/macos.py +130 -0
  665. package/lldb/lib/python3.12/site-packages/pip/_vendor/platformdirs/unix.py +275 -0
  666. package/lldb/lib/python3.12/site-packages/pip/_vendor/platformdirs/version.py +16 -0
  667. package/lldb/lib/python3.12/site-packages/pip/_vendor/platformdirs/windows.py +272 -0
  668. package/lldb/lib/python3.12/site-packages/pip/_vendor/pygments/__init__.py +82 -0
  669. package/lldb/lib/python3.12/site-packages/pip/_vendor/pygments/__main__.py +17 -0
  670. package/lldb/lib/python3.12/site-packages/pip/_vendor/pygments/cmdline.py +668 -0
  671. package/lldb/lib/python3.12/site-packages/pip/_vendor/pygments/console.py +70 -0
  672. package/lldb/lib/python3.12/site-packages/pip/_vendor/pygments/filter.py +71 -0
  673. package/lldb/lib/python3.12/site-packages/pip/_vendor/pygments/filters/__init__.py +940 -0
  674. package/lldb/lib/python3.12/site-packages/pip/_vendor/pygments/formatter.py +124 -0
  675. package/lldb/lib/python3.12/site-packages/pip/_vendor/pygments/formatters/__init__.py +158 -0
  676. package/lldb/lib/python3.12/site-packages/pip/_vendor/pygments/formatters/_mapping.py +23 -0
  677. package/lldb/lib/python3.12/site-packages/pip/_vendor/pygments/formatters/bbcode.py +108 -0
  678. package/lldb/lib/python3.12/site-packages/pip/_vendor/pygments/formatters/groff.py +170 -0
  679. package/lldb/lib/python3.12/site-packages/pip/_vendor/pygments/formatters/html.py +990 -0
  680. package/lldb/lib/python3.12/site-packages/pip/_vendor/pygments/formatters/img.py +684 -0
  681. package/lldb/lib/python3.12/site-packages/pip/_vendor/pygments/formatters/irc.py +154 -0
  682. package/lldb/lib/python3.12/site-packages/pip/_vendor/pygments/formatters/latex.py +521 -0
  683. package/lldb/lib/python3.12/site-packages/pip/_vendor/pygments/formatters/other.py +161 -0
  684. package/lldb/lib/python3.12/site-packages/pip/_vendor/pygments/formatters/pangomarkup.py +83 -0
  685. package/lldb/lib/python3.12/site-packages/pip/_vendor/pygments/formatters/rtf.py +146 -0
  686. package/lldb/lib/python3.12/site-packages/pip/_vendor/pygments/formatters/svg.py +188 -0
  687. package/lldb/lib/python3.12/site-packages/pip/_vendor/pygments/formatters/terminal.py +127 -0
  688. package/lldb/lib/python3.12/site-packages/pip/_vendor/pygments/formatters/terminal256.py +338 -0
  689. package/lldb/lib/python3.12/site-packages/pip/_vendor/pygments/lexer.py +961 -0
  690. package/lldb/lib/python3.12/site-packages/pip/_vendor/pygments/lexers/__init__.py +363 -0
  691. package/lldb/lib/python3.12/site-packages/pip/_vendor/pygments/lexers/_mapping.py +580 -0
  692. package/lldb/lib/python3.12/site-packages/pip/_vendor/pygments/lexers/python.py +1198 -0
  693. package/lldb/lib/python3.12/site-packages/pip/_vendor/pygments/modeline.py +43 -0
  694. package/lldb/lib/python3.12/site-packages/pip/_vendor/pygments/plugin.py +88 -0
  695. package/lldb/lib/python3.12/site-packages/pip/_vendor/pygments/regexopt.py +91 -0
  696. package/lldb/lib/python3.12/site-packages/pip/_vendor/pygments/scanner.py +104 -0
  697. package/lldb/lib/python3.12/site-packages/pip/_vendor/pygments/sphinxext.py +239 -0
  698. package/lldb/lib/python3.12/site-packages/pip/_vendor/pygments/style.py +203 -0
  699. package/lldb/lib/python3.12/site-packages/pip/_vendor/pygments/styles/__init__.py +61 -0
  700. package/lldb/lib/python3.12/site-packages/pip/_vendor/pygments/styles/_mapping.py +53 -0
  701. package/lldb/lib/python3.12/site-packages/pip/_vendor/pygments/token.py +214 -0
  702. package/lldb/lib/python3.12/site-packages/pip/_vendor/pygments/unistring.py +153 -0
  703. package/lldb/lib/python3.12/site-packages/pip/_vendor/pygments/util.py +330 -0
  704. package/lldb/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/__init__.py +23 -0
  705. package/lldb/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_compat.py +8 -0
  706. package/lldb/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_impl.py +330 -0
  707. package/lldb/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/__init__.py +18 -0
  708. package/lldb/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py +353 -0
  709. package/lldb/lib/python3.12/site-packages/pip/_vendor/requests/__init__.py +179 -0
  710. package/lldb/lib/python3.12/site-packages/pip/_vendor/requests/__version__.py +14 -0
  711. package/lldb/lib/python3.12/site-packages/pip/_vendor/requests/_internal_utils.py +50 -0
  712. package/lldb/lib/python3.12/site-packages/pip/_vendor/requests/adapters.py +719 -0
  713. package/lldb/lib/python3.12/site-packages/pip/_vendor/requests/api.py +157 -0
  714. package/lldb/lib/python3.12/site-packages/pip/_vendor/requests/auth.py +314 -0
  715. package/lldb/lib/python3.12/site-packages/pip/_vendor/requests/certs.py +24 -0
  716. package/lldb/lib/python3.12/site-packages/pip/_vendor/requests/compat.py +78 -0
  717. package/lldb/lib/python3.12/site-packages/pip/_vendor/requests/cookies.py +561 -0
  718. package/lldb/lib/python3.12/site-packages/pip/_vendor/requests/exceptions.py +151 -0
  719. package/lldb/lib/python3.12/site-packages/pip/_vendor/requests/help.py +127 -0
  720. package/lldb/lib/python3.12/site-packages/pip/_vendor/requests/hooks.py +33 -0
  721. package/lldb/lib/python3.12/site-packages/pip/_vendor/requests/models.py +1037 -0
  722. package/lldb/lib/python3.12/site-packages/pip/_vendor/requests/packages.py +25 -0
  723. package/lldb/lib/python3.12/site-packages/pip/_vendor/requests/sessions.py +831 -0
  724. package/lldb/lib/python3.12/site-packages/pip/_vendor/requests/status_codes.py +128 -0
  725. package/lldb/lib/python3.12/site-packages/pip/_vendor/requests/structures.py +99 -0
  726. package/lldb/lib/python3.12/site-packages/pip/_vendor/requests/utils.py +1096 -0
  727. package/lldb/lib/python3.12/site-packages/pip/_vendor/resolvelib/__init__.py +26 -0
  728. package/lldb/lib/python3.12/site-packages/pip/_vendor/resolvelib/compat/__init__.py +0 -0
  729. package/lldb/lib/python3.12/site-packages/pip/_vendor/resolvelib/compat/collections_abc.py +6 -0
  730. package/lldb/lib/python3.12/site-packages/pip/_vendor/resolvelib/providers.py +133 -0
  731. package/lldb/lib/python3.12/site-packages/pip/_vendor/resolvelib/reporters.py +43 -0
  732. package/lldb/lib/python3.12/site-packages/pip/_vendor/resolvelib/resolvers.py +547 -0
  733. package/lldb/lib/python3.12/site-packages/pip/_vendor/resolvelib/structs.py +170 -0
  734. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/__init__.py +177 -0
  735. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/__main__.py +273 -0
  736. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/_cell_widths.py +454 -0
  737. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/_emoji_codes.py +3610 -0
  738. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/_emoji_replace.py +32 -0
  739. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/_export_format.py +76 -0
  740. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/_extension.py +10 -0
  741. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/_fileno.py +24 -0
  742. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/_inspect.py +270 -0
  743. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/_log_render.py +94 -0
  744. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/_loop.py +43 -0
  745. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/_null_file.py +69 -0
  746. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/_palettes.py +309 -0
  747. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/_pick.py +17 -0
  748. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/_ratio.py +159 -0
  749. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/_spinners.py +482 -0
  750. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/_stack.py +16 -0
  751. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/_timer.py +19 -0
  752. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/_win32_console.py +662 -0
  753. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/_windows.py +71 -0
  754. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/_windows_renderer.py +56 -0
  755. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/_wrap.py +93 -0
  756. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/abc.py +33 -0
  757. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/align.py +311 -0
  758. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/ansi.py +240 -0
  759. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/bar.py +93 -0
  760. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/box.py +480 -0
  761. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/cells.py +167 -0
  762. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/color.py +621 -0
  763. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/color_triplet.py +38 -0
  764. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/columns.py +187 -0
  765. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/console.py +2633 -0
  766. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/constrain.py +37 -0
  767. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/containers.py +167 -0
  768. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/control.py +225 -0
  769. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/default_styles.py +190 -0
  770. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/diagnose.py +37 -0
  771. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/emoji.py +96 -0
  772. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/errors.py +34 -0
  773. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/file_proxy.py +57 -0
  774. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/filesize.py +89 -0
  775. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/highlighter.py +232 -0
  776. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/json.py +139 -0
  777. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/jupyter.py +101 -0
  778. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/layout.py +442 -0
  779. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/live.py +375 -0
  780. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/live_render.py +112 -0
  781. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/logging.py +289 -0
  782. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/markup.py +251 -0
  783. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/measure.py +151 -0
  784. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/padding.py +141 -0
  785. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/pager.py +34 -0
  786. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/palette.py +100 -0
  787. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/panel.py +312 -0
  788. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/pretty.py +995 -0
  789. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/progress.py +1699 -0
  790. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/progress_bar.py +223 -0
  791. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/prompt.py +375 -0
  792. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/protocol.py +42 -0
  793. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/region.py +10 -0
  794. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/repr.py +149 -0
  795. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/rule.py +130 -0
  796. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/scope.py +86 -0
  797. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/screen.py +54 -0
  798. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/segment.py +738 -0
  799. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/spinner.py +137 -0
  800. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/status.py +131 -0
  801. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/style.py +796 -0
  802. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/styled.py +42 -0
  803. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/syntax.py +958 -0
  804. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/table.py +1000 -0
  805. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/terminal_theme.py +153 -0
  806. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/text.py +1357 -0
  807. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/theme.py +115 -0
  808. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/themes.py +5 -0
  809. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/traceback.py +753 -0
  810. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/tree.py +249 -0
  811. package/lldb/lib/python3.12/site-packages/pip/_vendor/tenacity/__init__.py +608 -0
  812. package/lldb/lib/python3.12/site-packages/pip/_vendor/tenacity/_asyncio.py +94 -0
  813. package/lldb/lib/python3.12/site-packages/pip/_vendor/tenacity/_utils.py +76 -0
  814. package/lldb/lib/python3.12/site-packages/pip/_vendor/tenacity/after.py +51 -0
  815. package/lldb/lib/python3.12/site-packages/pip/_vendor/tenacity/before.py +46 -0
  816. package/lldb/lib/python3.12/site-packages/pip/_vendor/tenacity/before_sleep.py +71 -0
  817. package/lldb/lib/python3.12/site-packages/pip/_vendor/tenacity/nap.py +43 -0
  818. package/lldb/lib/python3.12/site-packages/pip/_vendor/tenacity/retry.py +272 -0
  819. package/lldb/lib/python3.12/site-packages/pip/_vendor/tenacity/stop.py +103 -0
  820. package/lldb/lib/python3.12/site-packages/pip/_vendor/tenacity/tornadoweb.py +59 -0
  821. package/lldb/lib/python3.12/site-packages/pip/_vendor/tenacity/wait.py +228 -0
  822. package/lldb/lib/python3.12/site-packages/pip/_vendor/tomli/__init__.py +11 -0
  823. package/lldb/lib/python3.12/site-packages/pip/_vendor/tomli/_parser.py +691 -0
  824. package/lldb/lib/python3.12/site-packages/pip/_vendor/tomli/_re.py +107 -0
  825. package/lldb/lib/python3.12/site-packages/pip/_vendor/tomli/_types.py +10 -0
  826. package/lldb/lib/python3.12/site-packages/pip/_vendor/truststore/__init__.py +13 -0
  827. package/lldb/lib/python3.12/site-packages/pip/_vendor/truststore/_api.py +313 -0
  828. package/lldb/lib/python3.12/site-packages/pip/_vendor/truststore/_macos.py +499 -0
  829. package/lldb/lib/python3.12/site-packages/pip/_vendor/truststore/_openssl.py +66 -0
  830. package/lldb/lib/python3.12/site-packages/pip/_vendor/truststore/_ssl_constants.py +31 -0
  831. package/lldb/lib/python3.12/site-packages/pip/_vendor/truststore/_windows.py +564 -0
  832. package/lldb/lib/python3.12/site-packages/pip/_vendor/typing_extensions.py +3332 -0
  833. package/lldb/lib/python3.12/site-packages/pip/_vendor/urllib3/__init__.py +102 -0
  834. package/lldb/lib/python3.12/site-packages/pip/_vendor/urllib3/_collections.py +355 -0
  835. package/lldb/lib/python3.12/site-packages/pip/_vendor/urllib3/_version.py +2 -0
  836. package/lldb/lib/python3.12/site-packages/pip/_vendor/urllib3/connection.py +572 -0
  837. package/lldb/lib/python3.12/site-packages/pip/_vendor/urllib3/connectionpool.py +1137 -0
  838. package/lldb/lib/python3.12/site-packages/pip/_vendor/urllib3/contrib/__init__.py +0 -0
  839. package/lldb/lib/python3.12/site-packages/pip/_vendor/urllib3/contrib/_appengine_environ.py +36 -0
  840. package/lldb/lib/python3.12/site-packages/pip/_vendor/urllib3/contrib/_securetransport/__init__.py +0 -0
  841. package/lldb/lib/python3.12/site-packages/pip/_vendor/urllib3/contrib/_securetransport/bindings.py +519 -0
  842. package/lldb/lib/python3.12/site-packages/pip/_vendor/urllib3/contrib/_securetransport/low_level.py +397 -0
  843. package/lldb/lib/python3.12/site-packages/pip/_vendor/urllib3/contrib/appengine.py +314 -0
  844. package/lldb/lib/python3.12/site-packages/pip/_vendor/urllib3/contrib/ntlmpool.py +130 -0
  845. package/lldb/lib/python3.12/site-packages/pip/_vendor/urllib3/contrib/pyopenssl.py +518 -0
  846. package/lldb/lib/python3.12/site-packages/pip/_vendor/urllib3/contrib/securetransport.py +920 -0
  847. package/lldb/lib/python3.12/site-packages/pip/_vendor/urllib3/contrib/socks.py +216 -0
  848. package/lldb/lib/python3.12/site-packages/pip/_vendor/urllib3/exceptions.py +323 -0
  849. package/lldb/lib/python3.12/site-packages/pip/_vendor/urllib3/fields.py +274 -0
  850. package/lldb/lib/python3.12/site-packages/pip/_vendor/urllib3/filepost.py +98 -0
  851. package/lldb/lib/python3.12/site-packages/pip/_vendor/urllib3/packages/__init__.py +0 -0
  852. package/lldb/lib/python3.12/site-packages/pip/_vendor/urllib3/packages/backports/__init__.py +0 -0
  853. package/lldb/lib/python3.12/site-packages/pip/_vendor/urllib3/packages/backports/makefile.py +51 -0
  854. package/lldb/lib/python3.12/site-packages/pip/_vendor/urllib3/packages/backports/weakref_finalize.py +155 -0
  855. package/lldb/lib/python3.12/site-packages/pip/_vendor/urllib3/packages/six.py +1076 -0
  856. package/lldb/lib/python3.12/site-packages/pip/_vendor/urllib3/poolmanager.py +540 -0
  857. package/lldb/lib/python3.12/site-packages/pip/_vendor/urllib3/request.py +191 -0
  858. package/lldb/lib/python3.12/site-packages/pip/_vendor/urllib3/response.py +879 -0
  859. package/lldb/lib/python3.12/site-packages/pip/_vendor/urllib3/util/__init__.py +49 -0
  860. package/lldb/lib/python3.12/site-packages/pip/_vendor/urllib3/util/connection.py +149 -0
  861. package/lldb/lib/python3.12/site-packages/pip/_vendor/urllib3/util/proxy.py +57 -0
  862. package/lldb/lib/python3.12/site-packages/pip/_vendor/urllib3/util/queue.py +22 -0
  863. package/lldb/lib/python3.12/site-packages/pip/_vendor/urllib3/util/request.py +137 -0
  864. package/lldb/lib/python3.12/site-packages/pip/_vendor/urllib3/util/response.py +107 -0
  865. package/lldb/lib/python3.12/site-packages/pip/_vendor/urllib3/util/retry.py +620 -0
  866. package/lldb/lib/python3.12/site-packages/pip/_vendor/urllib3/util/ssl_.py +495 -0
  867. package/lldb/lib/python3.12/site-packages/pip/_vendor/urllib3/util/ssl_match_hostname.py +159 -0
  868. package/lldb/lib/python3.12/site-packages/pip/_vendor/urllib3/util/ssltransport.py +221 -0
  869. package/lldb/lib/python3.12/site-packages/pip/_vendor/urllib3/util/timeout.py +271 -0
  870. package/lldb/lib/python3.12/site-packages/pip/_vendor/urllib3/util/url.py +435 -0
  871. package/lldb/lib/python3.12/site-packages/pip/_vendor/urllib3/util/wait.py +152 -0
  872. package/lldb/lib/python3.12/site.py +692 -0
  873. package/lldb/lib/python3.12/smtplib.py +1109 -0
  874. package/lldb/lib/python3.12/sndhdr.py +271 -0
  875. package/lldb/lib/python3.12/socket.py +981 -0
  876. package/lldb/lib/python3.12/socketserver.py +858 -0
  877. package/lldb/lib/python3.12/sre_compile.py +7 -0
  878. package/lldb/lib/python3.12/sre_constants.py +7 -0
  879. package/lldb/lib/python3.12/sre_parse.py +7 -0
  880. package/lldb/lib/python3.12/ssl.py +1476 -0
  881. package/lldb/lib/python3.12/stat.py +195 -0
  882. package/lldb/lib/python3.12/statistics.py +1454 -0
  883. package/lldb/lib/python3.12/string.py +309 -0
  884. package/lldb/lib/python3.12/stringprep.py +272 -0
  885. package/lldb/lib/python3.12/struct.py +15 -0
  886. package/lldb/lib/python3.12/subprocess.py +2216 -0
  887. package/lldb/lib/python3.12/sunau.py +533 -0
  888. package/lldb/lib/python3.12/symtable.py +362 -0
  889. package/lldb/lib/python3.12/sysconfig.py +876 -0
  890. package/lldb/lib/python3.12/tabnanny.py +340 -0
  891. package/lldb/lib/python3.12/tarfile.py +2933 -0
  892. package/lldb/lib/python3.12/telnetlib.py +680 -0
  893. package/lldb/lib/python3.12/tempfile.py +952 -0
  894. package/lldb/lib/python3.12/textwrap.py +491 -0
  895. package/lldb/lib/python3.12/this.py +28 -0
  896. package/lldb/lib/python3.12/threading.py +1708 -0
  897. package/lldb/lib/python3.12/timeit.py +381 -0
  898. package/lldb/lib/python3.12/token.py +142 -0
  899. package/lldb/lib/python3.12/tokenize.py +586 -0
  900. package/lldb/lib/python3.12/tomllib/__init__.py +10 -0
  901. package/lldb/lib/python3.12/tomllib/_parser.py +691 -0
  902. package/lldb/lib/python3.12/tomllib/_re.py +107 -0
  903. package/lldb/lib/python3.12/tomllib/_types.py +10 -0
  904. package/lldb/lib/python3.12/trace.py +748 -0
  905. package/lldb/lib/python3.12/traceback.py +1187 -0
  906. package/lldb/lib/python3.12/tracemalloc.py +560 -0
  907. package/lldb/lib/python3.12/tty.py +73 -0
  908. package/lldb/lib/python3.12/turtle.py +4207 -0
  909. package/lldb/lib/python3.12/types.py +333 -0
  910. package/lldb/lib/python3.12/typing.py +3489 -0
  911. package/lldb/lib/python3.12/unittest/__init__.py +85 -0
  912. package/lldb/lib/python3.12/unittest/__main__.py +18 -0
  913. package/lldb/lib/python3.12/unittest/_log.py +86 -0
  914. package/lldb/lib/python3.12/unittest/async_case.py +142 -0
  915. package/lldb/lib/python3.12/unittest/case.py +1456 -0
  916. package/lldb/lib/python3.12/unittest/loader.py +497 -0
  917. package/lldb/lib/python3.12/unittest/main.py +291 -0
  918. package/lldb/lib/python3.12/unittest/mock.py +3045 -0
  919. package/lldb/lib/python3.12/unittest/result.py +256 -0
  920. package/lldb/lib/python3.12/unittest/runner.py +292 -0
  921. package/lldb/lib/python3.12/unittest/signals.py +71 -0
  922. package/lldb/lib/python3.12/unittest/suite.py +379 -0
  923. package/lldb/lib/python3.12/unittest/util.py +170 -0
  924. package/lldb/lib/python3.12/urllib/__init__.py +0 -0
  925. package/lldb/lib/python3.12/urllib/error.py +74 -0
  926. package/lldb/lib/python3.12/urllib/parse.py +1246 -0
  927. package/lldb/lib/python3.12/urllib/request.py +2796 -0
  928. package/lldb/lib/python3.12/urllib/response.py +84 -0
  929. package/lldb/lib/python3.12/urllib/robotparser.py +273 -0
  930. package/lldb/lib/python3.12/uu.py +216 -0
  931. package/lldb/lib/python3.12/uuid.py +793 -0
  932. package/lldb/lib/python3.12/warnings.py +598 -0
  933. package/lldb/lib/python3.12/wave.py +653 -0
  934. package/lldb/lib/python3.12/weakref.py +674 -0
  935. package/lldb/lib/python3.12/webbrowser.py +689 -0
  936. package/lldb/lib/python3.12/wsgiref/__init__.py +25 -0
  937. package/lldb/lib/python3.12/wsgiref/handlers.py +573 -0
  938. package/lldb/lib/python3.12/wsgiref/headers.py +184 -0
  939. package/lldb/lib/python3.12/wsgiref/simple_server.py +165 -0
  940. package/lldb/lib/python3.12/wsgiref/types.py +54 -0
  941. package/lldb/lib/python3.12/wsgiref/util.py +159 -0
  942. package/lldb/lib/python3.12/wsgiref/validate.py +438 -0
  943. package/lldb/lib/python3.12/xdrlib.py +242 -0
  944. package/lldb/lib/python3.12/xml/__init__.py +20 -0
  945. package/lldb/lib/python3.12/xml/dom/NodeFilter.py +27 -0
  946. package/lldb/lib/python3.12/xml/dom/__init__.py +140 -0
  947. package/lldb/lib/python3.12/xml/dom/domreg.py +99 -0
  948. package/lldb/lib/python3.12/xml/dom/expatbuilder.py +962 -0
  949. package/lldb/lib/python3.12/xml/dom/minicompat.py +109 -0
  950. package/lldb/lib/python3.12/xml/dom/minidom.py +2013 -0
  951. package/lldb/lib/python3.12/xml/dom/pulldom.py +336 -0
  952. package/lldb/lib/python3.12/xml/dom/xmlbuilder.py +387 -0
  953. package/lldb/lib/python3.12/xml/etree/ElementInclude.py +186 -0
  954. package/lldb/lib/python3.12/xml/etree/ElementPath.py +423 -0
  955. package/lldb/lib/python3.12/xml/etree/ElementTree.py +2085 -0
  956. package/lldb/lib/python3.12/xml/etree/__init__.py +33 -0
  957. package/lldb/lib/python3.12/xml/etree/cElementTree.py +3 -0
  958. package/lldb/lib/python3.12/xml/parsers/__init__.py +8 -0
  959. package/lldb/lib/python3.12/xml/parsers/expat.py +8 -0
  960. package/lldb/lib/python3.12/xml/sax/__init__.py +94 -0
  961. package/lldb/lib/python3.12/xml/sax/_exceptions.py +127 -0
  962. package/lldb/lib/python3.12/xml/sax/expatreader.py +454 -0
  963. package/lldb/lib/python3.12/xml/sax/handler.py +387 -0
  964. package/lldb/lib/python3.12/xml/sax/saxutils.py +369 -0
  965. package/lldb/lib/python3.12/xml/sax/xmlreader.py +378 -0
  966. package/lldb/lib/python3.12/xmlrpc/__init__.py +1 -0
  967. package/lldb/lib/python3.12/xmlrpc/client.py +1529 -0
  968. package/lldb/lib/python3.12/xmlrpc/server.py +1002 -0
  969. package/lldb/lib/python3.12/zipapp.py +206 -0
  970. package/lldb/lib/python3.12/zipfile/__init__.py +2314 -0
  971. package/lldb/lib/python3.12/zipfile/__main__.py +4 -0
  972. package/lldb/lib/python3.12/zipfile/_path/__init__.py +412 -0
  973. package/lldb/lib/python3.12/zipfile/_path/glob.py +53 -0
  974. package/lldb/lib/python3.12/zipimport.py +712 -0
  975. package/lldb/lib/python3.12/zoneinfo/__init__.py +31 -0
  976. package/lldb/lib/python3.12/zoneinfo/_common.py +164 -0
  977. package/lldb/lib/python3.12/zoneinfo/_tzpath.py +181 -0
  978. package/lldb/lib/python3.12/zoneinfo/_zoneinfo.py +772 -0
  979. package/package.json +28 -4
  980. package/version.json +4 -0
@@ -0,0 +1,2314 @@
1
+ """
2
+ Read and write ZIP files.
3
+
4
+ XXX references to utf-8 need further investigation.
5
+ """
6
+ import binascii
7
+ import importlib.util
8
+ import io
9
+ import os
10
+ import shutil
11
+ import stat
12
+ import struct
13
+ import sys
14
+ import threading
15
+ import time
16
+
17
+ try:
18
+ import zlib # We may need its compression method
19
+ crc32 = zlib.crc32
20
+ except ImportError:
21
+ zlib = None
22
+ crc32 = binascii.crc32
23
+
24
+ try:
25
+ import bz2 # We may need its compression method
26
+ except ImportError:
27
+ bz2 = None
28
+
29
+ try:
30
+ import lzma # We may need its compression method
31
+ except ImportError:
32
+ lzma = None
33
+
34
+ __all__ = ["BadZipFile", "BadZipfile", "error",
35
+ "ZIP_STORED", "ZIP_DEFLATED", "ZIP_BZIP2", "ZIP_LZMA",
36
+ "is_zipfile", "ZipInfo", "ZipFile", "PyZipFile", "LargeZipFile",
37
+ "Path"]
38
+
39
+ class BadZipFile(Exception):
40
+ pass
41
+
42
+
43
+ class LargeZipFile(Exception):
44
+ """
45
+ Raised when writing a zipfile, the zipfile requires ZIP64 extensions
46
+ and those extensions are disabled.
47
+ """
48
+
49
+ error = BadZipfile = BadZipFile # Pre-3.2 compatibility names
50
+
51
+
52
+ ZIP64_LIMIT = (1 << 31) - 1
53
+ ZIP_FILECOUNT_LIMIT = (1 << 16) - 1
54
+ ZIP_MAX_COMMENT = (1 << 16) - 1
55
+
56
+ # constants for Zip file compression methods
57
+ ZIP_STORED = 0
58
+ ZIP_DEFLATED = 8
59
+ ZIP_BZIP2 = 12
60
+ ZIP_LZMA = 14
61
+ # Other ZIP compression methods not supported
62
+
63
+ DEFAULT_VERSION = 20
64
+ ZIP64_VERSION = 45
65
+ BZIP2_VERSION = 46
66
+ LZMA_VERSION = 63
67
+ # we recognize (but not necessarily support) all features up to that version
68
+ MAX_EXTRACT_VERSION = 63
69
+
70
+ # Below are some formats and associated data for reading/writing headers using
71
+ # the struct module. The names and structures of headers/records are those used
72
+ # in the PKWARE description of the ZIP file format:
73
+ # http://www.pkware.com/documents/casestudies/APPNOTE.TXT
74
+ # (URL valid as of January 2008)
75
+
76
+ # The "end of central directory" structure, magic number, size, and indices
77
+ # (section V.I in the format document)
78
+ structEndArchive = b"<4s4H2LH"
79
+ stringEndArchive = b"PK\005\006"
80
+ sizeEndCentDir = struct.calcsize(structEndArchive)
81
+
82
+ _ECD_SIGNATURE = 0
83
+ _ECD_DISK_NUMBER = 1
84
+ _ECD_DISK_START = 2
85
+ _ECD_ENTRIES_THIS_DISK = 3
86
+ _ECD_ENTRIES_TOTAL = 4
87
+ _ECD_SIZE = 5
88
+ _ECD_OFFSET = 6
89
+ _ECD_COMMENT_SIZE = 7
90
+ # These last two indices are not part of the structure as defined in the
91
+ # spec, but they are used internally by this module as a convenience
92
+ _ECD_COMMENT = 8
93
+ _ECD_LOCATION = 9
94
+
95
+ # The "central directory" structure, magic number, size, and indices
96
+ # of entries in the structure (section V.F in the format document)
97
+ structCentralDir = "<4s4B4HL2L5H2L"
98
+ stringCentralDir = b"PK\001\002"
99
+ sizeCentralDir = struct.calcsize(structCentralDir)
100
+
101
+ # indexes of entries in the central directory structure
102
+ _CD_SIGNATURE = 0
103
+ _CD_CREATE_VERSION = 1
104
+ _CD_CREATE_SYSTEM = 2
105
+ _CD_EXTRACT_VERSION = 3
106
+ _CD_EXTRACT_SYSTEM = 4
107
+ _CD_FLAG_BITS = 5
108
+ _CD_COMPRESS_TYPE = 6
109
+ _CD_TIME = 7
110
+ _CD_DATE = 8
111
+ _CD_CRC = 9
112
+ _CD_COMPRESSED_SIZE = 10
113
+ _CD_UNCOMPRESSED_SIZE = 11
114
+ _CD_FILENAME_LENGTH = 12
115
+ _CD_EXTRA_FIELD_LENGTH = 13
116
+ _CD_COMMENT_LENGTH = 14
117
+ _CD_DISK_NUMBER_START = 15
118
+ _CD_INTERNAL_FILE_ATTRIBUTES = 16
119
+ _CD_EXTERNAL_FILE_ATTRIBUTES = 17
120
+ _CD_LOCAL_HEADER_OFFSET = 18
121
+
122
+ # General purpose bit flags
123
+ # Zip Appnote: 4.4.4 general purpose bit flag: (2 bytes)
124
+ _MASK_ENCRYPTED = 1 << 0
125
+ # Bits 1 and 2 have different meanings depending on the compression used.
126
+ _MASK_COMPRESS_OPTION_1 = 1 << 1
127
+ # _MASK_COMPRESS_OPTION_2 = 1 << 2
128
+ # _MASK_USE_DATA_DESCRIPTOR: If set, crc-32, compressed size and uncompressed
129
+ # size are zero in the local header and the real values are written in the data
130
+ # descriptor immediately following the compressed data.
131
+ _MASK_USE_DATA_DESCRIPTOR = 1 << 3
132
+ # Bit 4: Reserved for use with compression method 8, for enhanced deflating.
133
+ # _MASK_RESERVED_BIT_4 = 1 << 4
134
+ _MASK_COMPRESSED_PATCH = 1 << 5
135
+ _MASK_STRONG_ENCRYPTION = 1 << 6
136
+ # _MASK_UNUSED_BIT_7 = 1 << 7
137
+ # _MASK_UNUSED_BIT_8 = 1 << 8
138
+ # _MASK_UNUSED_BIT_9 = 1 << 9
139
+ # _MASK_UNUSED_BIT_10 = 1 << 10
140
+ _MASK_UTF_FILENAME = 1 << 11
141
+ # Bit 12: Reserved by PKWARE for enhanced compression.
142
+ # _MASK_RESERVED_BIT_12 = 1 << 12
143
+ # _MASK_ENCRYPTED_CENTRAL_DIR = 1 << 13
144
+ # Bit 14, 15: Reserved by PKWARE
145
+ # _MASK_RESERVED_BIT_14 = 1 << 14
146
+ # _MASK_RESERVED_BIT_15 = 1 << 15
147
+
148
+ # The "local file header" structure, magic number, size, and indices
149
+ # (section V.A in the format document)
150
+ structFileHeader = "<4s2B4HL2L2H"
151
+ stringFileHeader = b"PK\003\004"
152
+ sizeFileHeader = struct.calcsize(structFileHeader)
153
+
154
+ _FH_SIGNATURE = 0
155
+ _FH_EXTRACT_VERSION = 1
156
+ _FH_EXTRACT_SYSTEM = 2
157
+ _FH_GENERAL_PURPOSE_FLAG_BITS = 3
158
+ _FH_COMPRESSION_METHOD = 4
159
+ _FH_LAST_MOD_TIME = 5
160
+ _FH_LAST_MOD_DATE = 6
161
+ _FH_CRC = 7
162
+ _FH_COMPRESSED_SIZE = 8
163
+ _FH_UNCOMPRESSED_SIZE = 9
164
+ _FH_FILENAME_LENGTH = 10
165
+ _FH_EXTRA_FIELD_LENGTH = 11
166
+
167
+ # The "Zip64 end of central directory locator" structure, magic number, and size
168
+ structEndArchive64Locator = "<4sLQL"
169
+ stringEndArchive64Locator = b"PK\x06\x07"
170
+ sizeEndCentDir64Locator = struct.calcsize(structEndArchive64Locator)
171
+
172
+ # The "Zip64 end of central directory" record, magic number, size, and indices
173
+ # (section V.G in the format document)
174
+ structEndArchive64 = "<4sQ2H2L4Q"
175
+ stringEndArchive64 = b"PK\x06\x06"
176
+ sizeEndCentDir64 = struct.calcsize(structEndArchive64)
177
+
178
+ _CD64_SIGNATURE = 0
179
+ _CD64_DIRECTORY_RECSIZE = 1
180
+ _CD64_CREATE_VERSION = 2
181
+ _CD64_EXTRACT_VERSION = 3
182
+ _CD64_DISK_NUMBER = 4
183
+ _CD64_DISK_NUMBER_START = 5
184
+ _CD64_NUMBER_ENTRIES_THIS_DISK = 6
185
+ _CD64_NUMBER_ENTRIES_TOTAL = 7
186
+ _CD64_DIRECTORY_SIZE = 8
187
+ _CD64_OFFSET_START_CENTDIR = 9
188
+
189
+ _DD_SIGNATURE = 0x08074b50
190
+
191
+ _EXTRA_FIELD_STRUCT = struct.Struct('<HH')
192
+
193
+ def _strip_extra(extra, xids):
194
+ # Remove Extra Fields with specified IDs.
195
+ unpack = _EXTRA_FIELD_STRUCT.unpack
196
+ modified = False
197
+ buffer = []
198
+ start = i = 0
199
+ while i + 4 <= len(extra):
200
+ xid, xlen = unpack(extra[i : i + 4])
201
+ j = i + 4 + xlen
202
+ if xid in xids:
203
+ if i != start:
204
+ buffer.append(extra[start : i])
205
+ start = j
206
+ modified = True
207
+ i = j
208
+ if not modified:
209
+ return extra
210
+ if start != len(extra):
211
+ buffer.append(extra[start:])
212
+ return b''.join(buffer)
213
+
214
+ def _check_zipfile(fp):
215
+ try:
216
+ if _EndRecData(fp):
217
+ return True # file has correct magic number
218
+ except OSError:
219
+ pass
220
+ return False
221
+
222
+ def is_zipfile(filename):
223
+ """Quickly see if a file is a ZIP file by checking the magic number.
224
+
225
+ The filename argument may be a file or file-like object too.
226
+ """
227
+ result = False
228
+ try:
229
+ if hasattr(filename, "read"):
230
+ result = _check_zipfile(fp=filename)
231
+ else:
232
+ with open(filename, "rb") as fp:
233
+ result = _check_zipfile(fp)
234
+ except OSError:
235
+ pass
236
+ return result
237
+
238
+ def _EndRecData64(fpin, offset, endrec):
239
+ """
240
+ Read the ZIP64 end-of-archive records and use that to update endrec
241
+ """
242
+ try:
243
+ fpin.seek(offset - sizeEndCentDir64Locator, 2)
244
+ except OSError:
245
+ # If the seek fails, the file is not large enough to contain a ZIP64
246
+ # end-of-archive record, so just return the end record we were given.
247
+ return endrec
248
+
249
+ data = fpin.read(sizeEndCentDir64Locator)
250
+ if len(data) != sizeEndCentDir64Locator:
251
+ return endrec
252
+ sig, diskno, reloff, disks = struct.unpack(structEndArchive64Locator, data)
253
+ if sig != stringEndArchive64Locator:
254
+ return endrec
255
+
256
+ if diskno != 0 or disks > 1:
257
+ raise BadZipFile("zipfiles that span multiple disks are not supported")
258
+
259
+ # Assume no 'zip64 extensible data'
260
+ fpin.seek(offset - sizeEndCentDir64Locator - sizeEndCentDir64, 2)
261
+ data = fpin.read(sizeEndCentDir64)
262
+ if len(data) != sizeEndCentDir64:
263
+ return endrec
264
+ sig, sz, create_version, read_version, disk_num, disk_dir, \
265
+ dircount, dircount2, dirsize, diroffset = \
266
+ struct.unpack(structEndArchive64, data)
267
+ if sig != stringEndArchive64:
268
+ return endrec
269
+
270
+ # Update the original endrec using data from the ZIP64 record
271
+ endrec[_ECD_SIGNATURE] = sig
272
+ endrec[_ECD_DISK_NUMBER] = disk_num
273
+ endrec[_ECD_DISK_START] = disk_dir
274
+ endrec[_ECD_ENTRIES_THIS_DISK] = dircount
275
+ endrec[_ECD_ENTRIES_TOTAL] = dircount2
276
+ endrec[_ECD_SIZE] = dirsize
277
+ endrec[_ECD_OFFSET] = diroffset
278
+ return endrec
279
+
280
+
281
+ def _EndRecData(fpin):
282
+ """Return data from the "End of Central Directory" record, or None.
283
+
284
+ The data is a list of the nine items in the ZIP "End of central dir"
285
+ record followed by a tenth item, the file seek offset of this record."""
286
+
287
+ # Determine file size
288
+ fpin.seek(0, 2)
289
+ filesize = fpin.tell()
290
+
291
+ # Check to see if this is ZIP file with no archive comment (the
292
+ # "end of central directory" structure should be the last item in the
293
+ # file if this is the case).
294
+ try:
295
+ fpin.seek(-sizeEndCentDir, 2)
296
+ except OSError:
297
+ return None
298
+ data = fpin.read()
299
+ if (len(data) == sizeEndCentDir and
300
+ data[0:4] == stringEndArchive and
301
+ data[-2:] == b"\000\000"):
302
+ # the signature is correct and there's no comment, unpack structure
303
+ endrec = struct.unpack(structEndArchive, data)
304
+ endrec=list(endrec)
305
+
306
+ # Append a blank comment and record start offset
307
+ endrec.append(b"")
308
+ endrec.append(filesize - sizeEndCentDir)
309
+
310
+ # Try to read the "Zip64 end of central directory" structure
311
+ return _EndRecData64(fpin, -sizeEndCentDir, endrec)
312
+
313
+ # Either this is not a ZIP file, or it is a ZIP file with an archive
314
+ # comment. Search the end of the file for the "end of central directory"
315
+ # record signature. The comment is the last item in the ZIP file and may be
316
+ # up to 64K long. It is assumed that the "end of central directory" magic
317
+ # number does not appear in the comment.
318
+ maxCommentStart = max(filesize - (1 << 16) - sizeEndCentDir, 0)
319
+ fpin.seek(maxCommentStart, 0)
320
+ data = fpin.read()
321
+ start = data.rfind(stringEndArchive)
322
+ if start >= 0:
323
+ # found the magic number; attempt to unpack and interpret
324
+ recData = data[start:start+sizeEndCentDir]
325
+ if len(recData) != sizeEndCentDir:
326
+ # Zip file is corrupted.
327
+ return None
328
+ endrec = list(struct.unpack(structEndArchive, recData))
329
+ commentSize = endrec[_ECD_COMMENT_SIZE] #as claimed by the zip file
330
+ comment = data[start+sizeEndCentDir:start+sizeEndCentDir+commentSize]
331
+ endrec.append(comment)
332
+ endrec.append(maxCommentStart + start)
333
+
334
+ # Try to read the "Zip64 end of central directory" structure
335
+ return _EndRecData64(fpin, maxCommentStart + start - filesize,
336
+ endrec)
337
+
338
+ # Unable to find a valid end of central directory structure
339
+ return None
340
+
341
+ def _sanitize_filename(filename):
342
+ """Terminate the file name at the first null byte and
343
+ ensure paths always use forward slashes as the directory separator."""
344
+
345
+ # Terminate the file name at the first null byte. Null bytes in file
346
+ # names are used as tricks by viruses in archives.
347
+ null_byte = filename.find(chr(0))
348
+ if null_byte >= 0:
349
+ filename = filename[0:null_byte]
350
+ # This is used to ensure paths in generated ZIP files always use
351
+ # forward slashes as the directory separator, as required by the
352
+ # ZIP format specification.
353
+ if os.sep != "/" and os.sep in filename:
354
+ filename = filename.replace(os.sep, "/")
355
+ if os.altsep and os.altsep != "/" and os.altsep in filename:
356
+ filename = filename.replace(os.altsep, "/")
357
+ return filename
358
+
359
+
360
+ class ZipInfo (object):
361
+ """Class with attributes describing each file in the ZIP archive."""
362
+
363
+ __slots__ = (
364
+ 'orig_filename',
365
+ 'filename',
366
+ 'date_time',
367
+ 'compress_type',
368
+ '_compresslevel',
369
+ 'comment',
370
+ 'extra',
371
+ 'create_system',
372
+ 'create_version',
373
+ 'extract_version',
374
+ 'reserved',
375
+ 'flag_bits',
376
+ 'volume',
377
+ 'internal_attr',
378
+ 'external_attr',
379
+ 'header_offset',
380
+ 'CRC',
381
+ 'compress_size',
382
+ 'file_size',
383
+ '_raw_time',
384
+ '_end_offset',
385
+ )
386
+
387
+ def __init__(self, filename="NoName", date_time=(1980,1,1,0,0,0)):
388
+ self.orig_filename = filename # Original file name in archive
389
+
390
+ # Terminate the file name at the first null byte and
391
+ # ensure paths always use forward slashes as the directory separator.
392
+ filename = _sanitize_filename(filename)
393
+
394
+ self.filename = filename # Normalized file name
395
+ self.date_time = date_time # year, month, day, hour, min, sec
396
+
397
+ if date_time[0] < 1980:
398
+ raise ValueError('ZIP does not support timestamps before 1980')
399
+
400
+ # Standard values:
401
+ self.compress_type = ZIP_STORED # Type of compression for the file
402
+ self._compresslevel = None # Level for the compressor
403
+ self.comment = b"" # Comment for each file
404
+ self.extra = b"" # ZIP extra data
405
+ if sys.platform == 'win32':
406
+ self.create_system = 0 # System which created ZIP archive
407
+ else:
408
+ # Assume everything else is unix-y
409
+ self.create_system = 3 # System which created ZIP archive
410
+ self.create_version = DEFAULT_VERSION # Version which created ZIP archive
411
+ self.extract_version = DEFAULT_VERSION # Version needed to extract archive
412
+ self.reserved = 0 # Must be zero
413
+ self.flag_bits = 0 # ZIP flag bits
414
+ self.volume = 0 # Volume number of file header
415
+ self.internal_attr = 0 # Internal attributes
416
+ self.external_attr = 0 # External file attributes
417
+ self.compress_size = 0 # Size of the compressed file
418
+ self.file_size = 0 # Size of the uncompressed file
419
+ self._end_offset = None # Start of the next local header or central directory
420
+ # Other attributes are set by class ZipFile:
421
+ # header_offset Byte offset to the file header
422
+ # CRC CRC-32 of the uncompressed file
423
+
424
+ def __repr__(self):
425
+ result = ['<%s filename=%r' % (self.__class__.__name__, self.filename)]
426
+ if self.compress_type != ZIP_STORED:
427
+ result.append(' compress_type=%s' %
428
+ compressor_names.get(self.compress_type,
429
+ self.compress_type))
430
+ hi = self.external_attr >> 16
431
+ lo = self.external_attr & 0xFFFF
432
+ if hi:
433
+ result.append(' filemode=%r' % stat.filemode(hi))
434
+ if lo:
435
+ result.append(' external_attr=%#x' % lo)
436
+ isdir = self.is_dir()
437
+ if not isdir or self.file_size:
438
+ result.append(' file_size=%r' % self.file_size)
439
+ if ((not isdir or self.compress_size) and
440
+ (self.compress_type != ZIP_STORED or
441
+ self.file_size != self.compress_size)):
442
+ result.append(' compress_size=%r' % self.compress_size)
443
+ result.append('>')
444
+ return ''.join(result)
445
+
446
+ def FileHeader(self, zip64=None):
447
+ """Return the per-file header as a bytes object.
448
+
449
+ When the optional zip64 arg is None rather than a bool, we will
450
+ decide based upon the file_size and compress_size, if known,
451
+ False otherwise.
452
+ """
453
+ dt = self.date_time
454
+ dosdate = (dt[0] - 1980) << 9 | dt[1] << 5 | dt[2]
455
+ dostime = dt[3] << 11 | dt[4] << 5 | (dt[5] // 2)
456
+ if self.flag_bits & _MASK_USE_DATA_DESCRIPTOR:
457
+ # Set these to zero because we write them after the file data
458
+ CRC = compress_size = file_size = 0
459
+ else:
460
+ CRC = self.CRC
461
+ compress_size = self.compress_size
462
+ file_size = self.file_size
463
+
464
+ extra = self.extra
465
+
466
+ min_version = 0
467
+ if zip64 is None:
468
+ # We always explicitly pass zip64 within this module.... This
469
+ # remains for anyone using ZipInfo.FileHeader as a public API.
470
+ zip64 = file_size > ZIP64_LIMIT or compress_size > ZIP64_LIMIT
471
+ if zip64:
472
+ fmt = '<HHQQ'
473
+ extra = extra + struct.pack(fmt,
474
+ 1, struct.calcsize(fmt)-4, file_size, compress_size)
475
+ file_size = 0xffffffff
476
+ compress_size = 0xffffffff
477
+ min_version = ZIP64_VERSION
478
+
479
+ if self.compress_type == ZIP_BZIP2:
480
+ min_version = max(BZIP2_VERSION, min_version)
481
+ elif self.compress_type == ZIP_LZMA:
482
+ min_version = max(LZMA_VERSION, min_version)
483
+
484
+ self.extract_version = max(min_version, self.extract_version)
485
+ self.create_version = max(min_version, self.create_version)
486
+ filename, flag_bits = self._encodeFilenameFlags()
487
+ header = struct.pack(structFileHeader, stringFileHeader,
488
+ self.extract_version, self.reserved, flag_bits,
489
+ self.compress_type, dostime, dosdate, CRC,
490
+ compress_size, file_size,
491
+ len(filename), len(extra))
492
+ return header + filename + extra
493
+
494
+ def _encodeFilenameFlags(self):
495
+ try:
496
+ return self.filename.encode('ascii'), self.flag_bits
497
+ except UnicodeEncodeError:
498
+ return self.filename.encode('utf-8'), self.flag_bits | _MASK_UTF_FILENAME
499
+
500
+ def _decodeExtra(self, filename_crc):
501
+ # Try to decode the extra field.
502
+ extra = self.extra
503
+ unpack = struct.unpack
504
+ while len(extra) >= 4:
505
+ tp, ln = unpack('<HH', extra[:4])
506
+ if ln+4 > len(extra):
507
+ raise BadZipFile("Corrupt extra field %04x (size=%d)" % (tp, ln))
508
+ if tp == 0x0001:
509
+ data = extra[4:ln+4]
510
+ # ZIP64 extension (large files and/or large archives)
511
+ try:
512
+ if self.file_size in (0xFFFF_FFFF_FFFF_FFFF, 0xFFFF_FFFF):
513
+ field = "File size"
514
+ self.file_size, = unpack('<Q', data[:8])
515
+ data = data[8:]
516
+ if self.compress_size == 0xFFFF_FFFF:
517
+ field = "Compress size"
518
+ self.compress_size, = unpack('<Q', data[:8])
519
+ data = data[8:]
520
+ if self.header_offset == 0xFFFF_FFFF:
521
+ field = "Header offset"
522
+ self.header_offset, = unpack('<Q', data[:8])
523
+ except struct.error:
524
+ raise BadZipFile(f"Corrupt zip64 extra field. "
525
+ f"{field} not found.") from None
526
+ elif tp == 0x7075:
527
+ data = extra[4:ln+4]
528
+ # Unicode Path Extra Field
529
+ try:
530
+ up_version, up_name_crc = unpack('<BL', data[:5])
531
+ if up_version == 1 and up_name_crc == filename_crc:
532
+ up_unicode_name = data[5:].decode('utf-8')
533
+ if up_unicode_name:
534
+ self.filename = _sanitize_filename(up_unicode_name)
535
+ else:
536
+ import warnings
537
+ warnings.warn("Empty unicode path extra field (0x7075)", stacklevel=2)
538
+ except struct.error as e:
539
+ raise BadZipFile("Corrupt unicode path extra field (0x7075)") from e
540
+ except UnicodeDecodeError as e:
541
+ raise BadZipFile('Corrupt unicode path extra field (0x7075): invalid utf-8 bytes') from e
542
+
543
+ extra = extra[ln+4:]
544
+
545
+ @classmethod
546
+ def from_file(cls, filename, arcname=None, *, strict_timestamps=True):
547
+ """Construct an appropriate ZipInfo for a file on the filesystem.
548
+
549
+ filename should be the path to a file or directory on the filesystem.
550
+
551
+ arcname is the name which it will have within the archive (by default,
552
+ this will be the same as filename, but without a drive letter and with
553
+ leading path separators removed).
554
+ """
555
+ if isinstance(filename, os.PathLike):
556
+ filename = os.fspath(filename)
557
+ st = os.stat(filename)
558
+ isdir = stat.S_ISDIR(st.st_mode)
559
+ mtime = time.localtime(st.st_mtime)
560
+ date_time = mtime[0:6]
561
+ if not strict_timestamps and date_time[0] < 1980:
562
+ date_time = (1980, 1, 1, 0, 0, 0)
563
+ elif not strict_timestamps and date_time[0] > 2107:
564
+ date_time = (2107, 12, 31, 23, 59, 59)
565
+ # Create ZipInfo instance to store file information
566
+ if arcname is None:
567
+ arcname = filename
568
+ arcname = os.path.normpath(os.path.splitdrive(arcname)[1])
569
+ while arcname[0] in (os.sep, os.altsep):
570
+ arcname = arcname[1:]
571
+ if isdir:
572
+ arcname += '/'
573
+ zinfo = cls(arcname, date_time)
574
+ zinfo.external_attr = (st.st_mode & 0xFFFF) << 16 # Unix attributes
575
+ if isdir:
576
+ zinfo.file_size = 0
577
+ zinfo.external_attr |= 0x10 # MS-DOS directory flag
578
+ else:
579
+ zinfo.file_size = st.st_size
580
+
581
+ return zinfo
582
+
583
+ def is_dir(self):
584
+ """Return True if this archive member is a directory."""
585
+ if self.filename.endswith('/'):
586
+ return True
587
+ # The ZIP format specification requires to use forward slashes
588
+ # as the directory separator, but in practice some ZIP files
589
+ # created on Windows can use backward slashes. For compatibility
590
+ # with the extraction code which already handles this:
591
+ if os.path.altsep:
592
+ return self.filename.endswith((os.path.sep, os.path.altsep))
593
+ return False
594
+
595
+
596
+ # ZIP encryption uses the CRC32 one-byte primitive for scrambling some
597
+ # internal keys. We noticed that a direct implementation is faster than
598
+ # relying on binascii.crc32().
599
+
600
+ _crctable = None
601
+ def _gen_crc(crc):
602
+ for j in range(8):
603
+ if crc & 1:
604
+ crc = (crc >> 1) ^ 0xEDB88320
605
+ else:
606
+ crc >>= 1
607
+ return crc
608
+
609
+ # ZIP supports a password-based form of encryption. Even though known
610
+ # plaintext attacks have been found against it, it is still useful
611
+ # to be able to get data out of such a file.
612
+ #
613
+ # Usage:
614
+ # zd = _ZipDecrypter(mypwd)
615
+ # plain_bytes = zd(cypher_bytes)
616
+
617
+ def _ZipDecrypter(pwd):
618
+ key0 = 305419896
619
+ key1 = 591751049
620
+ key2 = 878082192
621
+
622
+ global _crctable
623
+ if _crctable is None:
624
+ _crctable = list(map(_gen_crc, range(256)))
625
+ crctable = _crctable
626
+
627
+ def crc32(ch, crc):
628
+ """Compute the CRC32 primitive on one byte."""
629
+ return (crc >> 8) ^ crctable[(crc ^ ch) & 0xFF]
630
+
631
+ def update_keys(c):
632
+ nonlocal key0, key1, key2
633
+ key0 = crc32(c, key0)
634
+ key1 = (key1 + (key0 & 0xFF)) & 0xFFFFFFFF
635
+ key1 = (key1 * 134775813 + 1) & 0xFFFFFFFF
636
+ key2 = crc32(key1 >> 24, key2)
637
+
638
+ for p in pwd:
639
+ update_keys(p)
640
+
641
+ def decrypter(data):
642
+ """Decrypt a bytes object."""
643
+ result = bytearray()
644
+ append = result.append
645
+ for c in data:
646
+ k = key2 | 2
647
+ c ^= ((k * (k^1)) >> 8) & 0xFF
648
+ update_keys(c)
649
+ append(c)
650
+ return bytes(result)
651
+
652
+ return decrypter
653
+
654
+
655
+ class LZMACompressor:
656
+
657
+ def __init__(self):
658
+ self._comp = None
659
+
660
+ def _init(self):
661
+ props = lzma._encode_filter_properties({'id': lzma.FILTER_LZMA1})
662
+ self._comp = lzma.LZMACompressor(lzma.FORMAT_RAW, filters=[
663
+ lzma._decode_filter_properties(lzma.FILTER_LZMA1, props)
664
+ ])
665
+ return struct.pack('<BBH', 9, 4, len(props)) + props
666
+
667
+ def compress(self, data):
668
+ if self._comp is None:
669
+ return self._init() + self._comp.compress(data)
670
+ return self._comp.compress(data)
671
+
672
+ def flush(self):
673
+ if self._comp is None:
674
+ return self._init() + self._comp.flush()
675
+ return self._comp.flush()
676
+
677
+
678
+ class LZMADecompressor:
679
+
680
+ def __init__(self):
681
+ self._decomp = None
682
+ self._unconsumed = b''
683
+ self.eof = False
684
+
685
+ def decompress(self, data):
686
+ if self._decomp is None:
687
+ self._unconsumed += data
688
+ if len(self._unconsumed) <= 4:
689
+ return b''
690
+ psize, = struct.unpack('<H', self._unconsumed[2:4])
691
+ if len(self._unconsumed) <= 4 + psize:
692
+ return b''
693
+
694
+ self._decomp = lzma.LZMADecompressor(lzma.FORMAT_RAW, filters=[
695
+ lzma._decode_filter_properties(lzma.FILTER_LZMA1,
696
+ self._unconsumed[4:4 + psize])
697
+ ])
698
+ data = self._unconsumed[4 + psize:]
699
+ del self._unconsumed
700
+
701
+ result = self._decomp.decompress(data)
702
+ self.eof = self._decomp.eof
703
+ return result
704
+
705
+
706
+ compressor_names = {
707
+ 0: 'store',
708
+ 1: 'shrink',
709
+ 2: 'reduce',
710
+ 3: 'reduce',
711
+ 4: 'reduce',
712
+ 5: 'reduce',
713
+ 6: 'implode',
714
+ 7: 'tokenize',
715
+ 8: 'deflate',
716
+ 9: 'deflate64',
717
+ 10: 'implode',
718
+ 12: 'bzip2',
719
+ 14: 'lzma',
720
+ 18: 'terse',
721
+ 19: 'lz77',
722
+ 97: 'wavpack',
723
+ 98: 'ppmd',
724
+ }
725
+
726
+ def _check_compression(compression):
727
+ if compression == ZIP_STORED:
728
+ pass
729
+ elif compression == ZIP_DEFLATED:
730
+ if not zlib:
731
+ raise RuntimeError(
732
+ "Compression requires the (missing) zlib module")
733
+ elif compression == ZIP_BZIP2:
734
+ if not bz2:
735
+ raise RuntimeError(
736
+ "Compression requires the (missing) bz2 module")
737
+ elif compression == ZIP_LZMA:
738
+ if not lzma:
739
+ raise RuntimeError(
740
+ "Compression requires the (missing) lzma module")
741
+ else:
742
+ raise NotImplementedError("That compression method is not supported")
743
+
744
+
745
+ def _get_compressor(compress_type, compresslevel=None):
746
+ if compress_type == ZIP_DEFLATED:
747
+ if compresslevel is not None:
748
+ return zlib.compressobj(compresslevel, zlib.DEFLATED, -15)
749
+ return zlib.compressobj(zlib.Z_DEFAULT_COMPRESSION, zlib.DEFLATED, -15)
750
+ elif compress_type == ZIP_BZIP2:
751
+ if compresslevel is not None:
752
+ return bz2.BZ2Compressor(compresslevel)
753
+ return bz2.BZ2Compressor()
754
+ # compresslevel is ignored for ZIP_LZMA
755
+ elif compress_type == ZIP_LZMA:
756
+ return LZMACompressor()
757
+ else:
758
+ return None
759
+
760
+
761
+ def _get_decompressor(compress_type):
762
+ _check_compression(compress_type)
763
+ if compress_type == ZIP_STORED:
764
+ return None
765
+ elif compress_type == ZIP_DEFLATED:
766
+ return zlib.decompressobj(-15)
767
+ elif compress_type == ZIP_BZIP2:
768
+ return bz2.BZ2Decompressor()
769
+ elif compress_type == ZIP_LZMA:
770
+ return LZMADecompressor()
771
+ else:
772
+ descr = compressor_names.get(compress_type)
773
+ if descr:
774
+ raise NotImplementedError("compression type %d (%s)" % (compress_type, descr))
775
+ else:
776
+ raise NotImplementedError("compression type %d" % (compress_type,))
777
+
778
+
779
+ class _SharedFile:
780
+ def __init__(self, file, pos, close, lock, writing):
781
+ self._file = file
782
+ self._pos = pos
783
+ self._close = close
784
+ self._lock = lock
785
+ self._writing = writing
786
+ self.seekable = file.seekable
787
+
788
+ def tell(self):
789
+ return self._pos
790
+
791
+ def seek(self, offset, whence=0):
792
+ with self._lock:
793
+ if self._writing():
794
+ raise ValueError("Can't reposition in the ZIP file while "
795
+ "there is an open writing handle on it. "
796
+ "Close the writing handle before trying to read.")
797
+ self._file.seek(offset, whence)
798
+ self._pos = self._file.tell()
799
+ return self._pos
800
+
801
+ def read(self, n=-1):
802
+ with self._lock:
803
+ if self._writing():
804
+ raise ValueError("Can't read from the ZIP file while there "
805
+ "is an open writing handle on it. "
806
+ "Close the writing handle before trying to read.")
807
+ self._file.seek(self._pos)
808
+ data = self._file.read(n)
809
+ self._pos = self._file.tell()
810
+ return data
811
+
812
+ def close(self):
813
+ if self._file is not None:
814
+ fileobj = self._file
815
+ self._file = None
816
+ self._close(fileobj)
817
+
818
+ # Provide the tell method for unseekable stream
819
+ class _Tellable:
820
+ def __init__(self, fp):
821
+ self.fp = fp
822
+ self.offset = 0
823
+
824
+ def write(self, data):
825
+ n = self.fp.write(data)
826
+ self.offset += n
827
+ return n
828
+
829
+ def tell(self):
830
+ return self.offset
831
+
832
+ def flush(self):
833
+ self.fp.flush()
834
+
835
+ def close(self):
836
+ self.fp.close()
837
+
838
+
839
+ class ZipExtFile(io.BufferedIOBase):
840
+ """File-like object for reading an archive member.
841
+ Is returned by ZipFile.open().
842
+ """
843
+
844
+ # Max size supported by decompressor.
845
+ MAX_N = 1 << 31 - 1
846
+
847
+ # Read from compressed files in 4k blocks.
848
+ MIN_READ_SIZE = 4096
849
+
850
+ # Chunk size to read during seek
851
+ MAX_SEEK_READ = 1 << 24
852
+
853
+ def __init__(self, fileobj, mode, zipinfo, pwd=None,
854
+ close_fileobj=False):
855
+ self._fileobj = fileobj
856
+ self._pwd = pwd
857
+ self._close_fileobj = close_fileobj
858
+
859
+ self._compress_type = zipinfo.compress_type
860
+ self._compress_left = zipinfo.compress_size
861
+ self._left = zipinfo.file_size
862
+
863
+ self._decompressor = _get_decompressor(self._compress_type)
864
+
865
+ self._eof = False
866
+ self._readbuffer = b''
867
+ self._offset = 0
868
+
869
+ self.newlines = None
870
+
871
+ self.mode = mode
872
+ self.name = zipinfo.filename
873
+
874
+ if hasattr(zipinfo, 'CRC'):
875
+ self._expected_crc = zipinfo.CRC
876
+ self._running_crc = crc32(b'')
877
+ else:
878
+ self._expected_crc = None
879
+
880
+ self._seekable = False
881
+ try:
882
+ if fileobj.seekable():
883
+ self._orig_compress_start = fileobj.tell()
884
+ self._orig_compress_size = zipinfo.compress_size
885
+ self._orig_file_size = zipinfo.file_size
886
+ self._orig_start_crc = self._running_crc
887
+ self._orig_crc = self._expected_crc
888
+ self._seekable = True
889
+ except AttributeError:
890
+ pass
891
+
892
+ self._decrypter = None
893
+ if pwd:
894
+ if zipinfo.flag_bits & _MASK_USE_DATA_DESCRIPTOR:
895
+ # compare against the file type from extended local headers
896
+ check_byte = (zipinfo._raw_time >> 8) & 0xff
897
+ else:
898
+ # compare against the CRC otherwise
899
+ check_byte = (zipinfo.CRC >> 24) & 0xff
900
+ h = self._init_decrypter()
901
+ if h != check_byte:
902
+ raise RuntimeError("Bad password for file %r" % zipinfo.orig_filename)
903
+
904
+
905
+ def _init_decrypter(self):
906
+ self._decrypter = _ZipDecrypter(self._pwd)
907
+ # The first 12 bytes in the cypher stream is an encryption header
908
+ # used to strengthen the algorithm. The first 11 bytes are
909
+ # completely random, while the 12th contains the MSB of the CRC,
910
+ # or the MSB of the file time depending on the header type
911
+ # and is used to check the correctness of the password.
912
+ header = self._fileobj.read(12)
913
+ self._compress_left -= 12
914
+ return self._decrypter(header)[11]
915
+
916
+ def __repr__(self):
917
+ result = ['<%s.%s' % (self.__class__.__module__,
918
+ self.__class__.__qualname__)]
919
+ if not self.closed:
920
+ result.append(' name=%r mode=%r' % (self.name, self.mode))
921
+ if self._compress_type != ZIP_STORED:
922
+ result.append(' compress_type=%s' %
923
+ compressor_names.get(self._compress_type,
924
+ self._compress_type))
925
+ else:
926
+ result.append(' [closed]')
927
+ result.append('>')
928
+ return ''.join(result)
929
+
930
+ def readline(self, limit=-1):
931
+ """Read and return a line from the stream.
932
+
933
+ If limit is specified, at most limit bytes will be read.
934
+ """
935
+
936
+ if limit < 0:
937
+ # Shortcut common case - newline found in buffer.
938
+ i = self._readbuffer.find(b'\n', self._offset) + 1
939
+ if i > 0:
940
+ line = self._readbuffer[self._offset: i]
941
+ self._offset = i
942
+ return line
943
+
944
+ return io.BufferedIOBase.readline(self, limit)
945
+
946
+ def peek(self, n=1):
947
+ """Returns buffered bytes without advancing the position."""
948
+ if n > len(self._readbuffer) - self._offset:
949
+ chunk = self.read(n)
950
+ if len(chunk) > self._offset:
951
+ self._readbuffer = chunk + self._readbuffer[self._offset:]
952
+ self._offset = 0
953
+ else:
954
+ self._offset -= len(chunk)
955
+
956
+ # Return up to 512 bytes to reduce allocation overhead for tight loops.
957
+ return self._readbuffer[self._offset: self._offset + 512]
958
+
959
+ def readable(self):
960
+ if self.closed:
961
+ raise ValueError("I/O operation on closed file.")
962
+ return True
963
+
964
+ def read(self, n=-1):
965
+ """Read and return up to n bytes.
966
+ If the argument is omitted, None, or negative, data is read and returned until EOF is reached.
967
+ """
968
+ if self.closed:
969
+ raise ValueError("read from closed file.")
970
+ if n is None or n < 0:
971
+ buf = self._readbuffer[self._offset:]
972
+ self._readbuffer = b''
973
+ self._offset = 0
974
+ while not self._eof:
975
+ buf += self._read1(self.MAX_N)
976
+ return buf
977
+
978
+ end = n + self._offset
979
+ if end < len(self._readbuffer):
980
+ buf = self._readbuffer[self._offset:end]
981
+ self._offset = end
982
+ return buf
983
+
984
+ n = end - len(self._readbuffer)
985
+ buf = self._readbuffer[self._offset:]
986
+ self._readbuffer = b''
987
+ self._offset = 0
988
+ while n > 0 and not self._eof:
989
+ data = self._read1(n)
990
+ if n < len(data):
991
+ self._readbuffer = data
992
+ self._offset = n
993
+ buf += data[:n]
994
+ break
995
+ buf += data
996
+ n -= len(data)
997
+ return buf
998
+
999
+ def _update_crc(self, newdata):
1000
+ # Update the CRC using the given data.
1001
+ if self._expected_crc is None:
1002
+ # No need to compute the CRC if we don't have a reference value
1003
+ return
1004
+ self._running_crc = crc32(newdata, self._running_crc)
1005
+ # Check the CRC if we're at the end of the file
1006
+ if self._eof and self._running_crc != self._expected_crc:
1007
+ raise BadZipFile("Bad CRC-32 for file %r" % self.name)
1008
+
1009
+ def read1(self, n):
1010
+ """Read up to n bytes with at most one read() system call."""
1011
+
1012
+ if n is None or n < 0:
1013
+ buf = self._readbuffer[self._offset:]
1014
+ self._readbuffer = b''
1015
+ self._offset = 0
1016
+ while not self._eof:
1017
+ data = self._read1(self.MAX_N)
1018
+ if data:
1019
+ buf += data
1020
+ break
1021
+ return buf
1022
+
1023
+ end = n + self._offset
1024
+ if end < len(self._readbuffer):
1025
+ buf = self._readbuffer[self._offset:end]
1026
+ self._offset = end
1027
+ return buf
1028
+
1029
+ n = end - len(self._readbuffer)
1030
+ buf = self._readbuffer[self._offset:]
1031
+ self._readbuffer = b''
1032
+ self._offset = 0
1033
+ if n > 0:
1034
+ while not self._eof:
1035
+ data = self._read1(n)
1036
+ if n < len(data):
1037
+ self._readbuffer = data
1038
+ self._offset = n
1039
+ buf += data[:n]
1040
+ break
1041
+ if data:
1042
+ buf += data
1043
+ break
1044
+ return buf
1045
+
1046
+ def _read1(self, n):
1047
+ # Read up to n compressed bytes with at most one read() system call,
1048
+ # decrypt and decompress them.
1049
+ if self._eof or n <= 0:
1050
+ return b''
1051
+
1052
+ # Read from file.
1053
+ if self._compress_type == ZIP_DEFLATED:
1054
+ ## Handle unconsumed data.
1055
+ data = self._decompressor.unconsumed_tail
1056
+ if n > len(data):
1057
+ data += self._read2(n - len(data))
1058
+ else:
1059
+ data = self._read2(n)
1060
+
1061
+ if self._compress_type == ZIP_STORED:
1062
+ self._eof = self._compress_left <= 0
1063
+ elif self._compress_type == ZIP_DEFLATED:
1064
+ n = max(n, self.MIN_READ_SIZE)
1065
+ data = self._decompressor.decompress(data, n)
1066
+ self._eof = (self._decompressor.eof or
1067
+ self._compress_left <= 0 and
1068
+ not self._decompressor.unconsumed_tail)
1069
+ if self._eof:
1070
+ data += self._decompressor.flush()
1071
+ else:
1072
+ data = self._decompressor.decompress(data)
1073
+ self._eof = self._decompressor.eof or self._compress_left <= 0
1074
+
1075
+ data = data[:self._left]
1076
+ self._left -= len(data)
1077
+ if self._left <= 0:
1078
+ self._eof = True
1079
+ self._update_crc(data)
1080
+ return data
1081
+
1082
+ def _read2(self, n):
1083
+ if self._compress_left <= 0:
1084
+ return b''
1085
+
1086
+ n = max(n, self.MIN_READ_SIZE)
1087
+ n = min(n, self._compress_left)
1088
+
1089
+ data = self._fileobj.read(n)
1090
+ self._compress_left -= len(data)
1091
+ if not data:
1092
+ raise EOFError
1093
+
1094
+ if self._decrypter is not None:
1095
+ data = self._decrypter(data)
1096
+ return data
1097
+
1098
+ def close(self):
1099
+ try:
1100
+ if self._close_fileobj:
1101
+ self._fileobj.close()
1102
+ finally:
1103
+ super().close()
1104
+
1105
+ def seekable(self):
1106
+ if self.closed:
1107
+ raise ValueError("I/O operation on closed file.")
1108
+ return self._seekable
1109
+
1110
+ def seek(self, offset, whence=os.SEEK_SET):
1111
+ if self.closed:
1112
+ raise ValueError("seek on closed file.")
1113
+ if not self._seekable:
1114
+ raise io.UnsupportedOperation("underlying stream is not seekable")
1115
+ curr_pos = self.tell()
1116
+ if whence == os.SEEK_SET:
1117
+ new_pos = offset
1118
+ elif whence == os.SEEK_CUR:
1119
+ new_pos = curr_pos + offset
1120
+ elif whence == os.SEEK_END:
1121
+ new_pos = self._orig_file_size + offset
1122
+ else:
1123
+ raise ValueError("whence must be os.SEEK_SET (0), "
1124
+ "os.SEEK_CUR (1), or os.SEEK_END (2)")
1125
+
1126
+ if new_pos > self._orig_file_size:
1127
+ new_pos = self._orig_file_size
1128
+
1129
+ if new_pos < 0:
1130
+ new_pos = 0
1131
+
1132
+ read_offset = new_pos - curr_pos
1133
+ buff_offset = read_offset + self._offset
1134
+
1135
+ if buff_offset >= 0 and buff_offset < len(self._readbuffer):
1136
+ # Just move the _offset index if the new position is in the _readbuffer
1137
+ self._offset = buff_offset
1138
+ read_offset = 0
1139
+ # Fast seek uncompressed unencrypted file
1140
+ elif self._compress_type == ZIP_STORED and self._decrypter is None and read_offset > 0:
1141
+ # disable CRC checking after first seeking - it would be invalid
1142
+ self._expected_crc = None
1143
+ # seek actual file taking already buffered data into account
1144
+ read_offset -= len(self._readbuffer) - self._offset
1145
+ self._fileobj.seek(read_offset, os.SEEK_CUR)
1146
+ self._left -= read_offset
1147
+ read_offset = 0
1148
+ # flush read buffer
1149
+ self._readbuffer = b''
1150
+ self._offset = 0
1151
+ elif read_offset < 0:
1152
+ # Position is before the current position. Reset the ZipExtFile
1153
+ self._fileobj.seek(self._orig_compress_start)
1154
+ self._running_crc = self._orig_start_crc
1155
+ self._expected_crc = self._orig_crc
1156
+ self._compress_left = self._orig_compress_size
1157
+ self._left = self._orig_file_size
1158
+ self._readbuffer = b''
1159
+ self._offset = 0
1160
+ self._decompressor = _get_decompressor(self._compress_type)
1161
+ self._eof = False
1162
+ read_offset = new_pos
1163
+ if self._decrypter is not None:
1164
+ self._init_decrypter()
1165
+
1166
+ while read_offset > 0:
1167
+ read_len = min(self.MAX_SEEK_READ, read_offset)
1168
+ self.read(read_len)
1169
+ read_offset -= read_len
1170
+
1171
+ return self.tell()
1172
+
1173
+ def tell(self):
1174
+ if self.closed:
1175
+ raise ValueError("tell on closed file.")
1176
+ if not self._seekable:
1177
+ raise io.UnsupportedOperation("underlying stream is not seekable")
1178
+ filepos = self._orig_file_size - self._left - len(self._readbuffer) + self._offset
1179
+ return filepos
1180
+
1181
+
1182
+ class _ZipWriteFile(io.BufferedIOBase):
1183
+ def __init__(self, zf, zinfo, zip64):
1184
+ self._zinfo = zinfo
1185
+ self._zip64 = zip64
1186
+ self._zipfile = zf
1187
+ self._compressor = _get_compressor(zinfo.compress_type,
1188
+ zinfo._compresslevel)
1189
+ self._file_size = 0
1190
+ self._compress_size = 0
1191
+ self._crc = 0
1192
+
1193
+ @property
1194
+ def _fileobj(self):
1195
+ return self._zipfile.fp
1196
+
1197
+ def writable(self):
1198
+ return True
1199
+
1200
+ def write(self, data):
1201
+ if self.closed:
1202
+ raise ValueError('I/O operation on closed file.')
1203
+
1204
+ # Accept any data that supports the buffer protocol
1205
+ if isinstance(data, (bytes, bytearray)):
1206
+ nbytes = len(data)
1207
+ else:
1208
+ data = memoryview(data)
1209
+ nbytes = data.nbytes
1210
+ self._file_size += nbytes
1211
+
1212
+ self._crc = crc32(data, self._crc)
1213
+ if self._compressor:
1214
+ data = self._compressor.compress(data)
1215
+ self._compress_size += len(data)
1216
+ self._fileobj.write(data)
1217
+ return nbytes
1218
+
1219
+ def close(self):
1220
+ if self.closed:
1221
+ return
1222
+ try:
1223
+ super().close()
1224
+ # Flush any data from the compressor, and update header info
1225
+ if self._compressor:
1226
+ buf = self._compressor.flush()
1227
+ self._compress_size += len(buf)
1228
+ self._fileobj.write(buf)
1229
+ self._zinfo.compress_size = self._compress_size
1230
+ else:
1231
+ self._zinfo.compress_size = self._file_size
1232
+ self._zinfo.CRC = self._crc
1233
+ self._zinfo.file_size = self._file_size
1234
+
1235
+ if not self._zip64:
1236
+ if self._file_size > ZIP64_LIMIT:
1237
+ raise RuntimeError("File size too large, try using force_zip64")
1238
+ if self._compress_size > ZIP64_LIMIT:
1239
+ raise RuntimeError("Compressed size too large, try using force_zip64")
1240
+
1241
+ # Write updated header info
1242
+ if self._zinfo.flag_bits & _MASK_USE_DATA_DESCRIPTOR:
1243
+ # Write CRC and file sizes after the file data
1244
+ fmt = '<LLQQ' if self._zip64 else '<LLLL'
1245
+ self._fileobj.write(struct.pack(fmt, _DD_SIGNATURE, self._zinfo.CRC,
1246
+ self._zinfo.compress_size, self._zinfo.file_size))
1247
+ self._zipfile.start_dir = self._fileobj.tell()
1248
+ else:
1249
+ # Seek backwards and write file header (which will now include
1250
+ # correct CRC and file sizes)
1251
+
1252
+ # Preserve current position in file
1253
+ self._zipfile.start_dir = self._fileobj.tell()
1254
+ self._fileobj.seek(self._zinfo.header_offset)
1255
+ self._fileobj.write(self._zinfo.FileHeader(self._zip64))
1256
+ self._fileobj.seek(self._zipfile.start_dir)
1257
+
1258
+ # Successfully written: Add file to our caches
1259
+ self._zipfile.filelist.append(self._zinfo)
1260
+ self._zipfile.NameToInfo[self._zinfo.filename] = self._zinfo
1261
+ finally:
1262
+ self._zipfile._writing = False
1263
+
1264
+
1265
+
1266
+ class ZipFile:
1267
+ """ Class with methods to open, read, write, close, list zip files.
1268
+
1269
+ z = ZipFile(file, mode="r", compression=ZIP_STORED, allowZip64=True,
1270
+ compresslevel=None)
1271
+
1272
+ file: Either the path to the file, or a file-like object.
1273
+ If it is a path, the file will be opened and closed by ZipFile.
1274
+ mode: The mode can be either read 'r', write 'w', exclusive create 'x',
1275
+ or append 'a'.
1276
+ compression: ZIP_STORED (no compression), ZIP_DEFLATED (requires zlib),
1277
+ ZIP_BZIP2 (requires bz2) or ZIP_LZMA (requires lzma).
1278
+ allowZip64: if True ZipFile will create files with ZIP64 extensions when
1279
+ needed, otherwise it will raise an exception when this would
1280
+ be necessary.
1281
+ compresslevel: None (default for the given compression type) or an integer
1282
+ specifying the level to pass to the compressor.
1283
+ When using ZIP_STORED or ZIP_LZMA this keyword has no effect.
1284
+ When using ZIP_DEFLATED integers 0 through 9 are accepted.
1285
+ When using ZIP_BZIP2 integers 1 through 9 are accepted.
1286
+
1287
+ """
1288
+
1289
+ fp = None # Set here since __del__ checks it
1290
+ _windows_illegal_name_trans_table = None
1291
+
1292
+ def __init__(self, file, mode="r", compression=ZIP_STORED, allowZip64=True,
1293
+ compresslevel=None, *, strict_timestamps=True, metadata_encoding=None):
1294
+ """Open the ZIP file with mode read 'r', write 'w', exclusive create 'x',
1295
+ or append 'a'."""
1296
+ if mode not in ('r', 'w', 'x', 'a'):
1297
+ raise ValueError("ZipFile requires mode 'r', 'w', 'x', or 'a'")
1298
+
1299
+ _check_compression(compression)
1300
+
1301
+ self._allowZip64 = allowZip64
1302
+ self._didModify = False
1303
+ self.debug = 0 # Level of printing: 0 through 3
1304
+ self.NameToInfo = {} # Find file info given name
1305
+ self.filelist = [] # List of ZipInfo instances for archive
1306
+ self.compression = compression # Method of compression
1307
+ self.compresslevel = compresslevel
1308
+ self.mode = mode
1309
+ self.pwd = None
1310
+ self._comment = b''
1311
+ self._strict_timestamps = strict_timestamps
1312
+ self.metadata_encoding = metadata_encoding
1313
+
1314
+ # Check that we don't try to write with nonconforming codecs
1315
+ if self.metadata_encoding and mode != 'r':
1316
+ raise ValueError(
1317
+ "metadata_encoding is only supported for reading files")
1318
+
1319
+ # Check if we were passed a file-like object
1320
+ if isinstance(file, os.PathLike):
1321
+ file = os.fspath(file)
1322
+ if isinstance(file, str):
1323
+ # No, it's a filename
1324
+ self._filePassed = 0
1325
+ self.filename = file
1326
+ modeDict = {'r' : 'rb', 'w': 'w+b', 'x': 'x+b', 'a' : 'r+b',
1327
+ 'r+b': 'w+b', 'w+b': 'wb', 'x+b': 'xb'}
1328
+ filemode = modeDict[mode]
1329
+ while True:
1330
+ try:
1331
+ self.fp = io.open(file, filemode)
1332
+ except OSError:
1333
+ if filemode in modeDict:
1334
+ filemode = modeDict[filemode]
1335
+ continue
1336
+ raise
1337
+ break
1338
+ else:
1339
+ self._filePassed = 1
1340
+ self.fp = file
1341
+ self.filename = getattr(file, 'name', None)
1342
+ self._fileRefCnt = 1
1343
+ self._lock = threading.RLock()
1344
+ self._seekable = True
1345
+ self._writing = False
1346
+
1347
+ try:
1348
+ if mode == 'r':
1349
+ self._RealGetContents()
1350
+ elif mode in ('w', 'x'):
1351
+ # set the modified flag so central directory gets written
1352
+ # even if no files are added to the archive
1353
+ self._didModify = True
1354
+ try:
1355
+ self.start_dir = self.fp.tell()
1356
+ except (AttributeError, OSError):
1357
+ self.fp = _Tellable(self.fp)
1358
+ self.start_dir = 0
1359
+ self._seekable = False
1360
+ else:
1361
+ # Some file-like objects can provide tell() but not seek()
1362
+ try:
1363
+ self.fp.seek(self.start_dir)
1364
+ except (AttributeError, OSError):
1365
+ self._seekable = False
1366
+ elif mode == 'a':
1367
+ try:
1368
+ # See if file is a zip file
1369
+ self._RealGetContents()
1370
+ # seek to start of directory and overwrite
1371
+ self.fp.seek(self.start_dir)
1372
+ except BadZipFile:
1373
+ # file is not a zip file, just append
1374
+ self.fp.seek(0, 2)
1375
+
1376
+ # set the modified flag so central directory gets written
1377
+ # even if no files are added to the archive
1378
+ self._didModify = True
1379
+ self.start_dir = self.fp.tell()
1380
+ else:
1381
+ raise ValueError("Mode must be 'r', 'w', 'x', or 'a'")
1382
+ except:
1383
+ fp = self.fp
1384
+ self.fp = None
1385
+ self._fpclose(fp)
1386
+ raise
1387
+
1388
+ def __enter__(self):
1389
+ return self
1390
+
1391
+ def __exit__(self, type, value, traceback):
1392
+ self.close()
1393
+
1394
+ def __repr__(self):
1395
+ result = ['<%s.%s' % (self.__class__.__module__,
1396
+ self.__class__.__qualname__)]
1397
+ if self.fp is not None:
1398
+ if self._filePassed:
1399
+ result.append(' file=%r' % self.fp)
1400
+ elif self.filename is not None:
1401
+ result.append(' filename=%r' % self.filename)
1402
+ result.append(' mode=%r' % self.mode)
1403
+ else:
1404
+ result.append(' [closed]')
1405
+ result.append('>')
1406
+ return ''.join(result)
1407
+
1408
+ def _RealGetContents(self):
1409
+ """Read in the table of contents for the ZIP file."""
1410
+ fp = self.fp
1411
+ try:
1412
+ endrec = _EndRecData(fp)
1413
+ except OSError:
1414
+ raise BadZipFile("File is not a zip file")
1415
+ if not endrec:
1416
+ raise BadZipFile("File is not a zip file")
1417
+ if self.debug > 1:
1418
+ print(endrec)
1419
+ size_cd = endrec[_ECD_SIZE] # bytes in central directory
1420
+ offset_cd = endrec[_ECD_OFFSET] # offset of central directory
1421
+ self._comment = endrec[_ECD_COMMENT] # archive comment
1422
+
1423
+ # "concat" is zero, unless zip was concatenated to another file
1424
+ concat = endrec[_ECD_LOCATION] - size_cd - offset_cd
1425
+ if endrec[_ECD_SIGNATURE] == stringEndArchive64:
1426
+ # If Zip64 extension structures are present, account for them
1427
+ concat -= (sizeEndCentDir64 + sizeEndCentDir64Locator)
1428
+
1429
+ if self.debug > 2:
1430
+ inferred = concat + offset_cd
1431
+ print("given, inferred, offset", offset_cd, inferred, concat)
1432
+ # self.start_dir: Position of start of central directory
1433
+ self.start_dir = offset_cd + concat
1434
+ if self.start_dir < 0:
1435
+ raise BadZipFile("Bad offset for central directory")
1436
+ fp.seek(self.start_dir, 0)
1437
+ data = fp.read(size_cd)
1438
+ fp = io.BytesIO(data)
1439
+ total = 0
1440
+ while total < size_cd:
1441
+ centdir = fp.read(sizeCentralDir)
1442
+ if len(centdir) != sizeCentralDir:
1443
+ raise BadZipFile("Truncated central directory")
1444
+ centdir = struct.unpack(structCentralDir, centdir)
1445
+ if centdir[_CD_SIGNATURE] != stringCentralDir:
1446
+ raise BadZipFile("Bad magic number for central directory")
1447
+ if self.debug > 2:
1448
+ print(centdir)
1449
+ filename = fp.read(centdir[_CD_FILENAME_LENGTH])
1450
+ orig_filename_crc = crc32(filename)
1451
+ flags = centdir[_CD_FLAG_BITS]
1452
+ if flags & _MASK_UTF_FILENAME:
1453
+ # UTF-8 file names extension
1454
+ filename = filename.decode('utf-8')
1455
+ else:
1456
+ # Historical ZIP filename encoding
1457
+ filename = filename.decode(self.metadata_encoding or 'cp437')
1458
+ # Create ZipInfo instance to store file information
1459
+ x = ZipInfo(filename)
1460
+ x.extra = fp.read(centdir[_CD_EXTRA_FIELD_LENGTH])
1461
+ x.comment = fp.read(centdir[_CD_COMMENT_LENGTH])
1462
+ x.header_offset = centdir[_CD_LOCAL_HEADER_OFFSET]
1463
+ (x.create_version, x.create_system, x.extract_version, x.reserved,
1464
+ x.flag_bits, x.compress_type, t, d,
1465
+ x.CRC, x.compress_size, x.file_size) = centdir[1:12]
1466
+ if x.extract_version > MAX_EXTRACT_VERSION:
1467
+ raise NotImplementedError("zip file version %.1f" %
1468
+ (x.extract_version / 10))
1469
+ x.volume, x.internal_attr, x.external_attr = centdir[15:18]
1470
+ # Convert date/time code to (year, month, day, hour, min, sec)
1471
+ x._raw_time = t
1472
+ x.date_time = ( (d>>9)+1980, (d>>5)&0xF, d&0x1F,
1473
+ t>>11, (t>>5)&0x3F, (t&0x1F) * 2 )
1474
+ x._decodeExtra(orig_filename_crc)
1475
+ x.header_offset = x.header_offset + concat
1476
+ self.filelist.append(x)
1477
+ self.NameToInfo[x.filename] = x
1478
+
1479
+ # update total bytes read from central directory
1480
+ total = (total + sizeCentralDir + centdir[_CD_FILENAME_LENGTH]
1481
+ + centdir[_CD_EXTRA_FIELD_LENGTH]
1482
+ + centdir[_CD_COMMENT_LENGTH])
1483
+
1484
+ if self.debug > 2:
1485
+ print("total", total)
1486
+
1487
+ end_offset = self.start_dir
1488
+ for zinfo in sorted(self.filelist,
1489
+ key=lambda zinfo: zinfo.header_offset,
1490
+ reverse=True):
1491
+ zinfo._end_offset = end_offset
1492
+ end_offset = zinfo.header_offset
1493
+
1494
+ def namelist(self):
1495
+ """Return a list of file names in the archive."""
1496
+ return [data.filename for data in self.filelist]
1497
+
1498
+ def infolist(self):
1499
+ """Return a list of class ZipInfo instances for files in the
1500
+ archive."""
1501
+ return self.filelist
1502
+
1503
+ def printdir(self, file=None):
1504
+ """Print a table of contents for the zip file."""
1505
+ print("%-46s %19s %12s" % ("File Name", "Modified ", "Size"),
1506
+ file=file)
1507
+ for zinfo in self.filelist:
1508
+ date = "%d-%02d-%02d %02d:%02d:%02d" % zinfo.date_time[:6]
1509
+ print("%-46s %s %12d" % (zinfo.filename, date, zinfo.file_size),
1510
+ file=file)
1511
+
1512
+ def testzip(self):
1513
+ """Read all the files and check the CRC.
1514
+
1515
+ Return None if all files could be read successfully, or the name
1516
+ of the offending file otherwise."""
1517
+ chunk_size = 2 ** 20
1518
+ for zinfo in self.filelist:
1519
+ try:
1520
+ # Read by chunks, to avoid an OverflowError or a
1521
+ # MemoryError with very large embedded files.
1522
+ with self.open(zinfo.filename, "r") as f:
1523
+ while f.read(chunk_size): # Check CRC-32
1524
+ pass
1525
+ except BadZipFile:
1526
+ return zinfo.filename
1527
+
1528
+ def getinfo(self, name):
1529
+ """Return the instance of ZipInfo given 'name'."""
1530
+ info = self.NameToInfo.get(name)
1531
+ if info is None:
1532
+ raise KeyError(
1533
+ 'There is no item named %r in the archive' % name)
1534
+
1535
+ return info
1536
+
1537
+ def setpassword(self, pwd):
1538
+ """Set default password for encrypted files."""
1539
+ if pwd and not isinstance(pwd, bytes):
1540
+ raise TypeError("pwd: expected bytes, got %s" % type(pwd).__name__)
1541
+ if pwd:
1542
+ self.pwd = pwd
1543
+ else:
1544
+ self.pwd = None
1545
+
1546
+ @property
1547
+ def comment(self):
1548
+ """The comment text associated with the ZIP file."""
1549
+ return self._comment
1550
+
1551
+ @comment.setter
1552
+ def comment(self, comment):
1553
+ if not isinstance(comment, bytes):
1554
+ raise TypeError("comment: expected bytes, got %s" % type(comment).__name__)
1555
+ # check for valid comment length
1556
+ if len(comment) > ZIP_MAX_COMMENT:
1557
+ import warnings
1558
+ warnings.warn('Archive comment is too long; truncating to %d bytes'
1559
+ % ZIP_MAX_COMMENT, stacklevel=2)
1560
+ comment = comment[:ZIP_MAX_COMMENT]
1561
+ self._comment = comment
1562
+ self._didModify = True
1563
+
1564
+ def read(self, name, pwd=None):
1565
+ """Return file bytes for name. 'pwd' is the password to decrypt
1566
+ encrypted files."""
1567
+ with self.open(name, "r", pwd) as fp:
1568
+ return fp.read()
1569
+
1570
+ def open(self, name, mode="r", pwd=None, *, force_zip64=False):
1571
+ """Return file-like object for 'name'.
1572
+
1573
+ name is a string for the file name within the ZIP file, or a ZipInfo
1574
+ object.
1575
+
1576
+ mode should be 'r' to read a file already in the ZIP file, or 'w' to
1577
+ write to a file newly added to the archive.
1578
+
1579
+ pwd is the password to decrypt files (only used for reading).
1580
+
1581
+ When writing, if the file size is not known in advance but may exceed
1582
+ 2 GiB, pass force_zip64 to use the ZIP64 format, which can handle large
1583
+ files. If the size is known in advance, it is best to pass a ZipInfo
1584
+ instance for name, with zinfo.file_size set.
1585
+ """
1586
+ if mode not in {"r", "w"}:
1587
+ raise ValueError('open() requires mode "r" or "w"')
1588
+ if pwd and (mode == "w"):
1589
+ raise ValueError("pwd is only supported for reading files")
1590
+ if not self.fp:
1591
+ raise ValueError(
1592
+ "Attempt to use ZIP archive that was already closed")
1593
+
1594
+ # Make sure we have an info object
1595
+ if isinstance(name, ZipInfo):
1596
+ # 'name' is already an info object
1597
+ zinfo = name
1598
+ elif mode == 'w':
1599
+ zinfo = ZipInfo(name)
1600
+ zinfo.compress_type = self.compression
1601
+ zinfo._compresslevel = self.compresslevel
1602
+ else:
1603
+ # Get info object for name
1604
+ zinfo = self.getinfo(name)
1605
+
1606
+ if mode == 'w':
1607
+ return self._open_to_write(zinfo, force_zip64=force_zip64)
1608
+
1609
+ if self._writing:
1610
+ raise ValueError("Can't read from the ZIP file while there "
1611
+ "is an open writing handle on it. "
1612
+ "Close the writing handle before trying to read.")
1613
+
1614
+ # Open for reading:
1615
+ self._fileRefCnt += 1
1616
+ zef_file = _SharedFile(self.fp, zinfo.header_offset,
1617
+ self._fpclose, self._lock, lambda: self._writing)
1618
+ try:
1619
+ # Skip the file header:
1620
+ fheader = zef_file.read(sizeFileHeader)
1621
+ if len(fheader) != sizeFileHeader:
1622
+ raise BadZipFile("Truncated file header")
1623
+ fheader = struct.unpack(structFileHeader, fheader)
1624
+ if fheader[_FH_SIGNATURE] != stringFileHeader:
1625
+ raise BadZipFile("Bad magic number for file header")
1626
+
1627
+ fname = zef_file.read(fheader[_FH_FILENAME_LENGTH])
1628
+ if fheader[_FH_EXTRA_FIELD_LENGTH]:
1629
+ zef_file.seek(fheader[_FH_EXTRA_FIELD_LENGTH], whence=1)
1630
+
1631
+ if zinfo.flag_bits & _MASK_COMPRESSED_PATCH:
1632
+ # Zip 2.7: compressed patched data
1633
+ raise NotImplementedError("compressed patched data (flag bit 5)")
1634
+
1635
+ if zinfo.flag_bits & _MASK_STRONG_ENCRYPTION:
1636
+ # strong encryption
1637
+ raise NotImplementedError("strong encryption (flag bit 6)")
1638
+
1639
+ if fheader[_FH_GENERAL_PURPOSE_FLAG_BITS] & _MASK_UTF_FILENAME:
1640
+ # UTF-8 filename
1641
+ fname_str = fname.decode("utf-8")
1642
+ else:
1643
+ fname_str = fname.decode(self.metadata_encoding or "cp437")
1644
+
1645
+ if fname_str != zinfo.orig_filename:
1646
+ raise BadZipFile(
1647
+ 'File name in directory %r and header %r differ.'
1648
+ % (zinfo.orig_filename, fname))
1649
+
1650
+ if (zinfo._end_offset is not None and
1651
+ zef_file.tell() + zinfo.compress_size > zinfo._end_offset):
1652
+ raise BadZipFile(f"Overlapped entries: {zinfo.orig_filename!r} (possible zip bomb)")
1653
+
1654
+ # check for encrypted flag & handle password
1655
+ is_encrypted = zinfo.flag_bits & _MASK_ENCRYPTED
1656
+ if is_encrypted:
1657
+ if not pwd:
1658
+ pwd = self.pwd
1659
+ if pwd and not isinstance(pwd, bytes):
1660
+ raise TypeError("pwd: expected bytes, got %s" % type(pwd).__name__)
1661
+ if not pwd:
1662
+ raise RuntimeError("File %r is encrypted, password "
1663
+ "required for extraction" % name)
1664
+ else:
1665
+ pwd = None
1666
+
1667
+ return ZipExtFile(zef_file, mode, zinfo, pwd, True)
1668
+ except:
1669
+ zef_file.close()
1670
+ raise
1671
+
1672
+ def _open_to_write(self, zinfo, force_zip64=False):
1673
+ if force_zip64 and not self._allowZip64:
1674
+ raise ValueError(
1675
+ "force_zip64 is True, but allowZip64 was False when opening "
1676
+ "the ZIP file."
1677
+ )
1678
+ if self._writing:
1679
+ raise ValueError("Can't write to the ZIP file while there is "
1680
+ "another write handle open on it. "
1681
+ "Close the first handle before opening another.")
1682
+
1683
+ # Size and CRC are overwritten with correct data after processing the file
1684
+ zinfo.compress_size = 0
1685
+ zinfo.CRC = 0
1686
+
1687
+ zinfo.flag_bits = 0x00
1688
+ if zinfo.compress_type == ZIP_LZMA:
1689
+ # Compressed data includes an end-of-stream (EOS) marker
1690
+ zinfo.flag_bits |= _MASK_COMPRESS_OPTION_1
1691
+ if not self._seekable:
1692
+ zinfo.flag_bits |= _MASK_USE_DATA_DESCRIPTOR
1693
+
1694
+ if not zinfo.external_attr:
1695
+ zinfo.external_attr = 0o600 << 16 # permissions: ?rw-------
1696
+
1697
+ # Compressed size can be larger than uncompressed size
1698
+ zip64 = force_zip64 or (zinfo.file_size * 1.05 > ZIP64_LIMIT)
1699
+ if not self._allowZip64 and zip64:
1700
+ raise LargeZipFile("Filesize would require ZIP64 extensions")
1701
+
1702
+ if self._seekable:
1703
+ self.fp.seek(self.start_dir)
1704
+ zinfo.header_offset = self.fp.tell()
1705
+
1706
+ self._writecheck(zinfo)
1707
+ self._didModify = True
1708
+
1709
+ self.fp.write(zinfo.FileHeader(zip64))
1710
+
1711
+ self._writing = True
1712
+ return _ZipWriteFile(self, zinfo, zip64)
1713
+
1714
+ def extract(self, member, path=None, pwd=None):
1715
+ """Extract a member from the archive to the current working directory,
1716
+ using its full name. Its file information is extracted as accurately
1717
+ as possible. `member' may be a filename or a ZipInfo object. You can
1718
+ specify a different directory using `path'. You can specify the
1719
+ password to decrypt the file using 'pwd'.
1720
+ """
1721
+ if path is None:
1722
+ path = os.getcwd()
1723
+ else:
1724
+ path = os.fspath(path)
1725
+
1726
+ return self._extract_member(member, path, pwd)
1727
+
1728
+ def extractall(self, path=None, members=None, pwd=None):
1729
+ """Extract all members from the archive to the current working
1730
+ directory. `path' specifies a different directory to extract to.
1731
+ `members' is optional and must be a subset of the list returned
1732
+ by namelist(). You can specify the password to decrypt all files
1733
+ using 'pwd'.
1734
+ """
1735
+ if members is None:
1736
+ members = self.namelist()
1737
+
1738
+ if path is None:
1739
+ path = os.getcwd()
1740
+ else:
1741
+ path = os.fspath(path)
1742
+
1743
+ for zipinfo in members:
1744
+ self._extract_member(zipinfo, path, pwd)
1745
+
1746
+ @classmethod
1747
+ def _sanitize_windows_name(cls, arcname, pathsep):
1748
+ """Replace bad characters and remove trailing dots from parts."""
1749
+ table = cls._windows_illegal_name_trans_table
1750
+ if not table:
1751
+ illegal = ':<>|"?*'
1752
+ table = str.maketrans(illegal, '_' * len(illegal))
1753
+ cls._windows_illegal_name_trans_table = table
1754
+ arcname = arcname.translate(table)
1755
+ # remove trailing dots and spaces
1756
+ arcname = (x.rstrip(' .') for x in arcname.split(pathsep))
1757
+ # rejoin, removing empty parts.
1758
+ arcname = pathsep.join(x for x in arcname if x)
1759
+ return arcname
1760
+
1761
+ def _extract_member(self, member, targetpath, pwd):
1762
+ """Extract the ZipInfo object 'member' to a physical
1763
+ file on the path targetpath.
1764
+ """
1765
+ if not isinstance(member, ZipInfo):
1766
+ member = self.getinfo(member)
1767
+
1768
+ # build the destination pathname, replacing
1769
+ # forward slashes to platform specific separators.
1770
+ arcname = member.filename.replace('/', os.path.sep)
1771
+
1772
+ if os.path.altsep:
1773
+ arcname = arcname.replace(os.path.altsep, os.path.sep)
1774
+ # interpret absolute pathname as relative, remove drive letter or
1775
+ # UNC path, redundant separators, "." and ".." components.
1776
+ arcname = os.path.splitdrive(arcname)[1]
1777
+ invalid_path_parts = ('', os.path.curdir, os.path.pardir)
1778
+ arcname = os.path.sep.join(x for x in arcname.split(os.path.sep)
1779
+ if x not in invalid_path_parts)
1780
+ if os.path.sep == '\\':
1781
+ # filter illegal characters on Windows
1782
+ arcname = self._sanitize_windows_name(arcname, os.path.sep)
1783
+
1784
+ if not arcname and not member.is_dir():
1785
+ raise ValueError("Empty filename.")
1786
+
1787
+ targetpath = os.path.join(targetpath, arcname)
1788
+ targetpath = os.path.normpath(targetpath)
1789
+
1790
+ # Create all upper directories if necessary.
1791
+ upperdirs = os.path.dirname(targetpath)
1792
+ if upperdirs and not os.path.exists(upperdirs):
1793
+ os.makedirs(upperdirs)
1794
+
1795
+ if member.is_dir():
1796
+ if not os.path.isdir(targetpath):
1797
+ os.mkdir(targetpath)
1798
+ return targetpath
1799
+
1800
+ with self.open(member, pwd=pwd) as source, \
1801
+ open(targetpath, "wb") as target:
1802
+ shutil.copyfileobj(source, target)
1803
+
1804
+ return targetpath
1805
+
1806
+ def _writecheck(self, zinfo):
1807
+ """Check for errors before writing a file to the archive."""
1808
+ if zinfo.filename in self.NameToInfo:
1809
+ import warnings
1810
+ warnings.warn('Duplicate name: %r' % zinfo.filename, stacklevel=3)
1811
+ if self.mode not in ('w', 'x', 'a'):
1812
+ raise ValueError("write() requires mode 'w', 'x', or 'a'")
1813
+ if not self.fp:
1814
+ raise ValueError(
1815
+ "Attempt to write ZIP archive that was already closed")
1816
+ _check_compression(zinfo.compress_type)
1817
+ if not self._allowZip64:
1818
+ requires_zip64 = None
1819
+ if len(self.filelist) >= ZIP_FILECOUNT_LIMIT:
1820
+ requires_zip64 = "Files count"
1821
+ elif zinfo.file_size > ZIP64_LIMIT:
1822
+ requires_zip64 = "Filesize"
1823
+ elif zinfo.header_offset > ZIP64_LIMIT:
1824
+ requires_zip64 = "Zipfile size"
1825
+ if requires_zip64:
1826
+ raise LargeZipFile(requires_zip64 +
1827
+ " would require ZIP64 extensions")
1828
+
1829
+ def write(self, filename, arcname=None,
1830
+ compress_type=None, compresslevel=None):
1831
+ """Put the bytes from filename into the archive under the name
1832
+ arcname."""
1833
+ if not self.fp:
1834
+ raise ValueError(
1835
+ "Attempt to write to ZIP archive that was already closed")
1836
+ if self._writing:
1837
+ raise ValueError(
1838
+ "Can't write to ZIP archive while an open writing handle exists"
1839
+ )
1840
+
1841
+ zinfo = ZipInfo.from_file(filename, arcname,
1842
+ strict_timestamps=self._strict_timestamps)
1843
+
1844
+ if zinfo.is_dir():
1845
+ zinfo.compress_size = 0
1846
+ zinfo.CRC = 0
1847
+ self.mkdir(zinfo)
1848
+ else:
1849
+ if compress_type is not None:
1850
+ zinfo.compress_type = compress_type
1851
+ else:
1852
+ zinfo.compress_type = self.compression
1853
+
1854
+ if compresslevel is not None:
1855
+ zinfo._compresslevel = compresslevel
1856
+ else:
1857
+ zinfo._compresslevel = self.compresslevel
1858
+
1859
+ with open(filename, "rb") as src, self.open(zinfo, 'w') as dest:
1860
+ shutil.copyfileobj(src, dest, 1024*8)
1861
+
1862
+ def writestr(self, zinfo_or_arcname, data,
1863
+ compress_type=None, compresslevel=None):
1864
+ """Write a file into the archive. The contents is 'data', which
1865
+ may be either a 'str' or a 'bytes' instance; if it is a 'str',
1866
+ it is encoded as UTF-8 first.
1867
+ 'zinfo_or_arcname' is either a ZipInfo instance or
1868
+ the name of the file in the archive."""
1869
+ if isinstance(data, str):
1870
+ data = data.encode("utf-8")
1871
+ if not isinstance(zinfo_or_arcname, ZipInfo):
1872
+ zinfo = ZipInfo(filename=zinfo_or_arcname,
1873
+ date_time=time.localtime(time.time())[:6])
1874
+ zinfo.compress_type = self.compression
1875
+ zinfo._compresslevel = self.compresslevel
1876
+ if zinfo.filename.endswith('/'):
1877
+ zinfo.external_attr = 0o40775 << 16 # drwxrwxr-x
1878
+ zinfo.external_attr |= 0x10 # MS-DOS directory flag
1879
+ else:
1880
+ zinfo.external_attr = 0o600 << 16 # ?rw-------
1881
+ else:
1882
+ zinfo = zinfo_or_arcname
1883
+
1884
+ if not self.fp:
1885
+ raise ValueError(
1886
+ "Attempt to write to ZIP archive that was already closed")
1887
+ if self._writing:
1888
+ raise ValueError(
1889
+ "Can't write to ZIP archive while an open writing handle exists."
1890
+ )
1891
+
1892
+ if compress_type is not None:
1893
+ zinfo.compress_type = compress_type
1894
+
1895
+ if compresslevel is not None:
1896
+ zinfo._compresslevel = compresslevel
1897
+
1898
+ zinfo.file_size = len(data) # Uncompressed size
1899
+ with self._lock:
1900
+ with self.open(zinfo, mode='w') as dest:
1901
+ dest.write(data)
1902
+
1903
+ def mkdir(self, zinfo_or_directory_name, mode=511):
1904
+ """Creates a directory inside the zip archive."""
1905
+ if isinstance(zinfo_or_directory_name, ZipInfo):
1906
+ zinfo = zinfo_or_directory_name
1907
+ if not zinfo.is_dir():
1908
+ raise ValueError("The given ZipInfo does not describe a directory")
1909
+ elif isinstance(zinfo_or_directory_name, str):
1910
+ directory_name = zinfo_or_directory_name
1911
+ if not directory_name.endswith("/"):
1912
+ directory_name += "/"
1913
+ zinfo = ZipInfo(directory_name)
1914
+ zinfo.compress_size = 0
1915
+ zinfo.CRC = 0
1916
+ zinfo.external_attr = ((0o40000 | mode) & 0xFFFF) << 16
1917
+ zinfo.file_size = 0
1918
+ zinfo.external_attr |= 0x10
1919
+ else:
1920
+ raise TypeError("Expected type str or ZipInfo")
1921
+
1922
+ with self._lock:
1923
+ if self._seekable:
1924
+ self.fp.seek(self.start_dir)
1925
+ zinfo.header_offset = self.fp.tell() # Start of header bytes
1926
+ if zinfo.compress_type == ZIP_LZMA:
1927
+ # Compressed data includes an end-of-stream (EOS) marker
1928
+ zinfo.flag_bits |= _MASK_COMPRESS_OPTION_1
1929
+
1930
+ self._writecheck(zinfo)
1931
+ self._didModify = True
1932
+
1933
+ self.filelist.append(zinfo)
1934
+ self.NameToInfo[zinfo.filename] = zinfo
1935
+ self.fp.write(zinfo.FileHeader(False))
1936
+ self.start_dir = self.fp.tell()
1937
+
1938
+ def __del__(self):
1939
+ """Call the "close()" method in case the user forgot."""
1940
+ self.close()
1941
+
1942
+ def close(self):
1943
+ """Close the file, and for mode 'w', 'x' and 'a' write the ending
1944
+ records."""
1945
+ if self.fp is None:
1946
+ return
1947
+
1948
+ if self._writing:
1949
+ raise ValueError("Can't close the ZIP file while there is "
1950
+ "an open writing handle on it. "
1951
+ "Close the writing handle before closing the zip.")
1952
+
1953
+ try:
1954
+ if self.mode in ('w', 'x', 'a') and self._didModify: # write ending records
1955
+ with self._lock:
1956
+ if self._seekable:
1957
+ self.fp.seek(self.start_dir)
1958
+ self._write_end_record()
1959
+ finally:
1960
+ fp = self.fp
1961
+ self.fp = None
1962
+ self._fpclose(fp)
1963
+
1964
+ def _write_end_record(self):
1965
+ for zinfo in self.filelist: # write central directory
1966
+ dt = zinfo.date_time
1967
+ dosdate = (dt[0] - 1980) << 9 | dt[1] << 5 | dt[2]
1968
+ dostime = dt[3] << 11 | dt[4] << 5 | (dt[5] // 2)
1969
+ extra = []
1970
+ if zinfo.file_size > ZIP64_LIMIT \
1971
+ or zinfo.compress_size > ZIP64_LIMIT:
1972
+ extra.append(zinfo.file_size)
1973
+ extra.append(zinfo.compress_size)
1974
+ file_size = 0xffffffff
1975
+ compress_size = 0xffffffff
1976
+ else:
1977
+ file_size = zinfo.file_size
1978
+ compress_size = zinfo.compress_size
1979
+
1980
+ if zinfo.header_offset > ZIP64_LIMIT:
1981
+ extra.append(zinfo.header_offset)
1982
+ header_offset = 0xffffffff
1983
+ else:
1984
+ header_offset = zinfo.header_offset
1985
+
1986
+ extra_data = zinfo.extra
1987
+ min_version = 0
1988
+ if extra:
1989
+ # Append a ZIP64 field to the extra's
1990
+ extra_data = _strip_extra(extra_data, (1,))
1991
+ extra_data = struct.pack(
1992
+ '<HH' + 'Q'*len(extra),
1993
+ 1, 8*len(extra), *extra) + extra_data
1994
+
1995
+ min_version = ZIP64_VERSION
1996
+
1997
+ if zinfo.compress_type == ZIP_BZIP2:
1998
+ min_version = max(BZIP2_VERSION, min_version)
1999
+ elif zinfo.compress_type == ZIP_LZMA:
2000
+ min_version = max(LZMA_VERSION, min_version)
2001
+
2002
+ extract_version = max(min_version, zinfo.extract_version)
2003
+ create_version = max(min_version, zinfo.create_version)
2004
+ filename, flag_bits = zinfo._encodeFilenameFlags()
2005
+ centdir = struct.pack(structCentralDir,
2006
+ stringCentralDir, create_version,
2007
+ zinfo.create_system, extract_version, zinfo.reserved,
2008
+ flag_bits, zinfo.compress_type, dostime, dosdate,
2009
+ zinfo.CRC, compress_size, file_size,
2010
+ len(filename), len(extra_data), len(zinfo.comment),
2011
+ 0, zinfo.internal_attr, zinfo.external_attr,
2012
+ header_offset)
2013
+ self.fp.write(centdir)
2014
+ self.fp.write(filename)
2015
+ self.fp.write(extra_data)
2016
+ self.fp.write(zinfo.comment)
2017
+
2018
+ pos2 = self.fp.tell()
2019
+ # Write end-of-zip-archive record
2020
+ centDirCount = len(self.filelist)
2021
+ centDirSize = pos2 - self.start_dir
2022
+ centDirOffset = self.start_dir
2023
+ requires_zip64 = None
2024
+ if centDirCount > ZIP_FILECOUNT_LIMIT:
2025
+ requires_zip64 = "Files count"
2026
+ elif centDirOffset > ZIP64_LIMIT:
2027
+ requires_zip64 = "Central directory offset"
2028
+ elif centDirSize > ZIP64_LIMIT:
2029
+ requires_zip64 = "Central directory size"
2030
+ if requires_zip64:
2031
+ # Need to write the ZIP64 end-of-archive records
2032
+ if not self._allowZip64:
2033
+ raise LargeZipFile(requires_zip64 +
2034
+ " would require ZIP64 extensions")
2035
+ zip64endrec = struct.pack(
2036
+ structEndArchive64, stringEndArchive64,
2037
+ 44, 45, 45, 0, 0, centDirCount, centDirCount,
2038
+ centDirSize, centDirOffset)
2039
+ self.fp.write(zip64endrec)
2040
+
2041
+ zip64locrec = struct.pack(
2042
+ structEndArchive64Locator,
2043
+ stringEndArchive64Locator, 0, pos2, 1)
2044
+ self.fp.write(zip64locrec)
2045
+ centDirCount = min(centDirCount, 0xFFFF)
2046
+ centDirSize = min(centDirSize, 0xFFFFFFFF)
2047
+ centDirOffset = min(centDirOffset, 0xFFFFFFFF)
2048
+
2049
+ endrec = struct.pack(structEndArchive, stringEndArchive,
2050
+ 0, 0, centDirCount, centDirCount,
2051
+ centDirSize, centDirOffset, len(self._comment))
2052
+ self.fp.write(endrec)
2053
+ self.fp.write(self._comment)
2054
+ if self.mode == "a":
2055
+ self.fp.truncate()
2056
+ self.fp.flush()
2057
+
2058
+ def _fpclose(self, fp):
2059
+ assert self._fileRefCnt > 0
2060
+ self._fileRefCnt -= 1
2061
+ if not self._fileRefCnt and not self._filePassed:
2062
+ fp.close()
2063
+
2064
+
2065
+ class PyZipFile(ZipFile):
2066
+ """Class to create ZIP archives with Python library files and packages."""
2067
+
2068
+ def __init__(self, file, mode="r", compression=ZIP_STORED,
2069
+ allowZip64=True, optimize=-1):
2070
+ ZipFile.__init__(self, file, mode=mode, compression=compression,
2071
+ allowZip64=allowZip64)
2072
+ self._optimize = optimize
2073
+
2074
+ def writepy(self, pathname, basename="", filterfunc=None):
2075
+ """Add all files from "pathname" to the ZIP archive.
2076
+
2077
+ If pathname is a package directory, search the directory and
2078
+ all package subdirectories recursively for all *.py and enter
2079
+ the modules into the archive. If pathname is a plain
2080
+ directory, listdir *.py and enter all modules. Else, pathname
2081
+ must be a Python *.py file and the module will be put into the
2082
+ archive. Added modules are always module.pyc.
2083
+ This method will compile the module.py into module.pyc if
2084
+ necessary.
2085
+ If filterfunc(pathname) is given, it is called with every argument.
2086
+ When it is False, the file or directory is skipped.
2087
+ """
2088
+ pathname = os.fspath(pathname)
2089
+ if filterfunc and not filterfunc(pathname):
2090
+ if self.debug:
2091
+ label = 'path' if os.path.isdir(pathname) else 'file'
2092
+ print('%s %r skipped by filterfunc' % (label, pathname))
2093
+ return
2094
+ dir, name = os.path.split(pathname)
2095
+ if os.path.isdir(pathname):
2096
+ initname = os.path.join(pathname, "__init__.py")
2097
+ if os.path.isfile(initname):
2098
+ # This is a package directory, add it
2099
+ if basename:
2100
+ basename = "%s/%s" % (basename, name)
2101
+ else:
2102
+ basename = name
2103
+ if self.debug:
2104
+ print("Adding package in", pathname, "as", basename)
2105
+ fname, arcname = self._get_codename(initname[0:-3], basename)
2106
+ if self.debug:
2107
+ print("Adding", arcname)
2108
+ self.write(fname, arcname)
2109
+ dirlist = sorted(os.listdir(pathname))
2110
+ dirlist.remove("__init__.py")
2111
+ # Add all *.py files and package subdirectories
2112
+ for filename in dirlist:
2113
+ path = os.path.join(pathname, filename)
2114
+ root, ext = os.path.splitext(filename)
2115
+ if os.path.isdir(path):
2116
+ if os.path.isfile(os.path.join(path, "__init__.py")):
2117
+ # This is a package directory, add it
2118
+ self.writepy(path, basename,
2119
+ filterfunc=filterfunc) # Recursive call
2120
+ elif ext == ".py":
2121
+ if filterfunc and not filterfunc(path):
2122
+ if self.debug:
2123
+ print('file %r skipped by filterfunc' % path)
2124
+ continue
2125
+ fname, arcname = self._get_codename(path[0:-3],
2126
+ basename)
2127
+ if self.debug:
2128
+ print("Adding", arcname)
2129
+ self.write(fname, arcname)
2130
+ else:
2131
+ # This is NOT a package directory, add its files at top level
2132
+ if self.debug:
2133
+ print("Adding files from directory", pathname)
2134
+ for filename in sorted(os.listdir(pathname)):
2135
+ path = os.path.join(pathname, filename)
2136
+ root, ext = os.path.splitext(filename)
2137
+ if ext == ".py":
2138
+ if filterfunc and not filterfunc(path):
2139
+ if self.debug:
2140
+ print('file %r skipped by filterfunc' % path)
2141
+ continue
2142
+ fname, arcname = self._get_codename(path[0:-3],
2143
+ basename)
2144
+ if self.debug:
2145
+ print("Adding", arcname)
2146
+ self.write(fname, arcname)
2147
+ else:
2148
+ if pathname[-3:] != ".py":
2149
+ raise RuntimeError(
2150
+ 'Files added with writepy() must end with ".py"')
2151
+ fname, arcname = self._get_codename(pathname[0:-3], basename)
2152
+ if self.debug:
2153
+ print("Adding file", arcname)
2154
+ self.write(fname, arcname)
2155
+
2156
+ def _get_codename(self, pathname, basename):
2157
+ """Return (filename, archivename) for the path.
2158
+
2159
+ Given a module name path, return the correct file path and
2160
+ archive name, compiling if necessary. For example, given
2161
+ /python/lib/string, return (/python/lib/string.pyc, string).
2162
+ """
2163
+ def _compile(file, optimize=-1):
2164
+ import py_compile
2165
+ if self.debug:
2166
+ print("Compiling", file)
2167
+ try:
2168
+ py_compile.compile(file, doraise=True, optimize=optimize)
2169
+ except py_compile.PyCompileError as err:
2170
+ print(err.msg)
2171
+ return False
2172
+ return True
2173
+
2174
+ file_py = pathname + ".py"
2175
+ file_pyc = pathname + ".pyc"
2176
+ pycache_opt0 = importlib.util.cache_from_source(file_py, optimization='')
2177
+ pycache_opt1 = importlib.util.cache_from_source(file_py, optimization=1)
2178
+ pycache_opt2 = importlib.util.cache_from_source(file_py, optimization=2)
2179
+ if self._optimize == -1:
2180
+ # legacy mode: use whatever file is present
2181
+ if (os.path.isfile(file_pyc) and
2182
+ os.stat(file_pyc).st_mtime >= os.stat(file_py).st_mtime):
2183
+ # Use .pyc file.
2184
+ arcname = fname = file_pyc
2185
+ elif (os.path.isfile(pycache_opt0) and
2186
+ os.stat(pycache_opt0).st_mtime >= os.stat(file_py).st_mtime):
2187
+ # Use the __pycache__/*.pyc file, but write it to the legacy pyc
2188
+ # file name in the archive.
2189
+ fname = pycache_opt0
2190
+ arcname = file_pyc
2191
+ elif (os.path.isfile(pycache_opt1) and
2192
+ os.stat(pycache_opt1).st_mtime >= os.stat(file_py).st_mtime):
2193
+ # Use the __pycache__/*.pyc file, but write it to the legacy pyc
2194
+ # file name in the archive.
2195
+ fname = pycache_opt1
2196
+ arcname = file_pyc
2197
+ elif (os.path.isfile(pycache_opt2) and
2198
+ os.stat(pycache_opt2).st_mtime >= os.stat(file_py).st_mtime):
2199
+ # Use the __pycache__/*.pyc file, but write it to the legacy pyc
2200
+ # file name in the archive.
2201
+ fname = pycache_opt2
2202
+ arcname = file_pyc
2203
+ else:
2204
+ # Compile py into PEP 3147 pyc file.
2205
+ if _compile(file_py):
2206
+ if sys.flags.optimize == 0:
2207
+ fname = pycache_opt0
2208
+ elif sys.flags.optimize == 1:
2209
+ fname = pycache_opt1
2210
+ else:
2211
+ fname = pycache_opt2
2212
+ arcname = file_pyc
2213
+ else:
2214
+ fname = arcname = file_py
2215
+ else:
2216
+ # new mode: use given optimization level
2217
+ if self._optimize == 0:
2218
+ fname = pycache_opt0
2219
+ arcname = file_pyc
2220
+ else:
2221
+ arcname = file_pyc
2222
+ if self._optimize == 1:
2223
+ fname = pycache_opt1
2224
+ elif self._optimize == 2:
2225
+ fname = pycache_opt2
2226
+ else:
2227
+ msg = "invalid value for 'optimize': {!r}".format(self._optimize)
2228
+ raise ValueError(msg)
2229
+ if not (os.path.isfile(fname) and
2230
+ os.stat(fname).st_mtime >= os.stat(file_py).st_mtime):
2231
+ if not _compile(file_py, optimize=self._optimize):
2232
+ fname = arcname = file_py
2233
+ archivename = os.path.split(arcname)[1]
2234
+ if basename:
2235
+ archivename = "%s/%s" % (basename, archivename)
2236
+ return (fname, archivename)
2237
+
2238
+
2239
+ def main(args=None):
2240
+ import argparse
2241
+
2242
+ description = 'A simple command-line interface for zipfile module.'
2243
+ parser = argparse.ArgumentParser(description=description)
2244
+ group = parser.add_mutually_exclusive_group(required=True)
2245
+ group.add_argument('-l', '--list', metavar='<zipfile>',
2246
+ help='Show listing of a zipfile')
2247
+ group.add_argument('-e', '--extract', nargs=2,
2248
+ metavar=('<zipfile>', '<output_dir>'),
2249
+ help='Extract zipfile into target dir')
2250
+ group.add_argument('-c', '--create', nargs='+',
2251
+ metavar=('<name>', '<file>'),
2252
+ help='Create zipfile from sources')
2253
+ group.add_argument('-t', '--test', metavar='<zipfile>',
2254
+ help='Test if a zipfile is valid')
2255
+ parser.add_argument('--metadata-encoding', metavar='<encoding>',
2256
+ help='Specify encoding of member names for -l, -e and -t')
2257
+ args = parser.parse_args(args)
2258
+
2259
+ encoding = args.metadata_encoding
2260
+
2261
+ if args.test is not None:
2262
+ src = args.test
2263
+ with ZipFile(src, 'r', metadata_encoding=encoding) as zf:
2264
+ badfile = zf.testzip()
2265
+ if badfile:
2266
+ print("The following enclosed file is corrupted: {!r}".format(badfile))
2267
+ print("Done testing")
2268
+
2269
+ elif args.list is not None:
2270
+ src = args.list
2271
+ with ZipFile(src, 'r', metadata_encoding=encoding) as zf:
2272
+ zf.printdir()
2273
+
2274
+ elif args.extract is not None:
2275
+ src, curdir = args.extract
2276
+ with ZipFile(src, 'r', metadata_encoding=encoding) as zf:
2277
+ zf.extractall(curdir)
2278
+
2279
+ elif args.create is not None:
2280
+ if encoding:
2281
+ print("Non-conforming encodings not supported with -c.",
2282
+ file=sys.stderr)
2283
+ sys.exit(1)
2284
+
2285
+ zip_name = args.create.pop(0)
2286
+ files = args.create
2287
+
2288
+ def addToZip(zf, path, zippath):
2289
+ if os.path.isfile(path):
2290
+ zf.write(path, zippath, ZIP_DEFLATED)
2291
+ elif os.path.isdir(path):
2292
+ if zippath:
2293
+ zf.write(path, zippath)
2294
+ for nm in sorted(os.listdir(path)):
2295
+ addToZip(zf,
2296
+ os.path.join(path, nm), os.path.join(zippath, nm))
2297
+ # else: ignore
2298
+
2299
+ with ZipFile(zip_name, 'w') as zf:
2300
+ for path in files:
2301
+ zippath = os.path.basename(path)
2302
+ if not zippath:
2303
+ zippath = os.path.basename(os.path.dirname(path))
2304
+ if zippath in ('', os.curdir, os.pardir):
2305
+ zippath = ''
2306
+ addToZip(zf, path, zippath)
2307
+
2308
+
2309
+ from ._path import ( # noqa: E402
2310
+ Path,
2311
+
2312
+ # used privately for tests
2313
+ CompleteDirs, # noqa: F401
2314
+ )