@pairling/runtime-darwin-x64 0.0.0 → 0.2.0

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 (1238) hide show
  1. package/bin/pairling-connectd +0 -0
  2. package/manifest.json +18 -0
  3. package/package.json +2 -2
  4. package/python/bin/2to3-3.12 +7 -0
  5. package/python/bin/idle3.12 +7 -0
  6. package/python/bin/pip +8 -0
  7. package/python/bin/pip3 +8 -0
  8. package/python/bin/pip3.12 +8 -0
  9. package/python/bin/pydoc3.12 +7 -0
  10. package/python/bin/python3 +0 -0
  11. package/python/bin/python3.12 +0 -0
  12. package/python/bin/python3.12-config +76 -0
  13. package/python/include/python3.12/Python.h +109 -0
  14. package/python/include/python3.12/abstract.h +899 -0
  15. package/python/include/python3.12/bltinmodule.h +14 -0
  16. package/python/include/python3.12/boolobject.h +42 -0
  17. package/python/include/python3.12/bytearrayobject.h +44 -0
  18. package/python/include/python3.12/bytesobject.h +69 -0
  19. package/python/include/python3.12/ceval.h +168 -0
  20. package/python/include/python3.12/codecs.h +248 -0
  21. package/python/include/python3.12/compile.h +22 -0
  22. package/python/include/python3.12/complexobject.h +30 -0
  23. package/python/include/python3.12/cpython/abstract.h +206 -0
  24. package/python/include/python3.12/cpython/bytearrayobject.h +34 -0
  25. package/python/include/python3.12/cpython/bytesobject.h +133 -0
  26. package/python/include/python3.12/cpython/cellobject.h +44 -0
  27. package/python/include/python3.12/cpython/ceval.h +35 -0
  28. package/python/include/python3.12/cpython/classobject.h +71 -0
  29. package/python/include/python3.12/cpython/code.h +389 -0
  30. package/python/include/python3.12/cpython/compile.h +69 -0
  31. package/python/include/python3.12/cpython/complexobject.h +44 -0
  32. package/python/include/python3.12/cpython/context.h +78 -0
  33. package/python/include/python3.12/cpython/descrobject.h +64 -0
  34. package/python/include/python3.12/cpython/dictobject.h +118 -0
  35. package/python/include/python3.12/cpython/fileobject.h +19 -0
  36. package/python/include/python3.12/cpython/fileutils.h +8 -0
  37. package/python/include/python3.12/cpython/floatobject.h +27 -0
  38. package/python/include/python3.12/cpython/frameobject.h +29 -0
  39. package/python/include/python3.12/cpython/funcobject.h +190 -0
  40. package/python/include/python3.12/cpython/genobject.h +89 -0
  41. package/python/include/python3.12/cpython/import.h +46 -0
  42. package/python/include/python3.12/cpython/initconfig.h +256 -0
  43. package/python/include/python3.12/cpython/interpreteridobject.h +11 -0
  44. package/python/include/python3.12/cpython/listobject.h +47 -0
  45. package/python/include/python3.12/cpython/longintrepr.h +133 -0
  46. package/python/include/python3.12/cpython/longobject.h +100 -0
  47. package/python/include/python3.12/cpython/memoryobject.h +52 -0
  48. package/python/include/python3.12/cpython/methodobject.h +66 -0
  49. package/python/include/python3.12/cpython/modsupport.h +109 -0
  50. package/python/include/python3.12/cpython/object.h +575 -0
  51. package/python/include/python3.12/cpython/objimpl.h +95 -0
  52. package/python/include/python3.12/cpython/odictobject.h +43 -0
  53. package/python/include/python3.12/cpython/picklebufobject.h +31 -0
  54. package/python/include/python3.12/cpython/pthread_stubs.h +88 -0
  55. package/python/include/python3.12/cpython/pyctype.h +39 -0
  56. package/python/include/python3.12/cpython/pydebug.h +38 -0
  57. package/python/include/python3.12/cpython/pyerrors.h +178 -0
  58. package/python/include/python3.12/cpython/pyfpe.h +15 -0
  59. package/python/include/python3.12/cpython/pyframe.h +35 -0
  60. package/python/include/python3.12/cpython/pylifecycle.h +111 -0
  61. package/python/include/python3.12/cpython/pymem.h +98 -0
  62. package/python/include/python3.12/cpython/pystate.h +456 -0
  63. package/python/include/python3.12/cpython/pythonrun.h +121 -0
  64. package/python/include/python3.12/cpython/pythread.h +42 -0
  65. package/python/include/python3.12/cpython/pytime.h +331 -0
  66. package/python/include/python3.12/cpython/setobject.h +72 -0
  67. package/python/include/python3.12/cpython/sysmodule.h +16 -0
  68. package/python/include/python3.12/cpython/traceback.h +16 -0
  69. package/python/include/python3.12/cpython/tupleobject.h +39 -0
  70. package/python/include/python3.12/cpython/unicodeobject.h +976 -0
  71. package/python/include/python3.12/cpython/warnings.h +20 -0
  72. package/python/include/python3.12/cpython/weakrefobject.h +56 -0
  73. package/python/include/python3.12/datetime.h +267 -0
  74. package/python/include/python3.12/descrobject.h +100 -0
  75. package/python/include/python3.12/dictobject.h +97 -0
  76. package/python/include/python3.12/dynamic_annotations.h +499 -0
  77. package/python/include/python3.12/enumobject.h +17 -0
  78. package/python/include/python3.12/errcode.h +38 -0
  79. package/python/include/python3.12/exports.h +36 -0
  80. package/python/include/python3.12/fileobject.h +49 -0
  81. package/python/include/python3.12/fileutils.h +26 -0
  82. package/python/include/python3.12/floatobject.h +54 -0
  83. package/python/include/python3.12/frameobject.h +20 -0
  84. package/python/include/python3.12/genericaliasobject.h +14 -0
  85. package/python/include/python3.12/import.h +98 -0
  86. package/python/include/python3.12/internal/pycore_abstract.h +25 -0
  87. package/python/include/python3.12/internal/pycore_asdl.h +112 -0
  88. package/python/include/python3.12/internal/pycore_ast.h +922 -0
  89. package/python/include/python3.12/internal/pycore_ast_state.h +265 -0
  90. package/python/include/python3.12/internal/pycore_atexit.h +57 -0
  91. package/python/include/python3.12/internal/pycore_atomic.h +557 -0
  92. package/python/include/python3.12/internal/pycore_atomic_funcs.h +94 -0
  93. package/python/include/python3.12/internal/pycore_bitutils.h +186 -0
  94. package/python/include/python3.12/internal/pycore_blocks_output_buffer.h +317 -0
  95. package/python/include/python3.12/internal/pycore_bytes_methods.h +73 -0
  96. package/python/include/python3.12/internal/pycore_bytesobject.h +47 -0
  97. package/python/include/python3.12/internal/pycore_call.h +133 -0
  98. package/python/include/python3.12/internal/pycore_ceval.h +164 -0
  99. package/python/include/python3.12/internal/pycore_ceval_state.h +103 -0
  100. package/python/include/python3.12/internal/pycore_code.h +496 -0
  101. package/python/include/python3.12/internal/pycore_compile.h +118 -0
  102. package/python/include/python3.12/internal/pycore_condvar.h +99 -0
  103. package/python/include/python3.12/internal/pycore_context.h +71 -0
  104. package/python/include/python3.12/internal/pycore_descrobject.h +26 -0
  105. package/python/include/python3.12/internal/pycore_dict.h +199 -0
  106. package/python/include/python3.12/internal/pycore_dict_state.h +50 -0
  107. package/python/include/python3.12/internal/pycore_dtoa.h +69 -0
  108. package/python/include/python3.12/internal/pycore_emscripten_signal.h +25 -0
  109. package/python/include/python3.12/internal/pycore_exceptions.h +37 -0
  110. package/python/include/python3.12/internal/pycore_faulthandler.h +99 -0
  111. package/python/include/python3.12/internal/pycore_fileutils.h +292 -0
  112. package/python/include/python3.12/internal/pycore_fileutils_windows.h +98 -0
  113. package/python/include/python3.12/internal/pycore_floatobject.h +71 -0
  114. package/python/include/python3.12/internal/pycore_flowgraph.h +120 -0
  115. package/python/include/python3.12/internal/pycore_format.h +27 -0
  116. package/python/include/python3.12/internal/pycore_frame.h +283 -0
  117. package/python/include/python3.12/internal/pycore_function.h +26 -0
  118. package/python/include/python3.12/internal/pycore_gc.h +211 -0
  119. package/python/include/python3.12/internal/pycore_genobject.h +49 -0
  120. package/python/include/python3.12/internal/pycore_getopt.h +22 -0
  121. package/python/include/python3.12/internal/pycore_gil.h +50 -0
  122. package/python/include/python3.12/internal/pycore_global_objects.h +105 -0
  123. package/python/include/python3.12/internal/pycore_global_objects_fini_generated.h +1517 -0
  124. package/python/include/python3.12/internal/pycore_global_strings.h +777 -0
  125. package/python/include/python3.12/internal/pycore_hamt.h +134 -0
  126. package/python/include/python3.12/internal/pycore_hashtable.h +149 -0
  127. package/python/include/python3.12/internal/pycore_import.h +183 -0
  128. package/python/include/python3.12/internal/pycore_initconfig.h +179 -0
  129. package/python/include/python3.12/internal/pycore_instruments.h +106 -0
  130. package/python/include/python3.12/internal/pycore_interp.h +275 -0
  131. package/python/include/python3.12/internal/pycore_intrinsics.h +32 -0
  132. package/python/include/python3.12/internal/pycore_list.h +83 -0
  133. package/python/include/python3.12/internal/pycore_long.h +258 -0
  134. package/python/include/python3.12/internal/pycore_memoryobject.h +18 -0
  135. package/python/include/python3.12/internal/pycore_moduleobject.h +45 -0
  136. package/python/include/python3.12/internal/pycore_namespace.h +20 -0
  137. package/python/include/python3.12/internal/pycore_object.h +455 -0
  138. package/python/include/python3.12/internal/pycore_object_state.h +42 -0
  139. package/python/include/python3.12/internal/pycore_obmalloc.h +700 -0
  140. package/python/include/python3.12/internal/pycore_obmalloc_init.h +73 -0
  141. package/python/include/python3.12/internal/pycore_opcode.h +587 -0
  142. package/python/include/python3.12/internal/pycore_opcode_utils.h +92 -0
  143. package/python/include/python3.12/internal/pycore_parser.h +66 -0
  144. package/python/include/python3.12/internal/pycore_pathconfig.h +24 -0
  145. package/python/include/python3.12/internal/pycore_pyarena.h +64 -0
  146. package/python/include/python3.12/internal/pycore_pyerrors.h +129 -0
  147. package/python/include/python3.12/internal/pycore_pyhash.h +40 -0
  148. package/python/include/python3.12/internal/pycore_pylifecycle.h +99 -0
  149. package/python/include/python3.12/internal/pycore_pymath.h +205 -0
  150. package/python/include/python3.12/internal/pycore_pymem.h +98 -0
  151. package/python/include/python3.12/internal/pycore_pymem_init.h +85 -0
  152. package/python/include/python3.12/internal/pycore_pystate.h +180 -0
  153. package/python/include/python3.12/internal/pycore_pythread.h +81 -0
  154. package/python/include/python3.12/internal/pycore_range.h +21 -0
  155. package/python/include/python3.12/internal/pycore_runtime.h +235 -0
  156. package/python/include/python3.12/internal/pycore_runtime_init.h +188 -0
  157. package/python/include/python3.12/internal/pycore_runtime_init_generated.h +1511 -0
  158. package/python/include/python3.12/internal/pycore_signal.h +98 -0
  159. package/python/include/python3.12/internal/pycore_sliceobject.h +22 -0
  160. package/python/include/python3.12/internal/pycore_strhex.h +36 -0
  161. package/python/include/python3.12/internal/pycore_structseq.h +39 -0
  162. package/python/include/python3.12/internal/pycore_symtable.h +160 -0
  163. package/python/include/python3.12/internal/pycore_sysmodule.h +34 -0
  164. package/python/include/python3.12/internal/pycore_time.h +25 -0
  165. package/python/include/python3.12/internal/pycore_token.h +108 -0
  166. package/python/include/python3.12/internal/pycore_traceback.h +101 -0
  167. package/python/include/python3.12/internal/pycore_tracemalloc.h +123 -0
  168. package/python/include/python3.12/internal/pycore_tuple.h +79 -0
  169. package/python/include/python3.12/internal/pycore_typeobject.h +151 -0
  170. package/python/include/python3.12/internal/pycore_typevarobject.h +24 -0
  171. package/python/include/python3.12/internal/pycore_ucnhash.h +34 -0
  172. package/python/include/python3.12/internal/pycore_unicodeobject.h +86 -0
  173. package/python/include/python3.12/internal/pycore_unicodeobject_generated.h +2832 -0
  174. package/python/include/python3.12/internal/pycore_unionobject.h +23 -0
  175. package/python/include/python3.12/internal/pycore_warnings.h +29 -0
  176. package/python/include/python3.12/interpreteridobject.h +17 -0
  177. package/python/include/python3.12/intrcheck.h +30 -0
  178. package/python/include/python3.12/iterobject.h +27 -0
  179. package/python/include/python3.12/listobject.h +52 -0
  180. package/python/include/python3.12/longobject.h +108 -0
  181. package/python/include/python3.12/marshal.h +31 -0
  182. package/python/include/python3.12/memoryobject.h +34 -0
  183. package/python/include/python3.12/methodobject.h +132 -0
  184. package/python/include/python3.12/modsupport.h +168 -0
  185. package/python/include/python3.12/moduleobject.h +119 -0
  186. package/python/include/python3.12/object.h +993 -0
  187. package/python/include/python3.12/objimpl.h +234 -0
  188. package/python/include/python3.12/opcode.h +271 -0
  189. package/python/include/python3.12/osdefs.h +51 -0
  190. package/python/include/python3.12/osmodule.h +17 -0
  191. package/python/include/python3.12/patchlevel.h +35 -0
  192. package/python/include/python3.12/py_curses.h +99 -0
  193. package/python/include/python3.12/pybuffer.h +145 -0
  194. package/python/include/python3.12/pycapsule.h +59 -0
  195. package/python/include/python3.12/pyconfig.h +1943 -0
  196. package/python/include/python3.12/pydtrace.h +59 -0
  197. package/python/include/python3.12/pyerrors.h +337 -0
  198. package/python/include/python3.12/pyexpat.h +62 -0
  199. package/python/include/python3.12/pyframe.h +26 -0
  200. package/python/include/python3.12/pyhash.h +144 -0
  201. package/python/include/python3.12/pylifecycle.h +78 -0
  202. package/python/include/python3.12/pymacconfig.h +99 -0
  203. package/python/include/python3.12/pymacro.h +172 -0
  204. package/python/include/python3.12/pymath.h +62 -0
  205. package/python/include/python3.12/pymem.h +104 -0
  206. package/python/include/python3.12/pyport.h +782 -0
  207. package/python/include/python3.12/pystate.h +132 -0
  208. package/python/include/python3.12/pystats.h +110 -0
  209. package/python/include/python3.12/pystrcmp.h +23 -0
  210. package/python/include/python3.12/pystrtod.h +46 -0
  211. package/python/include/python3.12/pythonrun.h +49 -0
  212. package/python/include/python3.12/pythread.h +135 -0
  213. package/python/include/python3.12/pytypedefs.h +30 -0
  214. package/python/include/python3.12/rangeobject.h +27 -0
  215. package/python/include/python3.12/setobject.h +49 -0
  216. package/python/include/python3.12/sliceobject.h +65 -0
  217. package/python/include/python3.12/structmember.h +56 -0
  218. package/python/include/python3.12/structseq.h +49 -0
  219. package/python/include/python3.12/sysmodule.h +54 -0
  220. package/python/include/python3.12/traceback.h +26 -0
  221. package/python/include/python3.12/tracemalloc.h +77 -0
  222. package/python/include/python3.12/tupleobject.h +46 -0
  223. package/python/include/python3.12/typeslots.h +88 -0
  224. package/python/include/python3.12/unicodeobject.h +1020 -0
  225. package/python/include/python3.12/warnings.h +45 -0
  226. package/python/include/python3.12/weakrefobject.h +42 -0
  227. package/python/lib/libpython3.12.dylib +0 -0
  228. package/python/lib/python3.12/LICENSE.txt +279 -0
  229. package/python/lib/python3.12/__future__.py +147 -0
  230. package/python/lib/python3.12/__hello__.py +16 -0
  231. package/python/lib/python3.12/__phello__/__init__.py +7 -0
  232. package/python/lib/python3.12/__phello__/spam.py +7 -0
  233. package/python/lib/python3.12/_aix_support.py +108 -0
  234. package/python/lib/python3.12/_collections_abc.py +1173 -0
  235. package/python/lib/python3.12/_compat_pickle.py +252 -0
  236. package/python/lib/python3.12/_compression.py +162 -0
  237. package/python/lib/python3.12/_markupbase.py +396 -0
  238. package/python/lib/python3.12/_osx_support.py +579 -0
  239. package/python/lib/python3.12/_py_abc.py +147 -0
  240. package/python/lib/python3.12/_pydatetime.py +2643 -0
  241. package/python/lib/python3.12/_pydecimal.py +6339 -0
  242. package/python/lib/python3.12/_pyio.py +2698 -0
  243. package/python/lib/python3.12/_pylong.py +329 -0
  244. package/python/lib/python3.12/_sitebuiltins.py +103 -0
  245. package/python/lib/python3.12/_strptime.py +664 -0
  246. package/python/lib/python3.12/_sysconfigdata__darwin_darwin.py +984 -0
  247. package/python/lib/python3.12/_threading_local.py +242 -0
  248. package/python/lib/python3.12/_weakrefset.py +205 -0
  249. package/python/lib/python3.12/abc.py +188 -0
  250. package/python/lib/python3.12/aifc.py +984 -0
  251. package/python/lib/python3.12/antigravity.py +17 -0
  252. package/python/lib/python3.12/argparse.py +2650 -0
  253. package/python/lib/python3.12/ast.py +1840 -0
  254. package/python/lib/python3.12/asyncio/__init__.py +47 -0
  255. package/python/lib/python3.12/asyncio/__main__.py +128 -0
  256. package/python/lib/python3.12/asyncio/base_events.py +2024 -0
  257. package/python/lib/python3.12/asyncio/base_futures.py +67 -0
  258. package/python/lib/python3.12/asyncio/base_subprocess.py +285 -0
  259. package/python/lib/python3.12/asyncio/base_tasks.py +94 -0
  260. package/python/lib/python3.12/asyncio/constants.py +41 -0
  261. package/python/lib/python3.12/asyncio/coroutines.py +109 -0
  262. package/python/lib/python3.12/asyncio/events.py +868 -0
  263. package/python/lib/python3.12/asyncio/exceptions.py +62 -0
  264. package/python/lib/python3.12/asyncio/format_helpers.py +76 -0
  265. package/python/lib/python3.12/asyncio/futures.py +430 -0
  266. package/python/lib/python3.12/asyncio/locks.py +586 -0
  267. package/python/lib/python3.12/asyncio/log.py +7 -0
  268. package/python/lib/python3.12/asyncio/mixins.py +21 -0
  269. package/python/lib/python3.12/asyncio/proactor_events.py +897 -0
  270. package/python/lib/python3.12/asyncio/protocols.py +216 -0
  271. package/python/lib/python3.12/asyncio/queues.py +244 -0
  272. package/python/lib/python3.12/asyncio/runners.py +216 -0
  273. package/python/lib/python3.12/asyncio/selector_events.py +1324 -0
  274. package/python/lib/python3.12/asyncio/sslproto.py +929 -0
  275. package/python/lib/python3.12/asyncio/staggered.py +174 -0
  276. package/python/lib/python3.12/asyncio/streams.py +770 -0
  277. package/python/lib/python3.12/asyncio/subprocess.py +229 -0
  278. package/python/lib/python3.12/asyncio/taskgroups.py +268 -0
  279. package/python/lib/python3.12/asyncio/tasks.py +1065 -0
  280. package/python/lib/python3.12/asyncio/threads.py +25 -0
  281. package/python/lib/python3.12/asyncio/timeouts.py +168 -0
  282. package/python/lib/python3.12/asyncio/transports.py +335 -0
  283. package/python/lib/python3.12/asyncio/trsock.py +98 -0
  284. package/python/lib/python3.12/asyncio/unix_events.py +1500 -0
  285. package/python/lib/python3.12/asyncio/windows_events.py +901 -0
  286. package/python/lib/python3.12/asyncio/windows_utils.py +173 -0
  287. package/python/lib/python3.12/base64.py +586 -0
  288. package/python/lib/python3.12/bdb.py +920 -0
  289. package/python/lib/python3.12/bisect.py +118 -0
  290. package/python/lib/python3.12/bz2.py +344 -0
  291. package/python/lib/python3.12/cProfile.py +195 -0
  292. package/python/lib/python3.12/calendar.py +808 -0
  293. package/python/lib/python3.12/cgi.py +1014 -0
  294. package/python/lib/python3.12/cgitb.py +332 -0
  295. package/python/lib/python3.12/chunk.py +173 -0
  296. package/python/lib/python3.12/cmd.py +401 -0
  297. package/python/lib/python3.12/code.py +324 -0
  298. package/python/lib/python3.12/codecs.py +1129 -0
  299. package/python/lib/python3.12/codeop.py +161 -0
  300. package/python/lib/python3.12/collections/__init__.py +1592 -0
  301. package/python/lib/python3.12/collections/abc.py +3 -0
  302. package/python/lib/python3.12/colorsys.py +166 -0
  303. package/python/lib/python3.12/compileall.py +469 -0
  304. package/python/lib/python3.12/concurrent/__init__.py +1 -0
  305. package/python/lib/python3.12/concurrent/futures/__init__.py +54 -0
  306. package/python/lib/python3.12/concurrent/futures/_base.py +654 -0
  307. package/python/lib/python3.12/concurrent/futures/process.py +876 -0
  308. package/python/lib/python3.12/concurrent/futures/thread.py +240 -0
  309. package/python/lib/python3.12/config-3.12-darwin/Makefile +3224 -0
  310. package/python/lib/python3.12/config-3.12-darwin/Setup +303 -0
  311. package/python/lib/python3.12/config-3.12-darwin/Setup.bootstrap +36 -0
  312. package/python/lib/python3.12/config-3.12-darwin/Setup.local +90 -0
  313. package/python/lib/python3.12/config-3.12-darwin/Setup.stdlib +183 -0
  314. package/python/lib/python3.12/config-3.12-darwin/config.c +246 -0
  315. package/python/lib/python3.12/config-3.12-darwin/config.c.in +71 -0
  316. package/python/lib/python3.12/config-3.12-darwin/install-sh +541 -0
  317. package/python/lib/python3.12/config-3.12-darwin/makesetup +353 -0
  318. package/python/lib/python3.12/config-3.12-darwin/python-config.py +76 -0
  319. package/python/lib/python3.12/config-3.12-darwin/python.o +0 -0
  320. package/python/lib/python3.12/configparser.py +1333 -0
  321. package/python/lib/python3.12/contextlib.py +800 -0
  322. package/python/lib/python3.12/contextvars.py +4 -0
  323. package/python/lib/python3.12/copy.py +292 -0
  324. package/python/lib/python3.12/copyreg.py +217 -0
  325. package/python/lib/python3.12/crypt.py +124 -0
  326. package/python/lib/python3.12/csv.py +451 -0
  327. package/python/lib/python3.12/ctypes/__init__.py +582 -0
  328. package/python/lib/python3.12/ctypes/_aix.py +327 -0
  329. package/python/lib/python3.12/ctypes/_endian.py +78 -0
  330. package/python/lib/python3.12/ctypes/macholib/README.ctypes +7 -0
  331. package/python/lib/python3.12/ctypes/macholib/__init__.py +9 -0
  332. package/python/lib/python3.12/ctypes/macholib/dyld.py +165 -0
  333. package/python/lib/python3.12/ctypes/macholib/dylib.py +42 -0
  334. package/python/lib/python3.12/ctypes/macholib/fetch_macholib +2 -0
  335. package/python/lib/python3.12/ctypes/macholib/fetch_macholib.bat +1 -0
  336. package/python/lib/python3.12/ctypes/macholib/framework.py +42 -0
  337. package/python/lib/python3.12/ctypes/util.py +379 -0
  338. package/python/lib/python3.12/ctypes/wintypes.py +202 -0
  339. package/python/lib/python3.12/curses/__init__.py +101 -0
  340. package/python/lib/python3.12/curses/ascii.py +99 -0
  341. package/python/lib/python3.12/curses/has_key.py +192 -0
  342. package/python/lib/python3.12/curses/panel.py +6 -0
  343. package/python/lib/python3.12/curses/textpad.py +204 -0
  344. package/python/lib/python3.12/dataclasses.py +1588 -0
  345. package/python/lib/python3.12/datetime.py +9 -0
  346. package/python/lib/python3.12/dbm/__init__.py +190 -0
  347. package/python/lib/python3.12/dbm/dumb.py +317 -0
  348. package/python/lib/python3.12/dbm/gnu.py +3 -0
  349. package/python/lib/python3.12/dbm/ndbm.py +3 -0
  350. package/python/lib/python3.12/decimal.py +108 -0
  351. package/python/lib/python3.12/difflib.py +2056 -0
  352. package/python/lib/python3.12/dis.py +805 -0
  353. package/python/lib/python3.12/doctest.py +2845 -0
  354. package/python/lib/python3.12/email/__init__.py +61 -0
  355. package/python/lib/python3.12/email/_encoded_words.py +233 -0
  356. package/python/lib/python3.12/email/_header_value_parser.py +3108 -0
  357. package/python/lib/python3.12/email/_parseaddr.py +557 -0
  358. package/python/lib/python3.12/email/_policybase.py +382 -0
  359. package/python/lib/python3.12/email/architecture.rst +216 -0
  360. package/python/lib/python3.12/email/base64mime.py +115 -0
  361. package/python/lib/python3.12/email/charset.py +398 -0
  362. package/python/lib/python3.12/email/contentmanager.py +251 -0
  363. package/python/lib/python3.12/email/encoders.py +65 -0
  364. package/python/lib/python3.12/email/errors.py +117 -0
  365. package/python/lib/python3.12/email/feedparser.py +534 -0
  366. package/python/lib/python3.12/email/generator.py +530 -0
  367. package/python/lib/python3.12/email/header.py +573 -0
  368. package/python/lib/python3.12/email/headerregistry.py +604 -0
  369. package/python/lib/python3.12/email/iterators.py +68 -0
  370. package/python/lib/python3.12/email/message.py +1215 -0
  371. package/python/lib/python3.12/email/mime/__init__.py +0 -0
  372. package/python/lib/python3.12/email/mime/application.py +37 -0
  373. package/python/lib/python3.12/email/mime/audio.py +100 -0
  374. package/python/lib/python3.12/email/mime/base.py +29 -0
  375. package/python/lib/python3.12/email/mime/image.py +152 -0
  376. package/python/lib/python3.12/email/mime/message.py +33 -0
  377. package/python/lib/python3.12/email/mime/multipart.py +47 -0
  378. package/python/lib/python3.12/email/mime/nonmultipart.py +21 -0
  379. package/python/lib/python3.12/email/mime/text.py +40 -0
  380. package/python/lib/python3.12/email/parser.py +127 -0
  381. package/python/lib/python3.12/email/policy.py +232 -0
  382. package/python/lib/python3.12/email/quoprimime.py +300 -0
  383. package/python/lib/python3.12/email/utils.py +486 -0
  384. package/python/lib/python3.12/encodings/__init__.py +174 -0
  385. package/python/lib/python3.12/encodings/aliases.py +551 -0
  386. package/python/lib/python3.12/encodings/ascii.py +50 -0
  387. package/python/lib/python3.12/encodings/base64_codec.py +55 -0
  388. package/python/lib/python3.12/encodings/big5.py +39 -0
  389. package/python/lib/python3.12/encodings/big5hkscs.py +39 -0
  390. package/python/lib/python3.12/encodings/bz2_codec.py +78 -0
  391. package/python/lib/python3.12/encodings/charmap.py +69 -0
  392. package/python/lib/python3.12/encodings/cp037.py +307 -0
  393. package/python/lib/python3.12/encodings/cp1006.py +307 -0
  394. package/python/lib/python3.12/encodings/cp1026.py +307 -0
  395. package/python/lib/python3.12/encodings/cp1125.py +698 -0
  396. package/python/lib/python3.12/encodings/cp1140.py +307 -0
  397. package/python/lib/python3.12/encodings/cp1250.py +307 -0
  398. package/python/lib/python3.12/encodings/cp1251.py +307 -0
  399. package/python/lib/python3.12/encodings/cp1252.py +307 -0
  400. package/python/lib/python3.12/encodings/cp1253.py +307 -0
  401. package/python/lib/python3.12/encodings/cp1254.py +307 -0
  402. package/python/lib/python3.12/encodings/cp1255.py +307 -0
  403. package/python/lib/python3.12/encodings/cp1256.py +307 -0
  404. package/python/lib/python3.12/encodings/cp1257.py +307 -0
  405. package/python/lib/python3.12/encodings/cp1258.py +307 -0
  406. package/python/lib/python3.12/encodings/cp273.py +307 -0
  407. package/python/lib/python3.12/encodings/cp424.py +307 -0
  408. package/python/lib/python3.12/encodings/cp437.py +698 -0
  409. package/python/lib/python3.12/encodings/cp500.py +307 -0
  410. package/python/lib/python3.12/encodings/cp720.py +309 -0
  411. package/python/lib/python3.12/encodings/cp737.py +698 -0
  412. package/python/lib/python3.12/encodings/cp775.py +697 -0
  413. package/python/lib/python3.12/encodings/cp850.py +698 -0
  414. package/python/lib/python3.12/encodings/cp852.py +698 -0
  415. package/python/lib/python3.12/encodings/cp855.py +698 -0
  416. package/python/lib/python3.12/encodings/cp856.py +307 -0
  417. package/python/lib/python3.12/encodings/cp857.py +694 -0
  418. package/python/lib/python3.12/encodings/cp858.py +698 -0
  419. package/python/lib/python3.12/encodings/cp860.py +698 -0
  420. package/python/lib/python3.12/encodings/cp861.py +698 -0
  421. package/python/lib/python3.12/encodings/cp862.py +698 -0
  422. package/python/lib/python3.12/encodings/cp863.py +698 -0
  423. package/python/lib/python3.12/encodings/cp864.py +690 -0
  424. package/python/lib/python3.12/encodings/cp865.py +698 -0
  425. package/python/lib/python3.12/encodings/cp866.py +698 -0
  426. package/python/lib/python3.12/encodings/cp869.py +689 -0
  427. package/python/lib/python3.12/encodings/cp874.py +307 -0
  428. package/python/lib/python3.12/encodings/cp875.py +307 -0
  429. package/python/lib/python3.12/encodings/cp932.py +39 -0
  430. package/python/lib/python3.12/encodings/cp949.py +39 -0
  431. package/python/lib/python3.12/encodings/cp950.py +39 -0
  432. package/python/lib/python3.12/encodings/euc_jis_2004.py +39 -0
  433. package/python/lib/python3.12/encodings/euc_jisx0213.py +39 -0
  434. package/python/lib/python3.12/encodings/euc_jp.py +39 -0
  435. package/python/lib/python3.12/encodings/euc_kr.py +39 -0
  436. package/python/lib/python3.12/encodings/gb18030.py +39 -0
  437. package/python/lib/python3.12/encodings/gb2312.py +39 -0
  438. package/python/lib/python3.12/encodings/gbk.py +39 -0
  439. package/python/lib/python3.12/encodings/hex_codec.py +55 -0
  440. package/python/lib/python3.12/encodings/hp_roman8.py +314 -0
  441. package/python/lib/python3.12/encodings/hz.py +39 -0
  442. package/python/lib/python3.12/encodings/idna.py +317 -0
  443. package/python/lib/python3.12/encodings/iso2022_jp.py +39 -0
  444. package/python/lib/python3.12/encodings/iso2022_jp_1.py +39 -0
  445. package/python/lib/python3.12/encodings/iso2022_jp_2.py +39 -0
  446. package/python/lib/python3.12/encodings/iso2022_jp_2004.py +39 -0
  447. package/python/lib/python3.12/encodings/iso2022_jp_3.py +39 -0
  448. package/python/lib/python3.12/encodings/iso2022_jp_ext.py +39 -0
  449. package/python/lib/python3.12/encodings/iso2022_kr.py +39 -0
  450. package/python/lib/python3.12/encodings/iso8859_1.py +307 -0
  451. package/python/lib/python3.12/encodings/iso8859_10.py +307 -0
  452. package/python/lib/python3.12/encodings/iso8859_11.py +307 -0
  453. package/python/lib/python3.12/encodings/iso8859_13.py +307 -0
  454. package/python/lib/python3.12/encodings/iso8859_14.py +307 -0
  455. package/python/lib/python3.12/encodings/iso8859_15.py +307 -0
  456. package/python/lib/python3.12/encodings/iso8859_16.py +307 -0
  457. package/python/lib/python3.12/encodings/iso8859_2.py +307 -0
  458. package/python/lib/python3.12/encodings/iso8859_3.py +307 -0
  459. package/python/lib/python3.12/encodings/iso8859_4.py +307 -0
  460. package/python/lib/python3.12/encodings/iso8859_5.py +307 -0
  461. package/python/lib/python3.12/encodings/iso8859_6.py +307 -0
  462. package/python/lib/python3.12/encodings/iso8859_7.py +307 -0
  463. package/python/lib/python3.12/encodings/iso8859_8.py +307 -0
  464. package/python/lib/python3.12/encodings/iso8859_9.py +307 -0
  465. package/python/lib/python3.12/encodings/johab.py +39 -0
  466. package/python/lib/python3.12/encodings/koi8_r.py +307 -0
  467. package/python/lib/python3.12/encodings/koi8_t.py +308 -0
  468. package/python/lib/python3.12/encodings/koi8_u.py +307 -0
  469. package/python/lib/python3.12/encodings/kz1048.py +307 -0
  470. package/python/lib/python3.12/encodings/latin_1.py +50 -0
  471. package/python/lib/python3.12/encodings/mac_arabic.py +698 -0
  472. package/python/lib/python3.12/encodings/mac_croatian.py +307 -0
  473. package/python/lib/python3.12/encodings/mac_cyrillic.py +307 -0
  474. package/python/lib/python3.12/encodings/mac_farsi.py +307 -0
  475. package/python/lib/python3.12/encodings/mac_greek.py +307 -0
  476. package/python/lib/python3.12/encodings/mac_iceland.py +307 -0
  477. package/python/lib/python3.12/encodings/mac_latin2.py +312 -0
  478. package/python/lib/python3.12/encodings/mac_roman.py +307 -0
  479. package/python/lib/python3.12/encodings/mac_romanian.py +307 -0
  480. package/python/lib/python3.12/encodings/mac_turkish.py +307 -0
  481. package/python/lib/python3.12/encodings/mbcs.py +47 -0
  482. package/python/lib/python3.12/encodings/oem.py +41 -0
  483. package/python/lib/python3.12/encodings/palmos.py +308 -0
  484. package/python/lib/python3.12/encodings/ptcp154.py +312 -0
  485. package/python/lib/python3.12/encodings/punycode.py +237 -0
  486. package/python/lib/python3.12/encodings/quopri_codec.py +56 -0
  487. package/python/lib/python3.12/encodings/raw_unicode_escape.py +46 -0
  488. package/python/lib/python3.12/encodings/rot_13.py +113 -0
  489. package/python/lib/python3.12/encodings/shift_jis.py +39 -0
  490. package/python/lib/python3.12/encodings/shift_jis_2004.py +39 -0
  491. package/python/lib/python3.12/encodings/shift_jisx0213.py +39 -0
  492. package/python/lib/python3.12/encodings/tis_620.py +307 -0
  493. package/python/lib/python3.12/encodings/undefined.py +49 -0
  494. package/python/lib/python3.12/encodings/unicode_escape.py +46 -0
  495. package/python/lib/python3.12/encodings/utf_16.py +155 -0
  496. package/python/lib/python3.12/encodings/utf_16_be.py +42 -0
  497. package/python/lib/python3.12/encodings/utf_16_le.py +42 -0
  498. package/python/lib/python3.12/encodings/utf_32.py +150 -0
  499. package/python/lib/python3.12/encodings/utf_32_be.py +37 -0
  500. package/python/lib/python3.12/encodings/utf_32_le.py +37 -0
  501. package/python/lib/python3.12/encodings/utf_7.py +38 -0
  502. package/python/lib/python3.12/encodings/utf_8.py +42 -0
  503. package/python/lib/python3.12/encodings/utf_8_sig.py +130 -0
  504. package/python/lib/python3.12/encodings/uu_codec.py +103 -0
  505. package/python/lib/python3.12/encodings/zlib_codec.py +77 -0
  506. package/python/lib/python3.12/ensurepip/__init__.py +291 -0
  507. package/python/lib/python3.12/ensurepip/__main__.py +5 -0
  508. package/python/lib/python3.12/ensurepip/_bundled/pip-25.0.1-py3-none-any.whl +0 -0
  509. package/python/lib/python3.12/ensurepip/_uninstall.py +31 -0
  510. package/python/lib/python3.12/enum.py +2108 -0
  511. package/python/lib/python3.12/filecmp.py +315 -0
  512. package/python/lib/python3.12/fileinput.py +442 -0
  513. package/python/lib/python3.12/fnmatch.py +185 -0
  514. package/python/lib/python3.12/fractions.py +990 -0
  515. package/python/lib/python3.12/ftplib.py +966 -0
  516. package/python/lib/python3.12/functools.py +1009 -0
  517. package/python/lib/python3.12/genericpath.py +176 -0
  518. package/python/lib/python3.12/getopt.py +215 -0
  519. package/python/lib/python3.12/getpass.py +185 -0
  520. package/python/lib/python3.12/gettext.py +646 -0
  521. package/python/lib/python3.12/glob.py +252 -0
  522. package/python/lib/python3.12/graphlib.py +250 -0
  523. package/python/lib/python3.12/gzip.py +711 -0
  524. package/python/lib/python3.12/hashlib.py +253 -0
  525. package/python/lib/python3.12/heapq.py +603 -0
  526. package/python/lib/python3.12/hmac.py +219 -0
  527. package/python/lib/python3.12/html/__init__.py +132 -0
  528. package/python/lib/python3.12/html/entities.py +2513 -0
  529. package/python/lib/python3.12/html/parser.py +535 -0
  530. package/python/lib/python3.12/http/__init__.py +200 -0
  531. package/python/lib/python3.12/http/client.py +1570 -0
  532. package/python/lib/python3.12/http/cookiejar.py +2121 -0
  533. package/python/lib/python3.12/http/cookies.py +615 -0
  534. package/python/lib/python3.12/http/server.py +1335 -0
  535. package/python/lib/python3.12/imaplib.py +1641 -0
  536. package/python/lib/python3.12/imghdr.py +180 -0
  537. package/python/lib/python3.12/importlib/__init__.py +138 -0
  538. package/python/lib/python3.12/importlib/_abc.py +39 -0
  539. package/python/lib/python3.12/importlib/_bootstrap.py +1551 -0
  540. package/python/lib/python3.12/importlib/_bootstrap_external.py +1749 -0
  541. package/python/lib/python3.12/importlib/abc.py +239 -0
  542. package/python/lib/python3.12/importlib/machinery.py +20 -0
  543. package/python/lib/python3.12/importlib/metadata/__init__.py +966 -0
  544. package/python/lib/python3.12/importlib/metadata/_adapters.py +89 -0
  545. package/python/lib/python3.12/importlib/metadata/_collections.py +30 -0
  546. package/python/lib/python3.12/importlib/metadata/_functools.py +104 -0
  547. package/python/lib/python3.12/importlib/metadata/_itertools.py +73 -0
  548. package/python/lib/python3.12/importlib/metadata/_meta.py +63 -0
  549. package/python/lib/python3.12/importlib/metadata/_text.py +99 -0
  550. package/python/lib/python3.12/importlib/readers.py +12 -0
  551. package/python/lib/python3.12/importlib/resources/__init__.py +38 -0
  552. package/python/lib/python3.12/importlib/resources/_adapters.py +168 -0
  553. package/python/lib/python3.12/importlib/resources/_common.py +208 -0
  554. package/python/lib/python3.12/importlib/resources/_itertools.py +38 -0
  555. package/python/lib/python3.12/importlib/resources/_legacy.py +98 -0
  556. package/python/lib/python3.12/importlib/resources/abc.py +173 -0
  557. package/python/lib/python3.12/importlib/resources/readers.py +146 -0
  558. package/python/lib/python3.12/importlib/resources/simple.py +106 -0
  559. package/python/lib/python3.12/importlib/simple.py +14 -0
  560. package/python/lib/python3.12/importlib/util.py +270 -0
  561. package/python/lib/python3.12/inspect.py +3433 -0
  562. package/python/lib/python3.12/io.py +99 -0
  563. package/python/lib/python3.12/ipaddress.py +2430 -0
  564. package/python/lib/python3.12/json/__init__.py +359 -0
  565. package/python/lib/python3.12/json/decoder.py +357 -0
  566. package/python/lib/python3.12/json/encoder.py +443 -0
  567. package/python/lib/python3.12/json/scanner.py +73 -0
  568. package/python/lib/python3.12/json/tool.py +85 -0
  569. package/python/lib/python3.12/keyword.py +64 -0
  570. package/python/lib/python3.12/lib-dynload/.empty +0 -0
  571. package/python/lib/python3.12/lib-dynload/_crypt.cpython-312-darwin.so +0 -0
  572. package/python/lib/python3.12/lib-dynload/_dbm.cpython-312-darwin.so +0 -0
  573. package/python/lib/python3.12/linecache.py +185 -0
  574. package/python/lib/python3.12/locale.py +1779 -0
  575. package/python/lib/python3.12/logging/__init__.py +2345 -0
  576. package/python/lib/python3.12/logging/config.py +1078 -0
  577. package/python/lib/python3.12/logging/handlers.py +1624 -0
  578. package/python/lib/python3.12/lzma.py +356 -0
  579. package/python/lib/python3.12/mailbox.py +2153 -0
  580. package/python/lib/python3.12/mailcap.py +302 -0
  581. package/python/lib/python3.12/mimetypes.py +656 -0
  582. package/python/lib/python3.12/modulefinder.py +666 -0
  583. package/python/lib/python3.12/multiprocessing/__init__.py +37 -0
  584. package/python/lib/python3.12/multiprocessing/connection.py +1178 -0
  585. package/python/lib/python3.12/multiprocessing/context.py +377 -0
  586. package/python/lib/python3.12/multiprocessing/dummy/__init__.py +126 -0
  587. package/python/lib/python3.12/multiprocessing/dummy/connection.py +75 -0
  588. package/python/lib/python3.12/multiprocessing/forkserver.py +350 -0
  589. package/python/lib/python3.12/multiprocessing/heap.py +337 -0
  590. package/python/lib/python3.12/multiprocessing/managers.py +1387 -0
  591. package/python/lib/python3.12/multiprocessing/pool.py +957 -0
  592. package/python/lib/python3.12/multiprocessing/popen_fork.py +83 -0
  593. package/python/lib/python3.12/multiprocessing/popen_forkserver.py +74 -0
  594. package/python/lib/python3.12/multiprocessing/popen_spawn_posix.py +72 -0
  595. package/python/lib/python3.12/multiprocessing/popen_spawn_win32.py +145 -0
  596. package/python/lib/python3.12/multiprocessing/process.py +439 -0
  597. package/python/lib/python3.12/multiprocessing/queues.py +401 -0
  598. package/python/lib/python3.12/multiprocessing/reduction.py +281 -0
  599. package/python/lib/python3.12/multiprocessing/resource_sharer.py +154 -0
  600. package/python/lib/python3.12/multiprocessing/resource_tracker.py +294 -0
  601. package/python/lib/python3.12/multiprocessing/shared_memory.py +534 -0
  602. package/python/lib/python3.12/multiprocessing/sharedctypes.py +240 -0
  603. package/python/lib/python3.12/multiprocessing/spawn.py +307 -0
  604. package/python/lib/python3.12/multiprocessing/synchronize.py +404 -0
  605. package/python/lib/python3.12/multiprocessing/util.py +494 -0
  606. package/python/lib/python3.12/netrc.py +192 -0
  607. package/python/lib/python3.12/nntplib.py +1093 -0
  608. package/python/lib/python3.12/ntpath.py +869 -0
  609. package/python/lib/python3.12/nturl2path.py +69 -0
  610. package/python/lib/python3.12/numbers.py +418 -0
  611. package/python/lib/python3.12/opcode.py +493 -0
  612. package/python/lib/python3.12/operator.py +467 -0
  613. package/python/lib/python3.12/optparse.py +1681 -0
  614. package/python/lib/python3.12/os.py +1159 -0
  615. package/python/lib/python3.12/pathlib.py +1435 -0
  616. package/python/lib/python3.12/pdb.py +1987 -0
  617. package/python/lib/python3.12/pickle.py +1866 -0
  618. package/python/lib/python3.12/pickletools.py +2904 -0
  619. package/python/lib/python3.12/pipes.py +250 -0
  620. package/python/lib/python3.12/pkgutil.py +529 -0
  621. package/python/lib/python3.12/platform.py +1359 -0
  622. package/python/lib/python3.12/plistlib.py +920 -0
  623. package/python/lib/python3.12/poplib.py +478 -0
  624. package/python/lib/python3.12/posixpath.py +577 -0
  625. package/python/lib/python3.12/pprint.py +658 -0
  626. package/python/lib/python3.12/profile.py +615 -0
  627. package/python/lib/python3.12/pstats.py +778 -0
  628. package/python/lib/python3.12/pty.py +211 -0
  629. package/python/lib/python3.12/py_compile.py +212 -0
  630. package/python/lib/python3.12/pyclbr.py +314 -0
  631. package/python/lib/python3.12/pydoc.py +2950 -0
  632. package/python/lib/python3.12/pydoc_data/__init__.py +0 -0
  633. package/python/lib/python3.12/pydoc_data/_pydoc.css +112 -0
  634. package/python/lib/python3.12/pydoc_data/topics.py +12500 -0
  635. package/python/lib/python3.12/queue.py +326 -0
  636. package/python/lib/python3.12/quopri.py +237 -0
  637. package/python/lib/python3.12/random.py +996 -0
  638. package/python/lib/python3.12/re/__init__.py +385 -0
  639. package/python/lib/python3.12/re/_casefix.py +106 -0
  640. package/python/lib/python3.12/re/_compiler.py +770 -0
  641. package/python/lib/python3.12/re/_constants.py +220 -0
  642. package/python/lib/python3.12/re/_parser.py +1080 -0
  643. package/python/lib/python3.12/reprlib.py +214 -0
  644. package/python/lib/python3.12/rlcompleter.py +219 -0
  645. package/python/lib/python3.12/runpy.py +319 -0
  646. package/python/lib/python3.12/sched.py +167 -0
  647. package/python/lib/python3.12/secrets.py +71 -0
  648. package/python/lib/python3.12/selectors.py +623 -0
  649. package/python/lib/python3.12/shelve.py +243 -0
  650. package/python/lib/python3.12/shlex.py +345 -0
  651. package/python/lib/python3.12/shutil.py +1566 -0
  652. package/python/lib/python3.12/signal.py +94 -0
  653. package/python/lib/python3.12/site-packages/README.txt +2 -0
  654. package/python/lib/python3.12/site-packages/pip/__init__.py +13 -0
  655. package/python/lib/python3.12/site-packages/pip/__main__.py +24 -0
  656. package/python/lib/python3.12/site-packages/pip/__pip-runner__.py +50 -0
  657. package/python/lib/python3.12/site-packages/pip/_internal/__init__.py +18 -0
  658. package/python/lib/python3.12/site-packages/pip/_internal/build_env.py +606 -0
  659. package/python/lib/python3.12/site-packages/pip/_internal/cache.py +291 -0
  660. package/python/lib/python3.12/site-packages/pip/_internal/cli/__init__.py +3 -0
  661. package/python/lib/python3.12/site-packages/pip/_internal/cli/autocompletion.py +184 -0
  662. package/python/lib/python3.12/site-packages/pip/_internal/cli/base_command.py +264 -0
  663. package/python/lib/python3.12/site-packages/pip/_internal/cli/cmdoptions.py +1298 -0
  664. package/python/lib/python3.12/site-packages/pip/_internal/cli/command_context.py +28 -0
  665. package/python/lib/python3.12/site-packages/pip/_internal/cli/index_command.py +212 -0
  666. package/python/lib/python3.12/site-packages/pip/_internal/cli/main.py +85 -0
  667. package/python/lib/python3.12/site-packages/pip/_internal/cli/main_parser.py +136 -0
  668. package/python/lib/python3.12/site-packages/pip/_internal/cli/parser.py +358 -0
  669. package/python/lib/python3.12/site-packages/pip/_internal/cli/progress_bars.py +153 -0
  670. package/python/lib/python3.12/site-packages/pip/_internal/cli/req_command.py +472 -0
  671. package/python/lib/python3.12/site-packages/pip/_internal/cli/spinners.py +235 -0
  672. package/python/lib/python3.12/site-packages/pip/_internal/cli/status_codes.py +6 -0
  673. package/python/lib/python3.12/site-packages/pip/_internal/commands/__init__.py +139 -0
  674. package/python/lib/python3.12/site-packages/pip/_internal/commands/cache.py +255 -0
  675. package/python/lib/python3.12/site-packages/pip/_internal/commands/check.py +66 -0
  676. package/python/lib/python3.12/site-packages/pip/_internal/commands/completion.py +136 -0
  677. package/python/lib/python3.12/site-packages/pip/_internal/commands/configuration.py +288 -0
  678. package/python/lib/python3.12/site-packages/pip/_internal/commands/debug.py +196 -0
  679. package/python/lib/python3.12/site-packages/pip/_internal/commands/download.py +146 -0
  680. package/python/lib/python3.12/site-packages/pip/_internal/commands/freeze.py +107 -0
  681. package/python/lib/python3.12/site-packages/pip/_internal/commands/hash.py +58 -0
  682. package/python/lib/python3.12/site-packages/pip/_internal/commands/help.py +40 -0
  683. package/python/lib/python3.12/site-packages/pip/_internal/commands/index.py +166 -0
  684. package/python/lib/python3.12/site-packages/pip/_internal/commands/inspect.py +92 -0
  685. package/python/lib/python3.12/site-packages/pip/_internal/commands/install.py +904 -0
  686. package/python/lib/python3.12/site-packages/pip/_internal/commands/list.py +403 -0
  687. package/python/lib/python3.12/site-packages/pip/_internal/commands/lock.py +175 -0
  688. package/python/lib/python3.12/site-packages/pip/_internal/commands/search.py +178 -0
  689. package/python/lib/python3.12/site-packages/pip/_internal/commands/show.py +231 -0
  690. package/python/lib/python3.12/site-packages/pip/_internal/commands/uninstall.py +113 -0
  691. package/python/lib/python3.12/site-packages/pip/_internal/commands/wheel.py +171 -0
  692. package/python/lib/python3.12/site-packages/pip/_internal/configuration.py +396 -0
  693. package/python/lib/python3.12/site-packages/pip/_internal/distributions/__init__.py +21 -0
  694. package/python/lib/python3.12/site-packages/pip/_internal/distributions/base.py +55 -0
  695. package/python/lib/python3.12/site-packages/pip/_internal/distributions/installed.py +33 -0
  696. package/python/lib/python3.12/site-packages/pip/_internal/distributions/sdist.py +164 -0
  697. package/python/lib/python3.12/site-packages/pip/_internal/distributions/wheel.py +44 -0
  698. package/python/lib/python3.12/site-packages/pip/_internal/exceptions.py +971 -0
  699. package/python/lib/python3.12/site-packages/pip/_internal/index/__init__.py +1 -0
  700. package/python/lib/python3.12/site-packages/pip/_internal/index/collector.py +488 -0
  701. package/python/lib/python3.12/site-packages/pip/_internal/index/package_finder.py +1113 -0
  702. package/python/lib/python3.12/site-packages/pip/_internal/index/sources.py +287 -0
  703. package/python/lib/python3.12/site-packages/pip/_internal/locations/__init__.py +438 -0
  704. package/python/lib/python3.12/site-packages/pip/_internal/locations/_distutils.py +173 -0
  705. package/python/lib/python3.12/site-packages/pip/_internal/locations/_sysconfig.py +218 -0
  706. package/python/lib/python3.12/site-packages/pip/_internal/locations/base.py +82 -0
  707. package/python/lib/python3.12/site-packages/pip/_internal/main.py +12 -0
  708. package/python/lib/python3.12/site-packages/pip/_internal/metadata/__init__.py +169 -0
  709. package/python/lib/python3.12/site-packages/pip/_internal/metadata/_json.py +87 -0
  710. package/python/lib/python3.12/site-packages/pip/_internal/metadata/base.py +685 -0
  711. package/python/lib/python3.12/site-packages/pip/_internal/metadata/importlib/__init__.py +6 -0
  712. package/python/lib/python3.12/site-packages/pip/_internal/metadata/importlib/_compat.py +87 -0
  713. package/python/lib/python3.12/site-packages/pip/_internal/metadata/importlib/_dists.py +235 -0
  714. package/python/lib/python3.12/site-packages/pip/_internal/metadata/importlib/_envs.py +143 -0
  715. package/python/lib/python3.12/site-packages/pip/_internal/metadata/pkg_resources.py +298 -0
  716. package/python/lib/python3.12/site-packages/pip/_internal/models/__init__.py +1 -0
  717. package/python/lib/python3.12/site-packages/pip/_internal/models/candidate.py +23 -0
  718. package/python/lib/python3.12/site-packages/pip/_internal/models/direct_url.py +42 -0
  719. package/python/lib/python3.12/site-packages/pip/_internal/models/format_control.py +78 -0
  720. package/python/lib/python3.12/site-packages/pip/_internal/models/index.py +28 -0
  721. package/python/lib/python3.12/site-packages/pip/_internal/models/installation_report.py +57 -0
  722. package/python/lib/python3.12/site-packages/pip/_internal/models/link.py +617 -0
  723. package/python/lib/python3.12/site-packages/pip/_internal/models/release_control.py +91 -0
  724. package/python/lib/python3.12/site-packages/pip/_internal/models/scheme.py +23 -0
  725. package/python/lib/python3.12/site-packages/pip/_internal/models/search_scope.py +124 -0
  726. package/python/lib/python3.12/site-packages/pip/_internal/models/selection_prefs.py +36 -0
  727. package/python/lib/python3.12/site-packages/pip/_internal/models/target_python.py +122 -0
  728. package/python/lib/python3.12/site-packages/pip/_internal/models/wheel.py +80 -0
  729. package/python/lib/python3.12/site-packages/pip/_internal/network/__init__.py +1 -0
  730. package/python/lib/python3.12/site-packages/pip/_internal/network/auth.py +570 -0
  731. package/python/lib/python3.12/site-packages/pip/_internal/network/cache.py +128 -0
  732. package/python/lib/python3.12/site-packages/pip/_internal/network/download.py +340 -0
  733. package/python/lib/python3.12/site-packages/pip/_internal/network/lazy_wheel.py +215 -0
  734. package/python/lib/python3.12/site-packages/pip/_internal/network/session.py +537 -0
  735. package/python/lib/python3.12/site-packages/pip/_internal/network/utils.py +98 -0
  736. package/python/lib/python3.12/site-packages/pip/_internal/network/xmlrpc.py +61 -0
  737. package/python/lib/python3.12/site-packages/pip/_internal/operations/__init__.py +0 -0
  738. package/python/lib/python3.12/site-packages/pip/_internal/operations/build/__init__.py +0 -0
  739. package/python/lib/python3.12/site-packages/pip/_internal/operations/build/build_tracker.py +140 -0
  740. package/python/lib/python3.12/site-packages/pip/_internal/operations/build/metadata.py +38 -0
  741. package/python/lib/python3.12/site-packages/pip/_internal/operations/build/metadata_editable.py +41 -0
  742. package/python/lib/python3.12/site-packages/pip/_internal/operations/build/wheel.py +38 -0
  743. package/python/lib/python3.12/site-packages/pip/_internal/operations/build/wheel_editable.py +47 -0
  744. package/python/lib/python3.12/site-packages/pip/_internal/operations/check.py +175 -0
  745. package/python/lib/python3.12/site-packages/pip/_internal/operations/freeze.py +259 -0
  746. package/python/lib/python3.12/site-packages/pip/_internal/operations/install/__init__.py +1 -0
  747. package/python/lib/python3.12/site-packages/pip/_internal/operations/install/wheel.py +759 -0
  748. package/python/lib/python3.12/site-packages/pip/_internal/operations/prepare.py +751 -0
  749. package/python/lib/python3.12/site-packages/pip/_internal/pyproject.py +123 -0
  750. package/python/lib/python3.12/site-packages/pip/_internal/req/__init__.py +103 -0
  751. package/python/lib/python3.12/site-packages/pip/_internal/req/constructors.py +677 -0
  752. package/python/lib/python3.12/site-packages/pip/_internal/req/pep723.py +41 -0
  753. package/python/lib/python3.12/site-packages/pip/_internal/req/req_dependency_group.py +86 -0
  754. package/python/lib/python3.12/site-packages/pip/_internal/req/req_file.py +622 -0
  755. package/python/lib/python3.12/site-packages/pip/_internal/req/req_install.py +838 -0
  756. package/python/lib/python3.12/site-packages/pip/_internal/req/req_set.py +81 -0
  757. package/python/lib/python3.12/site-packages/pip/_internal/req/req_uninstall.py +639 -0
  758. package/python/lib/python3.12/site-packages/pip/_internal/resolution/__init__.py +0 -0
  759. package/python/lib/python3.12/site-packages/pip/_internal/resolution/base.py +20 -0
  760. package/python/lib/python3.12/site-packages/pip/_internal/resolution/legacy/__init__.py +0 -0
  761. package/python/lib/python3.12/site-packages/pip/_internal/resolution/legacy/resolver.py +598 -0
  762. package/python/lib/python3.12/site-packages/pip/_internal/resolution/resolvelib/__init__.py +0 -0
  763. package/python/lib/python3.12/site-packages/pip/_internal/resolution/resolvelib/base.py +164 -0
  764. package/python/lib/python3.12/site-packages/pip/_internal/resolution/resolvelib/candidates.py +599 -0
  765. package/python/lib/python3.12/site-packages/pip/_internal/resolution/resolvelib/factory.py +914 -0
  766. package/python/lib/python3.12/site-packages/pip/_internal/resolution/resolvelib/found_candidates.py +166 -0
  767. package/python/lib/python3.12/site-packages/pip/_internal/resolution/resolvelib/provider.py +306 -0
  768. package/python/lib/python3.12/site-packages/pip/_internal/resolution/resolvelib/reporter.py +98 -0
  769. package/python/lib/python3.12/site-packages/pip/_internal/resolution/resolvelib/requirements.py +251 -0
  770. package/python/lib/python3.12/site-packages/pip/_internal/resolution/resolvelib/resolver.py +332 -0
  771. package/python/lib/python3.12/site-packages/pip/_internal/self_outdated_check.py +246 -0
  772. package/python/lib/python3.12/site-packages/pip/_internal/utils/__init__.py +0 -0
  773. package/python/lib/python3.12/site-packages/pip/_internal/utils/_jaraco_text.py +109 -0
  774. package/python/lib/python3.12/site-packages/pip/_internal/utils/_log.py +38 -0
  775. package/python/lib/python3.12/site-packages/pip/_internal/utils/appdirs.py +52 -0
  776. package/python/lib/python3.12/site-packages/pip/_internal/utils/compat.py +85 -0
  777. package/python/lib/python3.12/site-packages/pip/_internal/utils/compatibility_tags.py +201 -0
  778. package/python/lib/python3.12/site-packages/pip/_internal/utils/datetime.py +28 -0
  779. package/python/lib/python3.12/site-packages/pip/_internal/utils/deprecation.py +139 -0
  780. package/python/lib/python3.12/site-packages/pip/_internal/utils/direct_url_helpers.py +92 -0
  781. package/python/lib/python3.12/site-packages/pip/_internal/utils/egg_link.py +81 -0
  782. package/python/lib/python3.12/site-packages/pip/_internal/utils/entrypoints.py +88 -0
  783. package/python/lib/python3.12/site-packages/pip/_internal/utils/filesystem.py +201 -0
  784. package/python/lib/python3.12/site-packages/pip/_internal/utils/filetypes.py +24 -0
  785. package/python/lib/python3.12/site-packages/pip/_internal/utils/glibc.py +102 -0
  786. package/python/lib/python3.12/site-packages/pip/_internal/utils/hashes.py +150 -0
  787. package/python/lib/python3.12/site-packages/pip/_internal/utils/logging.py +396 -0
  788. package/python/lib/python3.12/site-packages/pip/_internal/utils/misc.py +771 -0
  789. package/python/lib/python3.12/site-packages/pip/_internal/utils/packaging.py +44 -0
  790. package/python/lib/python3.12/site-packages/pip/_internal/utils/pylock.py +283 -0
  791. package/python/lib/python3.12/site-packages/pip/_internal/utils/retry.py +45 -0
  792. package/python/lib/python3.12/site-packages/pip/_internal/utils/subprocess.py +248 -0
  793. package/python/lib/python3.12/site-packages/pip/_internal/utils/temp_dir.py +294 -0
  794. package/python/lib/python3.12/site-packages/pip/_internal/utils/unpacking.py +381 -0
  795. package/python/lib/python3.12/site-packages/pip/_internal/utils/urls.py +55 -0
  796. package/python/lib/python3.12/site-packages/pip/_internal/utils/virtualenv.py +105 -0
  797. package/python/lib/python3.12/site-packages/pip/_internal/utils/wheel.py +132 -0
  798. package/python/lib/python3.12/site-packages/pip/_internal/vcs/__init__.py +15 -0
  799. package/python/lib/python3.12/site-packages/pip/_internal/vcs/bazaar.py +130 -0
  800. package/python/lib/python3.12/site-packages/pip/_internal/vcs/git.py +571 -0
  801. package/python/lib/python3.12/site-packages/pip/_internal/vcs/mercurial.py +186 -0
  802. package/python/lib/python3.12/site-packages/pip/_internal/vcs/subversion.py +335 -0
  803. package/python/lib/python3.12/site-packages/pip/_internal/vcs/versioncontrol.py +695 -0
  804. package/python/lib/python3.12/site-packages/pip/_internal/wheel_builder.py +261 -0
  805. package/python/lib/python3.12/site-packages/pip/_vendor/README.rst +178 -0
  806. package/python/lib/python3.12/site-packages/pip/_vendor/__init__.py +117 -0
  807. package/python/lib/python3.12/site-packages/pip/_vendor/cachecontrol/LICENSE.txt +13 -0
  808. package/python/lib/python3.12/site-packages/pip/_vendor/cachecontrol/__init__.py +32 -0
  809. package/python/lib/python3.12/site-packages/pip/_vendor/cachecontrol/_cmd.py +70 -0
  810. package/python/lib/python3.12/site-packages/pip/_vendor/cachecontrol/adapter.py +167 -0
  811. package/python/lib/python3.12/site-packages/pip/_vendor/cachecontrol/cache.py +75 -0
  812. package/python/lib/python3.12/site-packages/pip/_vendor/cachecontrol/caches/__init__.py +8 -0
  813. package/python/lib/python3.12/site-packages/pip/_vendor/cachecontrol/caches/file_cache.py +145 -0
  814. package/python/lib/python3.12/site-packages/pip/_vendor/cachecontrol/caches/redis_cache.py +48 -0
  815. package/python/lib/python3.12/site-packages/pip/_vendor/cachecontrol/controller.py +511 -0
  816. package/python/lib/python3.12/site-packages/pip/_vendor/cachecontrol/filewrapper.py +121 -0
  817. package/python/lib/python3.12/site-packages/pip/_vendor/cachecontrol/heuristics.py +157 -0
  818. package/python/lib/python3.12/site-packages/pip/_vendor/cachecontrol/py.typed +0 -0
  819. package/python/lib/python3.12/site-packages/pip/_vendor/cachecontrol/serialize.py +146 -0
  820. package/python/lib/python3.12/site-packages/pip/_vendor/cachecontrol/wrapper.py +43 -0
  821. package/python/lib/python3.12/site-packages/pip/_vendor/certifi/LICENSE +20 -0
  822. package/python/lib/python3.12/site-packages/pip/_vendor/certifi/__init__.py +4 -0
  823. package/python/lib/python3.12/site-packages/pip/_vendor/certifi/__main__.py +12 -0
  824. package/python/lib/python3.12/site-packages/pip/_vendor/certifi/cacert.pem +4494 -0
  825. package/python/lib/python3.12/site-packages/pip/_vendor/certifi/core.py +83 -0
  826. package/python/lib/python3.12/site-packages/pip/_vendor/certifi/py.typed +0 -0
  827. package/python/lib/python3.12/site-packages/pip/_vendor/distlib/LICENSE.txt +284 -0
  828. package/python/lib/python3.12/site-packages/pip/_vendor/distlib/__init__.py +33 -0
  829. package/python/lib/python3.12/site-packages/pip/_vendor/distlib/compat.py +1137 -0
  830. package/python/lib/python3.12/site-packages/pip/_vendor/distlib/resources.py +358 -0
  831. package/python/lib/python3.12/site-packages/pip/_vendor/distlib/scripts.py +447 -0
  832. package/python/lib/python3.12/site-packages/pip/_vendor/distlib/t32.exe +0 -0
  833. package/python/lib/python3.12/site-packages/pip/_vendor/distlib/t64-arm.exe +0 -0
  834. package/python/lib/python3.12/site-packages/pip/_vendor/distlib/t64.exe +0 -0
  835. package/python/lib/python3.12/site-packages/pip/_vendor/distlib/util.py +1984 -0
  836. package/python/lib/python3.12/site-packages/pip/_vendor/distlib/w32.exe +0 -0
  837. package/python/lib/python3.12/site-packages/pip/_vendor/distlib/w64-arm.exe +0 -0
  838. package/python/lib/python3.12/site-packages/pip/_vendor/distlib/w64.exe +0 -0
  839. package/python/lib/python3.12/site-packages/pip/_vendor/distro/LICENSE +202 -0
  840. package/python/lib/python3.12/site-packages/pip/_vendor/distro/__init__.py +54 -0
  841. package/python/lib/python3.12/site-packages/pip/_vendor/distro/__main__.py +4 -0
  842. package/python/lib/python3.12/site-packages/pip/_vendor/distro/distro.py +1403 -0
  843. package/python/lib/python3.12/site-packages/pip/_vendor/distro/py.typed +0 -0
  844. package/python/lib/python3.12/site-packages/pip/_vendor/idna/LICENSE.md +31 -0
  845. package/python/lib/python3.12/site-packages/pip/_vendor/idna/__init__.py +45 -0
  846. package/python/lib/python3.12/site-packages/pip/_vendor/idna/codec.py +122 -0
  847. package/python/lib/python3.12/site-packages/pip/_vendor/idna/compat.py +15 -0
  848. package/python/lib/python3.12/site-packages/pip/_vendor/idna/core.py +437 -0
  849. package/python/lib/python3.12/site-packages/pip/_vendor/idna/idnadata.py +4309 -0
  850. package/python/lib/python3.12/site-packages/pip/_vendor/idna/intranges.py +57 -0
  851. package/python/lib/python3.12/site-packages/pip/_vendor/idna/package_data.py +1 -0
  852. package/python/lib/python3.12/site-packages/pip/_vendor/idna/py.typed +0 -0
  853. package/python/lib/python3.12/site-packages/pip/_vendor/idna/uts46data.py +8841 -0
  854. package/python/lib/python3.12/site-packages/pip/_vendor/msgpack/COPYING +14 -0
  855. package/python/lib/python3.12/site-packages/pip/_vendor/msgpack/__init__.py +55 -0
  856. package/python/lib/python3.12/site-packages/pip/_vendor/msgpack/exceptions.py +48 -0
  857. package/python/lib/python3.12/site-packages/pip/_vendor/msgpack/ext.py +170 -0
  858. package/python/lib/python3.12/site-packages/pip/_vendor/msgpack/fallback.py +929 -0
  859. package/python/lib/python3.12/site-packages/pip/_vendor/packaging/LICENSE +3 -0
  860. package/python/lib/python3.12/site-packages/pip/_vendor/packaging/LICENSE.APACHE +177 -0
  861. package/python/lib/python3.12/site-packages/pip/_vendor/packaging/LICENSE.BSD +23 -0
  862. package/python/lib/python3.12/site-packages/pip/_vendor/packaging/__init__.py +15 -0
  863. package/python/lib/python3.12/site-packages/pip/_vendor/packaging/_elffile.py +108 -0
  864. package/python/lib/python3.12/site-packages/pip/_vendor/packaging/_manylinux.py +262 -0
  865. package/python/lib/python3.12/site-packages/pip/_vendor/packaging/_musllinux.py +85 -0
  866. package/python/lib/python3.12/site-packages/pip/_vendor/packaging/_parser.py +393 -0
  867. package/python/lib/python3.12/site-packages/pip/_vendor/packaging/_structures.py +33 -0
  868. package/python/lib/python3.12/site-packages/pip/_vendor/packaging/_tokenizer.py +193 -0
  869. package/python/lib/python3.12/site-packages/pip/_vendor/packaging/dependency_groups.py +302 -0
  870. package/python/lib/python3.12/site-packages/pip/_vendor/packaging/direct_url.py +325 -0
  871. package/python/lib/python3.12/site-packages/pip/_vendor/packaging/errors.py +94 -0
  872. package/python/lib/python3.12/site-packages/pip/_vendor/packaging/licenses/__init__.py +186 -0
  873. package/python/lib/python3.12/site-packages/pip/_vendor/packaging/licenses/_spdx.py +799 -0
  874. package/python/lib/python3.12/site-packages/pip/_vendor/packaging/markers.py +492 -0
  875. package/python/lib/python3.12/site-packages/pip/_vendor/packaging/metadata.py +964 -0
  876. package/python/lib/python3.12/site-packages/pip/_vendor/packaging/py.typed +0 -0
  877. package/python/lib/python3.12/site-packages/pip/_vendor/packaging/pylock.py +905 -0
  878. package/python/lib/python3.12/site-packages/pip/_vendor/packaging/requirements.py +129 -0
  879. package/python/lib/python3.12/site-packages/pip/_vendor/packaging/specifiers.py +1943 -0
  880. package/python/lib/python3.12/site-packages/pip/_vendor/packaging/tags.py +932 -0
  881. package/python/lib/python3.12/site-packages/pip/_vendor/packaging/utils.py +296 -0
  882. package/python/lib/python3.12/site-packages/pip/_vendor/packaging/version.py +1231 -0
  883. package/python/lib/python3.12/site-packages/pip/_vendor/pkg_resources/LICENSE +17 -0
  884. package/python/lib/python3.12/site-packages/pip/_vendor/pkg_resources/__init__.py +3676 -0
  885. package/python/lib/python3.12/site-packages/pip/_vendor/platformdirs/LICENSE +21 -0
  886. package/python/lib/python3.12/site-packages/pip/_vendor/platformdirs/__init__.py +631 -0
  887. package/python/lib/python3.12/site-packages/pip/_vendor/platformdirs/__main__.py +55 -0
  888. package/python/lib/python3.12/site-packages/pip/_vendor/platformdirs/android.py +249 -0
  889. package/python/lib/python3.12/site-packages/pip/_vendor/platformdirs/api.py +299 -0
  890. package/python/lib/python3.12/site-packages/pip/_vendor/platformdirs/macos.py +146 -0
  891. package/python/lib/python3.12/site-packages/pip/_vendor/platformdirs/py.typed +0 -0
  892. package/python/lib/python3.12/site-packages/pip/_vendor/platformdirs/unix.py +272 -0
  893. package/python/lib/python3.12/site-packages/pip/_vendor/platformdirs/version.py +34 -0
  894. package/python/lib/python3.12/site-packages/pip/_vendor/platformdirs/windows.py +278 -0
  895. package/python/lib/python3.12/site-packages/pip/_vendor/pygments/LICENSE +25 -0
  896. package/python/lib/python3.12/site-packages/pip/_vendor/pygments/__init__.py +82 -0
  897. package/python/lib/python3.12/site-packages/pip/_vendor/pygments/__main__.py +17 -0
  898. package/python/lib/python3.12/site-packages/pip/_vendor/pygments/console.py +70 -0
  899. package/python/lib/python3.12/site-packages/pip/_vendor/pygments/filter.py +70 -0
  900. package/python/lib/python3.12/site-packages/pip/_vendor/pygments/filters/__init__.py +940 -0
  901. package/python/lib/python3.12/site-packages/pip/_vendor/pygments/formatter.py +129 -0
  902. package/python/lib/python3.12/site-packages/pip/_vendor/pygments/formatters/__init__.py +157 -0
  903. package/python/lib/python3.12/site-packages/pip/_vendor/pygments/formatters/_mapping.py +23 -0
  904. package/python/lib/python3.12/site-packages/pip/_vendor/pygments/lexer.py +963 -0
  905. package/python/lib/python3.12/site-packages/pip/_vendor/pygments/lexers/__init__.py +362 -0
  906. package/python/lib/python3.12/site-packages/pip/_vendor/pygments/lexers/_mapping.py +602 -0
  907. package/python/lib/python3.12/site-packages/pip/_vendor/pygments/lexers/python.py +1201 -0
  908. package/python/lib/python3.12/site-packages/pip/_vendor/pygments/modeline.py +43 -0
  909. package/python/lib/python3.12/site-packages/pip/_vendor/pygments/plugin.py +72 -0
  910. package/python/lib/python3.12/site-packages/pip/_vendor/pygments/regexopt.py +91 -0
  911. package/python/lib/python3.12/site-packages/pip/_vendor/pygments/scanner.py +104 -0
  912. package/python/lib/python3.12/site-packages/pip/_vendor/pygments/sphinxext.py +247 -0
  913. package/python/lib/python3.12/site-packages/pip/_vendor/pygments/style.py +203 -0
  914. package/python/lib/python3.12/site-packages/pip/_vendor/pygments/styles/__init__.py +61 -0
  915. package/python/lib/python3.12/site-packages/pip/_vendor/pygments/styles/_mapping.py +54 -0
  916. package/python/lib/python3.12/site-packages/pip/_vendor/pygments/token.py +214 -0
  917. package/python/lib/python3.12/site-packages/pip/_vendor/pygments/unistring.py +153 -0
  918. package/python/lib/python3.12/site-packages/pip/_vendor/pygments/util.py +324 -0
  919. package/python/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/LICENSE +21 -0
  920. package/python/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/__init__.py +31 -0
  921. package/python/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_impl.py +410 -0
  922. package/python/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/__init__.py +21 -0
  923. package/python/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py +389 -0
  924. package/python/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/py.typed +0 -0
  925. package/python/lib/python3.12/site-packages/pip/_vendor/requests/LICENSE +175 -0
  926. package/python/lib/python3.12/site-packages/pip/_vendor/requests/__init__.py +178 -0
  927. package/python/lib/python3.12/site-packages/pip/_vendor/requests/__version__.py +14 -0
  928. package/python/lib/python3.12/site-packages/pip/_vendor/requests/_internal_utils.py +51 -0
  929. package/python/lib/python3.12/site-packages/pip/_vendor/requests/adapters.py +697 -0
  930. package/python/lib/python3.12/site-packages/pip/_vendor/requests/api.py +157 -0
  931. package/python/lib/python3.12/site-packages/pip/_vendor/requests/auth.py +314 -0
  932. package/python/lib/python3.12/site-packages/pip/_vendor/requests/certs.py +18 -0
  933. package/python/lib/python3.12/site-packages/pip/_vendor/requests/compat.py +90 -0
  934. package/python/lib/python3.12/site-packages/pip/_vendor/requests/cookies.py +561 -0
  935. package/python/lib/python3.12/site-packages/pip/_vendor/requests/exceptions.py +152 -0
  936. package/python/lib/python3.12/site-packages/pip/_vendor/requests/help.py +124 -0
  937. package/python/lib/python3.12/site-packages/pip/_vendor/requests/hooks.py +34 -0
  938. package/python/lib/python3.12/site-packages/pip/_vendor/requests/models.py +1041 -0
  939. package/python/lib/python3.12/site-packages/pip/_vendor/requests/packages.py +25 -0
  940. package/python/lib/python3.12/site-packages/pip/_vendor/requests/sessions.py +834 -0
  941. package/python/lib/python3.12/site-packages/pip/_vendor/requests/status_codes.py +128 -0
  942. package/python/lib/python3.12/site-packages/pip/_vendor/requests/structures.py +99 -0
  943. package/python/lib/python3.12/site-packages/pip/_vendor/requests/utils.py +1083 -0
  944. package/python/lib/python3.12/site-packages/pip/_vendor/resolvelib/LICENSE +13 -0
  945. package/python/lib/python3.12/site-packages/pip/_vendor/resolvelib/__init__.py +27 -0
  946. package/python/lib/python3.12/site-packages/pip/_vendor/resolvelib/providers.py +196 -0
  947. package/python/lib/python3.12/site-packages/pip/_vendor/resolvelib/py.typed +0 -0
  948. package/python/lib/python3.12/site-packages/pip/_vendor/resolvelib/reporters.py +55 -0
  949. package/python/lib/python3.12/site-packages/pip/_vendor/resolvelib/resolvers/__init__.py +27 -0
  950. package/python/lib/python3.12/site-packages/pip/_vendor/resolvelib/resolvers/abstract.py +47 -0
  951. package/python/lib/python3.12/site-packages/pip/_vendor/resolvelib/resolvers/criterion.py +48 -0
  952. package/python/lib/python3.12/site-packages/pip/_vendor/resolvelib/resolvers/exceptions.py +57 -0
  953. package/python/lib/python3.12/site-packages/pip/_vendor/resolvelib/resolvers/resolution.py +627 -0
  954. package/python/lib/python3.12/site-packages/pip/_vendor/resolvelib/structs.py +209 -0
  955. package/python/lib/python3.12/site-packages/pip/_vendor/rich/LICENSE +19 -0
  956. package/python/lib/python3.12/site-packages/pip/_vendor/rich/__init__.py +177 -0
  957. package/python/lib/python3.12/site-packages/pip/_vendor/rich/__main__.py +245 -0
  958. package/python/lib/python3.12/site-packages/pip/_vendor/rich/_cell_widths.py +454 -0
  959. package/python/lib/python3.12/site-packages/pip/_vendor/rich/_emoji_codes.py +3610 -0
  960. package/python/lib/python3.12/site-packages/pip/_vendor/rich/_emoji_replace.py +32 -0
  961. package/python/lib/python3.12/site-packages/pip/_vendor/rich/_export_format.py +76 -0
  962. package/python/lib/python3.12/site-packages/pip/_vendor/rich/_extension.py +10 -0
  963. package/python/lib/python3.12/site-packages/pip/_vendor/rich/_fileno.py +24 -0
  964. package/python/lib/python3.12/site-packages/pip/_vendor/rich/_inspect.py +268 -0
  965. package/python/lib/python3.12/site-packages/pip/_vendor/rich/_log_render.py +94 -0
  966. package/python/lib/python3.12/site-packages/pip/_vendor/rich/_loop.py +43 -0
  967. package/python/lib/python3.12/site-packages/pip/_vendor/rich/_null_file.py +69 -0
  968. package/python/lib/python3.12/site-packages/pip/_vendor/rich/_palettes.py +309 -0
  969. package/python/lib/python3.12/site-packages/pip/_vendor/rich/_pick.py +17 -0
  970. package/python/lib/python3.12/site-packages/pip/_vendor/rich/_ratio.py +153 -0
  971. package/python/lib/python3.12/site-packages/pip/_vendor/rich/_spinners.py +482 -0
  972. package/python/lib/python3.12/site-packages/pip/_vendor/rich/_stack.py +16 -0
  973. package/python/lib/python3.12/site-packages/pip/_vendor/rich/_timer.py +19 -0
  974. package/python/lib/python3.12/site-packages/pip/_vendor/rich/_win32_console.py +661 -0
  975. package/python/lib/python3.12/site-packages/pip/_vendor/rich/_windows.py +71 -0
  976. package/python/lib/python3.12/site-packages/pip/_vendor/rich/_windows_renderer.py +56 -0
  977. package/python/lib/python3.12/site-packages/pip/_vendor/rich/_wrap.py +93 -0
  978. package/python/lib/python3.12/site-packages/pip/_vendor/rich/abc.py +33 -0
  979. package/python/lib/python3.12/site-packages/pip/_vendor/rich/align.py +306 -0
  980. package/python/lib/python3.12/site-packages/pip/_vendor/rich/ansi.py +241 -0
  981. package/python/lib/python3.12/site-packages/pip/_vendor/rich/bar.py +93 -0
  982. package/python/lib/python3.12/site-packages/pip/_vendor/rich/box.py +474 -0
  983. package/python/lib/python3.12/site-packages/pip/_vendor/rich/cells.py +174 -0
  984. package/python/lib/python3.12/site-packages/pip/_vendor/rich/color.py +621 -0
  985. package/python/lib/python3.12/site-packages/pip/_vendor/rich/color_triplet.py +38 -0
  986. package/python/lib/python3.12/site-packages/pip/_vendor/rich/columns.py +187 -0
  987. package/python/lib/python3.12/site-packages/pip/_vendor/rich/console.py +2680 -0
  988. package/python/lib/python3.12/site-packages/pip/_vendor/rich/constrain.py +37 -0
  989. package/python/lib/python3.12/site-packages/pip/_vendor/rich/containers.py +167 -0
  990. package/python/lib/python3.12/site-packages/pip/_vendor/rich/control.py +219 -0
  991. package/python/lib/python3.12/site-packages/pip/_vendor/rich/default_styles.py +193 -0
  992. package/python/lib/python3.12/site-packages/pip/_vendor/rich/diagnose.py +39 -0
  993. package/python/lib/python3.12/site-packages/pip/_vendor/rich/emoji.py +91 -0
  994. package/python/lib/python3.12/site-packages/pip/_vendor/rich/errors.py +34 -0
  995. package/python/lib/python3.12/site-packages/pip/_vendor/rich/file_proxy.py +57 -0
  996. package/python/lib/python3.12/site-packages/pip/_vendor/rich/filesize.py +88 -0
  997. package/python/lib/python3.12/site-packages/pip/_vendor/rich/highlighter.py +232 -0
  998. package/python/lib/python3.12/site-packages/pip/_vendor/rich/json.py +139 -0
  999. package/python/lib/python3.12/site-packages/pip/_vendor/rich/jupyter.py +101 -0
  1000. package/python/lib/python3.12/site-packages/pip/_vendor/rich/layout.py +442 -0
  1001. package/python/lib/python3.12/site-packages/pip/_vendor/rich/live.py +400 -0
  1002. package/python/lib/python3.12/site-packages/pip/_vendor/rich/live_render.py +106 -0
  1003. package/python/lib/python3.12/site-packages/pip/_vendor/rich/logging.py +297 -0
  1004. package/python/lib/python3.12/site-packages/pip/_vendor/rich/markup.py +251 -0
  1005. package/python/lib/python3.12/site-packages/pip/_vendor/rich/measure.py +151 -0
  1006. package/python/lib/python3.12/site-packages/pip/_vendor/rich/padding.py +141 -0
  1007. package/python/lib/python3.12/site-packages/pip/_vendor/rich/pager.py +34 -0
  1008. package/python/lib/python3.12/site-packages/pip/_vendor/rich/palette.py +100 -0
  1009. package/python/lib/python3.12/site-packages/pip/_vendor/rich/panel.py +317 -0
  1010. package/python/lib/python3.12/site-packages/pip/_vendor/rich/pretty.py +1016 -0
  1011. package/python/lib/python3.12/site-packages/pip/_vendor/rich/progress.py +1715 -0
  1012. package/python/lib/python3.12/site-packages/pip/_vendor/rich/progress_bar.py +223 -0
  1013. package/python/lib/python3.12/site-packages/pip/_vendor/rich/prompt.py +400 -0
  1014. package/python/lib/python3.12/site-packages/pip/_vendor/rich/protocol.py +42 -0
  1015. package/python/lib/python3.12/site-packages/pip/_vendor/rich/py.typed +0 -0
  1016. package/python/lib/python3.12/site-packages/pip/_vendor/rich/region.py +10 -0
  1017. package/python/lib/python3.12/site-packages/pip/_vendor/rich/repr.py +149 -0
  1018. package/python/lib/python3.12/site-packages/pip/_vendor/rich/rule.py +130 -0
  1019. package/python/lib/python3.12/site-packages/pip/_vendor/rich/scope.py +86 -0
  1020. package/python/lib/python3.12/site-packages/pip/_vendor/rich/screen.py +54 -0
  1021. package/python/lib/python3.12/site-packages/pip/_vendor/rich/segment.py +752 -0
  1022. package/python/lib/python3.12/site-packages/pip/_vendor/rich/spinner.py +132 -0
  1023. package/python/lib/python3.12/site-packages/pip/_vendor/rich/status.py +131 -0
  1024. package/python/lib/python3.12/site-packages/pip/_vendor/rich/style.py +792 -0
  1025. package/python/lib/python3.12/site-packages/pip/_vendor/rich/styled.py +42 -0
  1026. package/python/lib/python3.12/site-packages/pip/_vendor/rich/syntax.py +985 -0
  1027. package/python/lib/python3.12/site-packages/pip/_vendor/rich/table.py +1006 -0
  1028. package/python/lib/python3.12/site-packages/pip/_vendor/rich/terminal_theme.py +153 -0
  1029. package/python/lib/python3.12/site-packages/pip/_vendor/rich/text.py +1361 -0
  1030. package/python/lib/python3.12/site-packages/pip/_vendor/rich/theme.py +115 -0
  1031. package/python/lib/python3.12/site-packages/pip/_vendor/rich/themes.py +5 -0
  1032. package/python/lib/python3.12/site-packages/pip/_vendor/rich/traceback.py +899 -0
  1033. package/python/lib/python3.12/site-packages/pip/_vendor/rich/tree.py +257 -0
  1034. package/python/lib/python3.12/site-packages/pip/_vendor/tomli/LICENSE +21 -0
  1035. package/python/lib/python3.12/site-packages/pip/_vendor/tomli/__init__.py +8 -0
  1036. package/python/lib/python3.12/site-packages/pip/_vendor/tomli/_parser.py +788 -0
  1037. package/python/lib/python3.12/site-packages/pip/_vendor/tomli/_re.py +115 -0
  1038. package/python/lib/python3.12/site-packages/pip/_vendor/tomli/_types.py +10 -0
  1039. package/python/lib/python3.12/site-packages/pip/_vendor/tomli/py.typed +1 -0
  1040. package/python/lib/python3.12/site-packages/pip/_vendor/tomli_w/LICENSE +21 -0
  1041. package/python/lib/python3.12/site-packages/pip/_vendor/tomli_w/__init__.py +4 -0
  1042. package/python/lib/python3.12/site-packages/pip/_vendor/tomli_w/_writer.py +229 -0
  1043. package/python/lib/python3.12/site-packages/pip/_vendor/tomli_w/py.typed +1 -0
  1044. package/python/lib/python3.12/site-packages/pip/_vendor/truststore/LICENSE +21 -0
  1045. package/python/lib/python3.12/site-packages/pip/_vendor/truststore/__init__.py +36 -0
  1046. package/python/lib/python3.12/site-packages/pip/_vendor/truststore/_api.py +341 -0
  1047. package/python/lib/python3.12/site-packages/pip/_vendor/truststore/_macos.py +571 -0
  1048. package/python/lib/python3.12/site-packages/pip/_vendor/truststore/_openssl.py +68 -0
  1049. package/python/lib/python3.12/site-packages/pip/_vendor/truststore/_ssl_constants.py +31 -0
  1050. package/python/lib/python3.12/site-packages/pip/_vendor/truststore/_windows.py +567 -0
  1051. package/python/lib/python3.12/site-packages/pip/_vendor/truststore/py.typed +0 -0
  1052. package/python/lib/python3.12/site-packages/pip/_vendor/urllib3/LICENSE.txt +21 -0
  1053. package/python/lib/python3.12/site-packages/pip/_vendor/urllib3/__init__.py +211 -0
  1054. package/python/lib/python3.12/site-packages/pip/_vendor/urllib3/_base_connection.py +165 -0
  1055. package/python/lib/python3.12/site-packages/pip/_vendor/urllib3/_collections.py +487 -0
  1056. package/python/lib/python3.12/site-packages/pip/_vendor/urllib3/_request_methods.py +278 -0
  1057. package/python/lib/python3.12/site-packages/pip/_vendor/urllib3/_version.py +34 -0
  1058. package/python/lib/python3.12/site-packages/pip/_vendor/urllib3/connection.py +1099 -0
  1059. package/python/lib/python3.12/site-packages/pip/_vendor/urllib3/connectionpool.py +1178 -0
  1060. package/python/lib/python3.12/site-packages/pip/_vendor/urllib3/contrib/__init__.py +0 -0
  1061. package/python/lib/python3.12/site-packages/pip/_vendor/urllib3/contrib/emscripten/__init__.py +17 -0
  1062. package/python/lib/python3.12/site-packages/pip/_vendor/urllib3/contrib/emscripten/connection.py +260 -0
  1063. package/python/lib/python3.12/site-packages/pip/_vendor/urllib3/contrib/emscripten/emscripten_fetch_worker.js +110 -0
  1064. package/python/lib/python3.12/site-packages/pip/_vendor/urllib3/contrib/emscripten/fetch.py +726 -0
  1065. package/python/lib/python3.12/site-packages/pip/_vendor/urllib3/contrib/emscripten/request.py +22 -0
  1066. package/python/lib/python3.12/site-packages/pip/_vendor/urllib3/contrib/emscripten/response.py +277 -0
  1067. package/python/lib/python3.12/site-packages/pip/_vendor/urllib3/contrib/pyopenssl.py +564 -0
  1068. package/python/lib/python3.12/site-packages/pip/_vendor/urllib3/contrib/socks.py +228 -0
  1069. package/python/lib/python3.12/site-packages/pip/_vendor/urllib3/exceptions.py +335 -0
  1070. package/python/lib/python3.12/site-packages/pip/_vendor/urllib3/fields.py +341 -0
  1071. package/python/lib/python3.12/site-packages/pip/_vendor/urllib3/filepost.py +89 -0
  1072. package/python/lib/python3.12/site-packages/pip/_vendor/urllib3/http2/__init__.py +53 -0
  1073. package/python/lib/python3.12/site-packages/pip/_vendor/urllib3/http2/connection.py +356 -0
  1074. package/python/lib/python3.12/site-packages/pip/_vendor/urllib3/http2/probe.py +87 -0
  1075. package/python/lib/python3.12/site-packages/pip/_vendor/urllib3/poolmanager.py +651 -0
  1076. package/python/lib/python3.12/site-packages/pip/_vendor/urllib3/py.typed +2 -0
  1077. package/python/lib/python3.12/site-packages/pip/_vendor/urllib3/response.py +1474 -0
  1078. package/python/lib/python3.12/site-packages/pip/_vendor/urllib3/util/__init__.py +42 -0
  1079. package/python/lib/python3.12/site-packages/pip/_vendor/urllib3/util/connection.py +137 -0
  1080. package/python/lib/python3.12/site-packages/pip/_vendor/urllib3/util/proxy.py +43 -0
  1081. package/python/lib/python3.12/site-packages/pip/_vendor/urllib3/util/request.py +254 -0
  1082. package/python/lib/python3.12/site-packages/pip/_vendor/urllib3/util/response.py +101 -0
  1083. package/python/lib/python3.12/site-packages/pip/_vendor/urllib3/util/retry.py +549 -0
  1084. package/python/lib/python3.12/site-packages/pip/_vendor/urllib3/util/ssl_.py +527 -0
  1085. package/python/lib/python3.12/site-packages/pip/_vendor/urllib3/util/ssl_match_hostname.py +159 -0
  1086. package/python/lib/python3.12/site-packages/pip/_vendor/urllib3/util/ssltransport.py +271 -0
  1087. package/python/lib/python3.12/site-packages/pip/_vendor/urllib3/util/timeout.py +275 -0
  1088. package/python/lib/python3.12/site-packages/pip/_vendor/urllib3/util/url.py +469 -0
  1089. package/python/lib/python3.12/site-packages/pip/_vendor/urllib3/util/util.py +42 -0
  1090. package/python/lib/python3.12/site-packages/pip/_vendor/urllib3/util/wait.py +124 -0
  1091. package/python/lib/python3.12/site-packages/pip/_vendor/vendor.txt +18 -0
  1092. package/python/lib/python3.12/site-packages/pip/py.typed +4 -0
  1093. package/python/lib/python3.12/site-packages/pip-26.1.2.dist-info/INSTALLER +1 -0
  1094. package/python/lib/python3.12/site-packages/pip-26.1.2.dist-info/METADATA +109 -0
  1095. package/python/lib/python3.12/site-packages/pip-26.1.2.dist-info/RECORD +866 -0
  1096. package/python/lib/python3.12/site-packages/pip-26.1.2.dist-info/REQUESTED +0 -0
  1097. package/python/lib/python3.12/site-packages/pip-26.1.2.dist-info/WHEEL +4 -0
  1098. package/python/lib/python3.12/site-packages/pip-26.1.2.dist-info/direct_url.json +1 -0
  1099. package/python/lib/python3.12/site-packages/pip-26.1.2.dist-info/entry_points.txt +4 -0
  1100. package/python/lib/python3.12/site-packages/pip-26.1.2.dist-info/licenses/AUTHORS.txt +868 -0
  1101. package/python/lib/python3.12/site-packages/pip-26.1.2.dist-info/licenses/LICENSE.txt +20 -0
  1102. package/python/lib/python3.12/site-packages/pip-26.1.2.dist-info/licenses/src/pip/_vendor/cachecontrol/LICENSE.txt +13 -0
  1103. package/python/lib/python3.12/site-packages/pip-26.1.2.dist-info/licenses/src/pip/_vendor/certifi/LICENSE +20 -0
  1104. package/python/lib/python3.12/site-packages/pip-26.1.2.dist-info/licenses/src/pip/_vendor/distlib/LICENSE.txt +284 -0
  1105. package/python/lib/python3.12/site-packages/pip-26.1.2.dist-info/licenses/src/pip/_vendor/distro/LICENSE +202 -0
  1106. package/python/lib/python3.12/site-packages/pip-26.1.2.dist-info/licenses/src/pip/_vendor/idna/LICENSE.md +31 -0
  1107. package/python/lib/python3.12/site-packages/pip-26.1.2.dist-info/licenses/src/pip/_vendor/msgpack/COPYING +14 -0
  1108. package/python/lib/python3.12/site-packages/pip-26.1.2.dist-info/licenses/src/pip/_vendor/packaging/LICENSE +3 -0
  1109. package/python/lib/python3.12/site-packages/pip-26.1.2.dist-info/licenses/src/pip/_vendor/packaging/LICENSE.APACHE +177 -0
  1110. package/python/lib/python3.12/site-packages/pip-26.1.2.dist-info/licenses/src/pip/_vendor/packaging/LICENSE.BSD +23 -0
  1111. package/python/lib/python3.12/site-packages/pip-26.1.2.dist-info/licenses/src/pip/_vendor/pkg_resources/LICENSE +17 -0
  1112. package/python/lib/python3.12/site-packages/pip-26.1.2.dist-info/licenses/src/pip/_vendor/platformdirs/LICENSE +21 -0
  1113. package/python/lib/python3.12/site-packages/pip-26.1.2.dist-info/licenses/src/pip/_vendor/pygments/LICENSE +25 -0
  1114. package/python/lib/python3.12/site-packages/pip-26.1.2.dist-info/licenses/src/pip/_vendor/pyproject_hooks/LICENSE +21 -0
  1115. package/python/lib/python3.12/site-packages/pip-26.1.2.dist-info/licenses/src/pip/_vendor/requests/LICENSE +175 -0
  1116. package/python/lib/python3.12/site-packages/pip-26.1.2.dist-info/licenses/src/pip/_vendor/resolvelib/LICENSE +13 -0
  1117. package/python/lib/python3.12/site-packages/pip-26.1.2.dist-info/licenses/src/pip/_vendor/rich/LICENSE +19 -0
  1118. package/python/lib/python3.12/site-packages/pip-26.1.2.dist-info/licenses/src/pip/_vendor/tomli/LICENSE +21 -0
  1119. package/python/lib/python3.12/site-packages/pip-26.1.2.dist-info/licenses/src/pip/_vendor/tomli_w/LICENSE +21 -0
  1120. package/python/lib/python3.12/site-packages/pip-26.1.2.dist-info/licenses/src/pip/_vendor/truststore/LICENSE +21 -0
  1121. package/python/lib/python3.12/site-packages/pip-26.1.2.dist-info/licenses/src/pip/_vendor/urllib3/LICENSE.txt +21 -0
  1122. package/python/lib/python3.12/site.py +693 -0
  1123. package/python/lib/python3.12/smtplib.py +1109 -0
  1124. package/python/lib/python3.12/sndhdr.py +271 -0
  1125. package/python/lib/python3.12/socket.py +983 -0
  1126. package/python/lib/python3.12/socketserver.py +863 -0
  1127. package/python/lib/python3.12/sqlite3/__init__.py +70 -0
  1128. package/python/lib/python3.12/sqlite3/__main__.py +127 -0
  1129. package/python/lib/python3.12/sqlite3/dbapi2.py +108 -0
  1130. package/python/lib/python3.12/sqlite3/dump.py +89 -0
  1131. package/python/lib/python3.12/sre_compile.py +7 -0
  1132. package/python/lib/python3.12/sre_constants.py +7 -0
  1133. package/python/lib/python3.12/sre_parse.py +7 -0
  1134. package/python/lib/python3.12/ssl.py +1488 -0
  1135. package/python/lib/python3.12/stat.py +195 -0
  1136. package/python/lib/python3.12/statistics.py +1454 -0
  1137. package/python/lib/python3.12/string.py +309 -0
  1138. package/python/lib/python3.12/stringprep.py +272 -0
  1139. package/python/lib/python3.12/struct.py +15 -0
  1140. package/python/lib/python3.12/subprocess.py +2216 -0
  1141. package/python/lib/python3.12/sunau.py +533 -0
  1142. package/python/lib/python3.12/symtable.py +362 -0
  1143. package/python/lib/python3.12/sysconfig.py +894 -0
  1144. package/python/lib/python3.12/tabnanny.py +340 -0
  1145. package/python/lib/python3.12/tarfile.py +3031 -0
  1146. package/python/lib/python3.12/telnetlib.py +680 -0
  1147. package/python/lib/python3.12/tempfile.py +956 -0
  1148. package/python/lib/python3.12/textwrap.py +491 -0
  1149. package/python/lib/python3.12/this.py +28 -0
  1150. package/python/lib/python3.12/threading.py +1708 -0
  1151. package/python/lib/python3.12/timeit.py +381 -0
  1152. package/python/lib/python3.12/token.py +143 -0
  1153. package/python/lib/python3.12/tokenize.py +594 -0
  1154. package/python/lib/python3.12/tomllib/__init__.py +10 -0
  1155. package/python/lib/python3.12/tomllib/_parser.py +691 -0
  1156. package/python/lib/python3.12/tomllib/_re.py +107 -0
  1157. package/python/lib/python3.12/tomllib/_types.py +10 -0
  1158. package/python/lib/python3.12/trace.py +748 -0
  1159. package/python/lib/python3.12/traceback.py +1187 -0
  1160. package/python/lib/python3.12/tracemalloc.py +560 -0
  1161. package/python/lib/python3.12/tty.py +73 -0
  1162. package/python/lib/python3.12/turtle.py +4207 -0
  1163. package/python/lib/python3.12/types.py +333 -0
  1164. package/python/lib/python3.12/typing.py +3494 -0
  1165. package/python/lib/python3.12/unittest/__init__.py +85 -0
  1166. package/python/lib/python3.12/unittest/__main__.py +18 -0
  1167. package/python/lib/python3.12/unittest/_log.py +86 -0
  1168. package/python/lib/python3.12/unittest/async_case.py +143 -0
  1169. package/python/lib/python3.12/unittest/case.py +1456 -0
  1170. package/python/lib/python3.12/unittest/loader.py +497 -0
  1171. package/python/lib/python3.12/unittest/main.py +291 -0
  1172. package/python/lib/python3.12/unittest/mock.py +3054 -0
  1173. package/python/lib/python3.12/unittest/result.py +256 -0
  1174. package/python/lib/python3.12/unittest/runner.py +292 -0
  1175. package/python/lib/python3.12/unittest/signals.py +71 -0
  1176. package/python/lib/python3.12/unittest/suite.py +379 -0
  1177. package/python/lib/python3.12/unittest/util.py +170 -0
  1178. package/python/lib/python3.12/urllib/__init__.py +0 -0
  1179. package/python/lib/python3.12/urllib/error.py +74 -0
  1180. package/python/lib/python3.12/urllib/parse.py +1262 -0
  1181. package/python/lib/python3.12/urllib/request.py +2816 -0
  1182. package/python/lib/python3.12/urllib/response.py +84 -0
  1183. package/python/lib/python3.12/urllib/robotparser.py +275 -0
  1184. package/python/lib/python3.12/uu.py +216 -0
  1185. package/python/lib/python3.12/uuid.py +793 -0
  1186. package/python/lib/python3.12/venv/__init__.py +608 -0
  1187. package/python/lib/python3.12/venv/__main__.py +10 -0
  1188. package/python/lib/python3.12/venv/scripts/common/Activate.ps1 +247 -0
  1189. package/python/lib/python3.12/venv/scripts/common/activate +76 -0
  1190. package/python/lib/python3.12/venv/scripts/posix/activate.csh +27 -0
  1191. package/python/lib/python3.12/venv/scripts/posix/activate.fish +69 -0
  1192. package/python/lib/python3.12/warnings.py +598 -0
  1193. package/python/lib/python3.12/wave.py +653 -0
  1194. package/python/lib/python3.12/weakref.py +674 -0
  1195. package/python/lib/python3.12/webbrowser.py +689 -0
  1196. package/python/lib/python3.12/wsgiref/__init__.py +25 -0
  1197. package/python/lib/python3.12/wsgiref/handlers.py +573 -0
  1198. package/python/lib/python3.12/wsgiref/headers.py +192 -0
  1199. package/python/lib/python3.12/wsgiref/simple_server.py +165 -0
  1200. package/python/lib/python3.12/wsgiref/types.py +54 -0
  1201. package/python/lib/python3.12/wsgiref/util.py +159 -0
  1202. package/python/lib/python3.12/wsgiref/validate.py +438 -0
  1203. package/python/lib/python3.12/xdrlib.py +242 -0
  1204. package/python/lib/python3.12/xml/__init__.py +20 -0
  1205. package/python/lib/python3.12/xml/dom/NodeFilter.py +27 -0
  1206. package/python/lib/python3.12/xml/dom/__init__.py +140 -0
  1207. package/python/lib/python3.12/xml/dom/domreg.py +99 -0
  1208. package/python/lib/python3.12/xml/dom/expatbuilder.py +962 -0
  1209. package/python/lib/python3.12/xml/dom/minicompat.py +109 -0
  1210. package/python/lib/python3.12/xml/dom/minidom.py +2008 -0
  1211. package/python/lib/python3.12/xml/dom/pulldom.py +336 -0
  1212. package/python/lib/python3.12/xml/dom/xmlbuilder.py +389 -0
  1213. package/python/lib/python3.12/xml/etree/ElementInclude.py +186 -0
  1214. package/python/lib/python3.12/xml/etree/ElementPath.py +423 -0
  1215. package/python/lib/python3.12/xml/etree/ElementTree.py +2085 -0
  1216. package/python/lib/python3.12/xml/etree/__init__.py +33 -0
  1217. package/python/lib/python3.12/xml/etree/cElementTree.py +3 -0
  1218. package/python/lib/python3.12/xml/parsers/__init__.py +8 -0
  1219. package/python/lib/python3.12/xml/parsers/expat.py +8 -0
  1220. package/python/lib/python3.12/xml/sax/__init__.py +94 -0
  1221. package/python/lib/python3.12/xml/sax/_exceptions.py +127 -0
  1222. package/python/lib/python3.12/xml/sax/expatreader.py +454 -0
  1223. package/python/lib/python3.12/xml/sax/handler.py +387 -0
  1224. package/python/lib/python3.12/xml/sax/saxutils.py +369 -0
  1225. package/python/lib/python3.12/xml/sax/xmlreader.py +378 -0
  1226. package/python/lib/python3.12/xmlrpc/__init__.py +1 -0
  1227. package/python/lib/python3.12/xmlrpc/client.py +1529 -0
  1228. package/python/lib/python3.12/xmlrpc/server.py +1002 -0
  1229. package/python/lib/python3.12/zipapp.py +206 -0
  1230. package/python/lib/python3.12/zipfile/__init__.py +2340 -0
  1231. package/python/lib/python3.12/zipfile/__main__.py +4 -0
  1232. package/python/lib/python3.12/zipfile/_path/__init__.py +412 -0
  1233. package/python/lib/python3.12/zipfile/_path/glob.py +53 -0
  1234. package/python/lib/python3.12/zipimport.py +712 -0
  1235. package/python/lib/python3.12/zoneinfo/__init__.py +31 -0
  1236. package/python/lib/python3.12/zoneinfo/_common.py +164 -0
  1237. package/python/lib/python3.12/zoneinfo/_tzpath.py +181 -0
  1238. package/python/lib/python3.12/zoneinfo/_zoneinfo.py +772 -0
@@ -0,0 +1,3031 @@
1
+ #!/usr/bin/env python3
2
+ #-------------------------------------------------------------------
3
+ # tarfile.py
4
+ #-------------------------------------------------------------------
5
+ # Copyright (C) 2002 Lars Gustaebel <lars@gustaebel.de>
6
+ # All rights reserved.
7
+ #
8
+ # Permission is hereby granted, free of charge, to any person
9
+ # obtaining a copy of this software and associated documentation
10
+ # files (the "Software"), to deal in the Software without
11
+ # restriction, including without limitation the rights to use,
12
+ # copy, modify, merge, publish, distribute, sublicense, and/or sell
13
+ # copies of the Software, and to permit persons to whom the
14
+ # Software is furnished to do so, subject to the following
15
+ # conditions:
16
+ #
17
+ # The above copyright notice and this permission notice shall be
18
+ # included in all copies or substantial portions of the Software.
19
+ #
20
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
22
+ # OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
24
+ # HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
25
+ # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
26
+ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
27
+ # OTHER DEALINGS IN THE SOFTWARE.
28
+ #
29
+ """Read from and write to tar format archives.
30
+ """
31
+
32
+ version = "0.9.0"
33
+ __author__ = "Lars Gust\u00e4bel (lars@gustaebel.de)"
34
+ __credits__ = "Gustavo Niemeyer, Niels Gust\u00e4bel, Richard Townsend."
35
+
36
+ #---------
37
+ # Imports
38
+ #---------
39
+ from builtins import open as bltn_open
40
+ import sys
41
+ import os
42
+ import io
43
+ import shutil
44
+ import stat
45
+ import time
46
+ import struct
47
+ import copy
48
+ import re
49
+ import warnings
50
+
51
+ try:
52
+ import pwd
53
+ except ImportError:
54
+ pwd = None
55
+ try:
56
+ import grp
57
+ except ImportError:
58
+ grp = None
59
+
60
+ # os.symlink on Windows prior to 6.0 raises NotImplementedError
61
+ # OSError (winerror=1314) will be raised if the caller does not hold the
62
+ # SeCreateSymbolicLinkPrivilege privilege
63
+ symlink_exception = (AttributeError, NotImplementedError, OSError)
64
+
65
+ # from tarfile import *
66
+ __all__ = ["TarFile", "TarInfo", "is_tarfile", "TarError", "ReadError",
67
+ "CompressionError", "StreamError", "ExtractError", "HeaderError",
68
+ "ENCODING", "USTAR_FORMAT", "GNU_FORMAT", "PAX_FORMAT",
69
+ "DEFAULT_FORMAT", "open","fully_trusted_filter", "data_filter",
70
+ "tar_filter", "FilterError", "AbsoluteLinkError",
71
+ "OutsideDestinationError", "SpecialFileError", "AbsolutePathError",
72
+ "LinkOutsideDestinationError"]
73
+
74
+
75
+ #---------------------------------------------------------
76
+ # tar constants
77
+ #---------------------------------------------------------
78
+ NUL = b"\0" # the null character
79
+ BLOCKSIZE = 512 # length of processing blocks
80
+ RECORDSIZE = BLOCKSIZE * 20 # length of records
81
+ GNU_MAGIC = b"ustar \0" # magic gnu tar string
82
+ POSIX_MAGIC = b"ustar\x0000" # magic posix tar string
83
+
84
+ LENGTH_NAME = 100 # maximum length of a filename
85
+ LENGTH_LINK = 100 # maximum length of a linkname
86
+ LENGTH_PREFIX = 155 # maximum length of the prefix field
87
+
88
+ REGTYPE = b"0" # regular file
89
+ AREGTYPE = b"\0" # regular file
90
+ LNKTYPE = b"1" # link (inside tarfile)
91
+ SYMTYPE = b"2" # symbolic link
92
+ CHRTYPE = b"3" # character special device
93
+ BLKTYPE = b"4" # block special device
94
+ DIRTYPE = b"5" # directory
95
+ FIFOTYPE = b"6" # fifo special device
96
+ CONTTYPE = b"7" # contiguous file
97
+
98
+ GNUTYPE_LONGNAME = b"L" # GNU tar longname
99
+ GNUTYPE_LONGLINK = b"K" # GNU tar longlink
100
+ GNUTYPE_SPARSE = b"S" # GNU tar sparse file
101
+
102
+ XHDTYPE = b"x" # POSIX.1-2001 extended header
103
+ XGLTYPE = b"g" # POSIX.1-2001 global header
104
+ SOLARIS_XHDTYPE = b"X" # Solaris extended header
105
+
106
+ USTAR_FORMAT = 0 # POSIX.1-1988 (ustar) format
107
+ GNU_FORMAT = 1 # GNU tar format
108
+ PAX_FORMAT = 2 # POSIX.1-2001 (pax) format
109
+ DEFAULT_FORMAT = PAX_FORMAT
110
+
111
+ #---------------------------------------------------------
112
+ # tarfile constants
113
+ #---------------------------------------------------------
114
+ # File types that tarfile supports:
115
+ SUPPORTED_TYPES = (REGTYPE, AREGTYPE, LNKTYPE,
116
+ SYMTYPE, DIRTYPE, FIFOTYPE,
117
+ CONTTYPE, CHRTYPE, BLKTYPE,
118
+ GNUTYPE_LONGNAME, GNUTYPE_LONGLINK,
119
+ GNUTYPE_SPARSE)
120
+
121
+ # File types that will be treated as a regular file.
122
+ REGULAR_TYPES = (REGTYPE, AREGTYPE,
123
+ CONTTYPE, GNUTYPE_SPARSE)
124
+
125
+ # File types that are part of the GNU tar format.
126
+ GNU_TYPES = (GNUTYPE_LONGNAME, GNUTYPE_LONGLINK,
127
+ GNUTYPE_SPARSE)
128
+
129
+ # Fields from a pax header that override a TarInfo attribute.
130
+ PAX_FIELDS = ("path", "linkpath", "size", "mtime",
131
+ "uid", "gid", "uname", "gname")
132
+
133
+ # Fields from a pax header that are affected by hdrcharset.
134
+ PAX_NAME_FIELDS = {"path", "linkpath", "uname", "gname"}
135
+
136
+ # Fields in a pax header that are numbers, all other fields
137
+ # are treated as strings.
138
+ PAX_NUMBER_FIELDS = {
139
+ "atime": float,
140
+ "ctime": float,
141
+ "mtime": float,
142
+ "uid": int,
143
+ "gid": int,
144
+ "size": int
145
+ }
146
+
147
+ #---------------------------------------------------------
148
+ # initialization
149
+ #---------------------------------------------------------
150
+ if os.name == "nt":
151
+ ENCODING = "utf-8"
152
+ else:
153
+ ENCODING = sys.getfilesystemencoding()
154
+
155
+ #---------------------------------------------------------
156
+ # Some useful functions
157
+ #---------------------------------------------------------
158
+
159
+ def stn(s, length, encoding, errors):
160
+ """Convert a string to a null-terminated bytes object.
161
+ """
162
+ if s is None:
163
+ raise ValueError("metadata cannot contain None")
164
+ s = s.encode(encoding, errors)
165
+ return s[:length] + (length - len(s)) * NUL
166
+
167
+ def nts(s, encoding, errors):
168
+ """Convert a null-terminated bytes object to a string.
169
+ """
170
+ p = s.find(b"\0")
171
+ if p != -1:
172
+ s = s[:p]
173
+ return s.decode(encoding, errors)
174
+
175
+ def nti(s):
176
+ """Convert a number field to a python number.
177
+ """
178
+ # There are two possible encodings for a number field, see
179
+ # itn() below.
180
+ if s[0] in (0o200, 0o377):
181
+ n = 0
182
+ for i in range(len(s) - 1):
183
+ n <<= 8
184
+ n += s[i + 1]
185
+ if s[0] == 0o377:
186
+ n = -(256 ** (len(s) - 1) - n)
187
+ else:
188
+ try:
189
+ s = nts(s, "ascii", "strict")
190
+ n = int(s.strip() or "0", 8)
191
+ except ValueError:
192
+ raise InvalidHeaderError("invalid header")
193
+ return n
194
+
195
+ def itn(n, digits=8, format=DEFAULT_FORMAT):
196
+ """Convert a python number to a number field.
197
+ """
198
+ # POSIX 1003.1-1988 requires numbers to be encoded as a string of
199
+ # octal digits followed by a null-byte, this allows values up to
200
+ # (8**(digits-1))-1. GNU tar allows storing numbers greater than
201
+ # that if necessary. A leading 0o200 or 0o377 byte indicate this
202
+ # particular encoding, the following digits-1 bytes are a big-endian
203
+ # base-256 representation. This allows values up to (256**(digits-1))-1.
204
+ # A 0o200 byte indicates a positive number, a 0o377 byte a negative
205
+ # number.
206
+ original_n = n
207
+ n = int(n)
208
+ if 0 <= n < 8 ** (digits - 1):
209
+ s = bytes("%0*o" % (digits - 1, n), "ascii") + NUL
210
+ elif format == GNU_FORMAT and -256 ** (digits - 1) <= n < 256 ** (digits - 1):
211
+ if n >= 0:
212
+ s = bytearray([0o200])
213
+ else:
214
+ s = bytearray([0o377])
215
+ n = 256 ** digits + n
216
+
217
+ for i in range(digits - 1):
218
+ s.insert(1, n & 0o377)
219
+ n >>= 8
220
+ else:
221
+ raise ValueError("overflow in number field")
222
+
223
+ return s
224
+
225
+ def calc_chksums(buf):
226
+ """Calculate the checksum for a member's header by summing up all
227
+ characters except for the chksum field which is treated as if
228
+ it was filled with spaces. According to the GNU tar sources,
229
+ some tars (Sun and NeXT) calculate chksum with signed char,
230
+ which will be different if there are chars in the buffer with
231
+ the high bit set. So we calculate two checksums, unsigned and
232
+ signed.
233
+ """
234
+ unsigned_chksum = 256 + sum(struct.unpack_from("148B8x356B", buf))
235
+ signed_chksum = 256 + sum(struct.unpack_from("148b8x356b", buf))
236
+ return unsigned_chksum, signed_chksum
237
+
238
+ def copyfileobj(src, dst, length=None, exception=OSError, bufsize=None):
239
+ """Copy length bytes from fileobj src to fileobj dst.
240
+ If length is None, copy the entire content.
241
+ """
242
+ bufsize = bufsize or 16 * 1024
243
+ if length == 0:
244
+ return
245
+ if length is None:
246
+ shutil.copyfileobj(src, dst, bufsize)
247
+ return
248
+
249
+ blocks, remainder = divmod(length, bufsize)
250
+ for b in range(blocks):
251
+ buf = src.read(bufsize)
252
+ if len(buf) < bufsize:
253
+ raise exception("unexpected end of data")
254
+ dst.write(buf)
255
+
256
+ if remainder != 0:
257
+ buf = src.read(remainder)
258
+ if len(buf) < remainder:
259
+ raise exception("unexpected end of data")
260
+ dst.write(buf)
261
+ return
262
+
263
+ def _safe_print(s):
264
+ encoding = getattr(sys.stdout, 'encoding', None)
265
+ if encoding is not None:
266
+ s = s.encode(encoding, 'backslashreplace').decode(encoding)
267
+ print(s, end=' ')
268
+
269
+
270
+ class TarError(Exception):
271
+ """Base exception."""
272
+ pass
273
+ class ExtractError(TarError):
274
+ """General exception for extract errors."""
275
+ pass
276
+ class ReadError(TarError):
277
+ """Exception for unreadable tar archives."""
278
+ pass
279
+ class CompressionError(TarError):
280
+ """Exception for unavailable compression methods."""
281
+ pass
282
+ class StreamError(TarError):
283
+ """Exception for unsupported operations on stream-like TarFiles."""
284
+ pass
285
+ class HeaderError(TarError):
286
+ """Base exception for header errors."""
287
+ pass
288
+ class EmptyHeaderError(HeaderError):
289
+ """Exception for empty headers."""
290
+ pass
291
+ class TruncatedHeaderError(HeaderError):
292
+ """Exception for truncated headers."""
293
+ pass
294
+ class EOFHeaderError(HeaderError):
295
+ """Exception for end of file headers."""
296
+ pass
297
+ class InvalidHeaderError(HeaderError):
298
+ """Exception for invalid headers."""
299
+ pass
300
+ class SubsequentHeaderError(HeaderError):
301
+ """Exception for missing and invalid extended headers."""
302
+ pass
303
+
304
+ #---------------------------
305
+ # internal stream interface
306
+ #---------------------------
307
+ class _LowLevelFile:
308
+ """Low-level file object. Supports reading and writing.
309
+ It is used instead of a regular file object for streaming
310
+ access.
311
+ """
312
+
313
+ def __init__(self, name, mode):
314
+ mode = {
315
+ "r": os.O_RDONLY,
316
+ "w": os.O_WRONLY | os.O_CREAT | os.O_TRUNC,
317
+ }[mode]
318
+ if hasattr(os, "O_BINARY"):
319
+ mode |= os.O_BINARY
320
+ self.fd = os.open(name, mode, 0o666)
321
+
322
+ def close(self):
323
+ os.close(self.fd)
324
+
325
+ def read(self, size):
326
+ return os.read(self.fd, size)
327
+
328
+ def write(self, s):
329
+ os.write(self.fd, s)
330
+
331
+ class _Stream:
332
+ """Class that serves as an adapter between TarFile and
333
+ a stream-like object. The stream-like object only
334
+ needs to have a read() or write() method that works with bytes,
335
+ and the method is accessed blockwise.
336
+ Use of gzip or bzip2 compression is possible.
337
+ A stream-like object could be for example: sys.stdin.buffer,
338
+ sys.stdout.buffer, a socket, a tape device etc.
339
+
340
+ _Stream is intended to be used only internally.
341
+ """
342
+
343
+ def __init__(self, name, mode, comptype, fileobj, bufsize,
344
+ compresslevel):
345
+ """Construct a _Stream object.
346
+ """
347
+ self._extfileobj = True
348
+ if fileobj is None:
349
+ fileobj = _LowLevelFile(name, mode)
350
+ self._extfileobj = False
351
+
352
+ if comptype == '*':
353
+ # Enable transparent compression detection for the
354
+ # stream interface
355
+ fileobj = _StreamProxy(fileobj)
356
+ comptype = fileobj.getcomptype()
357
+
358
+ self.name = name or ""
359
+ self.mode = mode
360
+ self.comptype = comptype
361
+ self.fileobj = fileobj
362
+ self.bufsize = bufsize
363
+ self.buf = b""
364
+ self.pos = 0
365
+ self.closed = False
366
+
367
+ try:
368
+ if comptype == "gz":
369
+ try:
370
+ import zlib
371
+ except ImportError:
372
+ raise CompressionError("zlib module is not available") from None
373
+ self.zlib = zlib
374
+ self.crc = zlib.crc32(b"")
375
+ if mode == "r":
376
+ self.exception = zlib.error
377
+ self._init_read_gz()
378
+ else:
379
+ self._init_write_gz(compresslevel)
380
+
381
+ elif comptype == "bz2":
382
+ try:
383
+ import bz2
384
+ except ImportError:
385
+ raise CompressionError("bz2 module is not available") from None
386
+ if mode == "r":
387
+ self.dbuf = b""
388
+ self.cmp = bz2.BZ2Decompressor()
389
+ self.exception = OSError
390
+ else:
391
+ self.cmp = bz2.BZ2Compressor(compresslevel)
392
+
393
+ elif comptype == "xz":
394
+ try:
395
+ import lzma
396
+ except ImportError:
397
+ raise CompressionError("lzma module is not available") from None
398
+ if mode == "r":
399
+ self.dbuf = b""
400
+ self.cmp = lzma.LZMADecompressor()
401
+ self.exception = lzma.LZMAError
402
+ else:
403
+ self.cmp = lzma.LZMACompressor()
404
+
405
+ elif comptype != "tar":
406
+ raise CompressionError("unknown compression type %r" % comptype)
407
+
408
+ except:
409
+ if not self._extfileobj:
410
+ self.fileobj.close()
411
+ self.closed = True
412
+ raise
413
+
414
+ def __del__(self):
415
+ if hasattr(self, "closed") and not self.closed:
416
+ self.close()
417
+
418
+ def _init_write_gz(self, compresslevel):
419
+ """Initialize for writing with gzip compression.
420
+ """
421
+ self.cmp = self.zlib.compressobj(compresslevel,
422
+ self.zlib.DEFLATED,
423
+ -self.zlib.MAX_WBITS,
424
+ self.zlib.DEF_MEM_LEVEL,
425
+ 0)
426
+ timestamp = struct.pack("<L", int(time.time()))
427
+ self.__write(b"\037\213\010\010" + timestamp + b"\002\377")
428
+ if self.name.endswith(".gz"):
429
+ self.name = self.name[:-3]
430
+ # Honor "directory components removed" from RFC1952
431
+ self.name = os.path.basename(self.name)
432
+ # RFC1952 says we must use ISO-8859-1 for the FNAME field.
433
+ self.__write(self.name.encode("iso-8859-1", "replace") + NUL)
434
+
435
+ def write(self, s):
436
+ """Write string s to the stream.
437
+ """
438
+ if self.comptype == "gz":
439
+ self.crc = self.zlib.crc32(s, self.crc)
440
+ self.pos += len(s)
441
+ if self.comptype != "tar":
442
+ s = self.cmp.compress(s)
443
+ self.__write(s)
444
+
445
+ def __write(self, s):
446
+ """Write string s to the stream if a whole new block
447
+ is ready to be written.
448
+ """
449
+ self.buf += s
450
+ while len(self.buf) > self.bufsize:
451
+ self.fileobj.write(self.buf[:self.bufsize])
452
+ self.buf = self.buf[self.bufsize:]
453
+
454
+ def close(self):
455
+ """Close the _Stream object. No operation should be
456
+ done on it afterwards.
457
+ """
458
+ if self.closed:
459
+ return
460
+
461
+ self.closed = True
462
+ try:
463
+ if self.mode == "w" and self.comptype != "tar":
464
+ self.buf += self.cmp.flush()
465
+
466
+ if self.mode == "w" and self.buf:
467
+ self.fileobj.write(self.buf)
468
+ self.buf = b""
469
+ if self.comptype == "gz":
470
+ self.fileobj.write(struct.pack("<L", self.crc))
471
+ self.fileobj.write(struct.pack("<L", self.pos & 0xffffFFFF))
472
+ finally:
473
+ if not self._extfileobj:
474
+ self.fileobj.close()
475
+
476
+ def _init_read_gz(self):
477
+ """Initialize for reading a gzip compressed fileobj.
478
+ """
479
+ self.cmp = self.zlib.decompressobj(-self.zlib.MAX_WBITS)
480
+ self.dbuf = b""
481
+
482
+ # taken from gzip.GzipFile with some alterations
483
+ if self.__read(2) != b"\037\213":
484
+ raise ReadError("not a gzip file")
485
+ if self.__read(1) != b"\010":
486
+ raise CompressionError("unsupported compression method")
487
+
488
+ flag = ord(self.__read(1))
489
+ self.__read(6)
490
+
491
+ if flag & 4:
492
+ xlen = ord(self.__read(1)) + 256 * ord(self.__read(1))
493
+ self.read(xlen)
494
+ if flag & 8:
495
+ while True:
496
+ s = self.__read(1)
497
+ if not s or s == NUL:
498
+ break
499
+ if flag & 16:
500
+ while True:
501
+ s = self.__read(1)
502
+ if not s or s == NUL:
503
+ break
504
+ if flag & 2:
505
+ self.__read(2)
506
+
507
+ def tell(self):
508
+ """Return the stream's file pointer position.
509
+ """
510
+ return self.pos
511
+
512
+ def seek(self, pos=0):
513
+ """Set the stream's file pointer to pos. Negative seeking
514
+ is forbidden.
515
+ """
516
+ if pos - self.pos >= 0:
517
+ blocks, remainder = divmod(pos - self.pos, self.bufsize)
518
+ for i in range(blocks):
519
+ self.read(self.bufsize)
520
+ self.read(remainder)
521
+ else:
522
+ raise StreamError("seeking backwards is not allowed")
523
+ return self.pos
524
+
525
+ def read(self, size):
526
+ """Return the next size number of bytes from the stream."""
527
+ assert size is not None
528
+ buf = self._read(size)
529
+ self.pos += len(buf)
530
+ return buf
531
+
532
+ def _read(self, size):
533
+ """Return size bytes from the stream.
534
+ """
535
+ if self.comptype == "tar":
536
+ return self.__read(size)
537
+
538
+ c = len(self.dbuf)
539
+ t = [self.dbuf]
540
+ while c < size:
541
+ # Skip underlying buffer to avoid unaligned double buffering.
542
+ if self.buf:
543
+ buf = self.buf
544
+ self.buf = b""
545
+ else:
546
+ buf = self.fileobj.read(self.bufsize)
547
+ if not buf:
548
+ break
549
+ try:
550
+ buf = self.cmp.decompress(buf)
551
+ except self.exception as e:
552
+ raise ReadError("invalid compressed data") from e
553
+ t.append(buf)
554
+ c += len(buf)
555
+ t = b"".join(t)
556
+ self.dbuf = t[size:]
557
+ return t[:size]
558
+
559
+ def __read(self, size):
560
+ """Return size bytes from stream. If internal buffer is empty,
561
+ read another block from the stream.
562
+ """
563
+ c = len(self.buf)
564
+ t = [self.buf]
565
+ while c < size:
566
+ buf = self.fileobj.read(self.bufsize)
567
+ if not buf:
568
+ break
569
+ t.append(buf)
570
+ c += len(buf)
571
+ t = b"".join(t)
572
+ self.buf = t[size:]
573
+ return t[:size]
574
+ # class _Stream
575
+
576
+ class _StreamProxy(object):
577
+ """Small proxy class that enables transparent compression
578
+ detection for the Stream interface (mode 'r|*').
579
+ """
580
+
581
+ def __init__(self, fileobj):
582
+ self.fileobj = fileobj
583
+ self.buf = self.fileobj.read(BLOCKSIZE)
584
+
585
+ def read(self, size):
586
+ self.read = self.fileobj.read
587
+ return self.buf
588
+
589
+ def getcomptype(self):
590
+ if self.buf.startswith(b"\x1f\x8b\x08"):
591
+ return "gz"
592
+ elif self.buf[0:3] == b"BZh" and self.buf[4:10] == b"1AY&SY":
593
+ return "bz2"
594
+ elif self.buf.startswith((b"\x5d\x00\x00\x80", b"\xfd7zXZ")):
595
+ return "xz"
596
+ else:
597
+ return "tar"
598
+
599
+ def close(self):
600
+ self.fileobj.close()
601
+ # class StreamProxy
602
+
603
+ #------------------------
604
+ # Extraction file object
605
+ #------------------------
606
+ class _FileInFile(object):
607
+ """A thin wrapper around an existing file object that
608
+ provides a part of its data as an individual file
609
+ object.
610
+ """
611
+
612
+ def __init__(self, fileobj, offset, size, name, blockinfo=None):
613
+ self.fileobj = fileobj
614
+ self.offset = offset
615
+ self.size = size
616
+ self.position = 0
617
+ self.name = name
618
+ self.closed = False
619
+
620
+ if blockinfo is None:
621
+ blockinfo = [(0, size)]
622
+
623
+ # Construct a map with data and zero blocks.
624
+ self.map_index = 0
625
+ self.map = []
626
+ lastpos = 0
627
+ realpos = self.offset
628
+ for offset, size in blockinfo:
629
+ if offset > lastpos:
630
+ self.map.append((False, lastpos, offset, None))
631
+ self.map.append((True, offset, offset + size, realpos))
632
+ realpos += size
633
+ lastpos = offset + size
634
+ if lastpos < self.size:
635
+ self.map.append((False, lastpos, self.size, None))
636
+
637
+ def flush(self):
638
+ pass
639
+
640
+ def readable(self):
641
+ return True
642
+
643
+ def writable(self):
644
+ return False
645
+
646
+ def seekable(self):
647
+ return self.fileobj.seekable()
648
+
649
+ def tell(self):
650
+ """Return the current file position.
651
+ """
652
+ return self.position
653
+
654
+ def seek(self, position, whence=io.SEEK_SET):
655
+ """Seek to a position in the file.
656
+ """
657
+ if whence == io.SEEK_SET:
658
+ self.position = min(max(position, 0), self.size)
659
+ elif whence == io.SEEK_CUR:
660
+ if position < 0:
661
+ self.position = max(self.position + position, 0)
662
+ else:
663
+ self.position = min(self.position + position, self.size)
664
+ elif whence == io.SEEK_END:
665
+ self.position = max(min(self.size + position, self.size), 0)
666
+ else:
667
+ raise ValueError("Invalid argument")
668
+ return self.position
669
+
670
+ def read(self, size=None):
671
+ """Read data from the file.
672
+ """
673
+ if size is None:
674
+ size = self.size - self.position
675
+ else:
676
+ size = min(size, self.size - self.position)
677
+
678
+ buf = b""
679
+ while size > 0:
680
+ while True:
681
+ data, start, stop, offset = self.map[self.map_index]
682
+ if start <= self.position < stop:
683
+ break
684
+ else:
685
+ self.map_index += 1
686
+ if self.map_index == len(self.map):
687
+ self.map_index = 0
688
+ length = min(size, stop - self.position)
689
+ if data:
690
+ self.fileobj.seek(offset + (self.position - start))
691
+ b = self.fileobj.read(length)
692
+ if len(b) != length:
693
+ raise ReadError("unexpected end of data")
694
+ buf += b
695
+ else:
696
+ buf += NUL * length
697
+ size -= length
698
+ self.position += length
699
+ return buf
700
+
701
+ def readinto(self, b):
702
+ buf = self.read(len(b))
703
+ b[:len(buf)] = buf
704
+ return len(buf)
705
+
706
+ def close(self):
707
+ self.closed = True
708
+ #class _FileInFile
709
+
710
+ class ExFileObject(io.BufferedReader):
711
+
712
+ def __init__(self, tarfile, tarinfo):
713
+ fileobj = _FileInFile(tarfile.fileobj, tarinfo.offset_data,
714
+ tarinfo.size, tarinfo.name, tarinfo.sparse)
715
+ super().__init__(fileobj)
716
+ #class ExFileObject
717
+
718
+
719
+ #-----------------------------
720
+ # extraction filters (PEP 706)
721
+ #-----------------------------
722
+
723
+ class FilterError(TarError):
724
+ pass
725
+
726
+ class AbsolutePathError(FilterError):
727
+ def __init__(self, tarinfo):
728
+ self.tarinfo = tarinfo
729
+ super().__init__(f'member {tarinfo.name!r} has an absolute path')
730
+
731
+ class OutsideDestinationError(FilterError):
732
+ def __init__(self, tarinfo, path):
733
+ self.tarinfo = tarinfo
734
+ self._path = path
735
+ super().__init__(f'{tarinfo.name!r} would be extracted to {path!r}, '
736
+ + 'which is outside the destination')
737
+
738
+ class SpecialFileError(FilterError):
739
+ def __init__(self, tarinfo):
740
+ self.tarinfo = tarinfo
741
+ super().__init__(f'{tarinfo.name!r} is a special file')
742
+
743
+ class AbsoluteLinkError(FilterError):
744
+ def __init__(self, tarinfo):
745
+ self.tarinfo = tarinfo
746
+ super().__init__(f'{tarinfo.name!r} is a link to an absolute path')
747
+
748
+ class LinkOutsideDestinationError(FilterError):
749
+ def __init__(self, tarinfo, path):
750
+ self.tarinfo = tarinfo
751
+ self._path = path
752
+ super().__init__(f'{tarinfo.name!r} would link to {path!r}, '
753
+ + 'which is outside the destination')
754
+
755
+ class LinkFallbackError(FilterError):
756
+ def __init__(self, tarinfo, path):
757
+ self.tarinfo = tarinfo
758
+ self._path = path
759
+ super().__init__(f'link {tarinfo.name!r} would be extracted as a '
760
+ + f'copy of {path!r}, which was rejected')
761
+
762
+ # Errors caused by filters -- both "fatal" and "non-fatal" -- that
763
+ # we consider to be issues with the argument, rather than a bug in the
764
+ # filter function
765
+ _FILTER_ERRORS = (FilterError, OSError, ExtractError)
766
+
767
+ def _get_filtered_attrs(member, dest_path, for_data=True):
768
+ new_attrs = {}
769
+ name = member.name
770
+ dest_path = os.path.realpath(dest_path, strict=os.path.ALLOW_MISSING)
771
+ # Strip leading / (tar's directory separator) from filenames.
772
+ # Include os.sep (target OS directory separator) as well.
773
+ if name.startswith(('/', os.sep)):
774
+ name = new_attrs['name'] = member.path.lstrip('/' + os.sep)
775
+ if os.path.isabs(name):
776
+ # Path is absolute even after stripping.
777
+ # For example, 'C:/foo' on Windows.
778
+ raise AbsolutePathError(member)
779
+ # Ensure we stay in the destination
780
+ target_path = os.path.realpath(os.path.join(dest_path, name),
781
+ strict=os.path.ALLOW_MISSING)
782
+ if os.path.commonpath([target_path, dest_path]) != dest_path:
783
+ raise OutsideDestinationError(member, target_path)
784
+ # Limit permissions (no high bits, and go-w)
785
+ mode = member.mode
786
+ if mode is not None:
787
+ # Strip high bits & group/other write bits
788
+ mode = mode & 0o755
789
+ if for_data:
790
+ # For data, handle permissions & file types
791
+ if member.isreg() or member.islnk():
792
+ if not mode & 0o100:
793
+ # Clear executable bits if not executable by user
794
+ mode &= ~0o111
795
+ # Ensure owner can read & write
796
+ mode |= 0o600
797
+ elif member.isdir() or member.issym():
798
+ # Ignore mode for directories & symlinks
799
+ mode = None
800
+ else:
801
+ # Reject special files
802
+ raise SpecialFileError(member)
803
+ if mode != member.mode:
804
+ new_attrs['mode'] = mode
805
+ if for_data:
806
+ # Ignore ownership for 'data'
807
+ if member.uid is not None:
808
+ new_attrs['uid'] = None
809
+ if member.gid is not None:
810
+ new_attrs['gid'] = None
811
+ if member.uname is not None:
812
+ new_attrs['uname'] = None
813
+ if member.gname is not None:
814
+ new_attrs['gname'] = None
815
+ # Check link destination for 'data'
816
+ if member.islnk() or member.issym():
817
+ if os.path.isabs(member.linkname):
818
+ raise AbsoluteLinkError(member)
819
+ normalized = os.path.normpath(member.linkname)
820
+ if normalized != member.linkname:
821
+ new_attrs['linkname'] = normalized
822
+ if member.issym():
823
+ target_path = os.path.join(dest_path,
824
+ os.path.dirname(name),
825
+ member.linkname)
826
+ else:
827
+ target_path = os.path.join(dest_path,
828
+ member.linkname)
829
+ target_path = os.path.realpath(target_path,
830
+ strict=os.path.ALLOW_MISSING)
831
+ if os.path.commonpath([target_path, dest_path]) != dest_path:
832
+ raise LinkOutsideDestinationError(member, target_path)
833
+ return new_attrs
834
+
835
+ def fully_trusted_filter(member, dest_path):
836
+ return member
837
+
838
+ def tar_filter(member, dest_path):
839
+ new_attrs = _get_filtered_attrs(member, dest_path, False)
840
+ if new_attrs:
841
+ return member.replace(**new_attrs, deep=False)
842
+ return member
843
+
844
+ def data_filter(member, dest_path):
845
+ new_attrs = _get_filtered_attrs(member, dest_path, True)
846
+ if new_attrs:
847
+ return member.replace(**new_attrs, deep=False)
848
+ return member
849
+
850
+ _NAMED_FILTERS = {
851
+ "fully_trusted": fully_trusted_filter,
852
+ "tar": tar_filter,
853
+ "data": data_filter,
854
+ }
855
+
856
+ #------------------
857
+ # Exported Classes
858
+ #------------------
859
+
860
+ # Sentinel for replace() defaults, meaning "don't change the attribute"
861
+ _KEEP = object()
862
+
863
+ # Header length is digits followed by a space.
864
+ _header_length_prefix_re = re.compile(br"([0-9]{1,20}) ")
865
+
866
+ class TarInfo(object):
867
+ """Informational class which holds the details about an
868
+ archive member given by a tar header block.
869
+ TarInfo objects are returned by TarFile.getmember(),
870
+ TarFile.getmembers() and TarFile.gettarinfo() and are
871
+ usually created internally.
872
+ """
873
+
874
+ __slots__ = dict(
875
+ name = 'Name of the archive member.',
876
+ mode = 'Permission bits.',
877
+ uid = 'User ID of the user who originally stored this member.',
878
+ gid = 'Group ID of the user who originally stored this member.',
879
+ size = 'Size in bytes.',
880
+ mtime = 'Time of last modification.',
881
+ chksum = 'Header checksum.',
882
+ type = ('File type. type is usually one of these constants: '
883
+ 'REGTYPE, AREGTYPE, LNKTYPE, SYMTYPE, DIRTYPE, FIFOTYPE, '
884
+ 'CONTTYPE, CHRTYPE, BLKTYPE, GNUTYPE_SPARSE.'),
885
+ linkname = ('Name of the target file name, which is only present '
886
+ 'in TarInfo objects of type LNKTYPE and SYMTYPE.'),
887
+ uname = 'User name.',
888
+ gname = 'Group name.',
889
+ devmajor = 'Device major number.',
890
+ devminor = 'Device minor number.',
891
+ offset = 'The tar header starts here.',
892
+ offset_data = "The file's data starts here.",
893
+ pax_headers = ('A dictionary containing key-value pairs of an '
894
+ 'associated pax extended header.'),
895
+ sparse = 'Sparse member information.',
896
+ tarfile = None,
897
+ _sparse_structs = None,
898
+ _link_target = None,
899
+ )
900
+
901
+ def __init__(self, name=""):
902
+ """Construct a TarInfo object. name is the optional name
903
+ of the member.
904
+ """
905
+ self.name = name # member name
906
+ self.mode = 0o644 # file permissions
907
+ self.uid = 0 # user id
908
+ self.gid = 0 # group id
909
+ self.size = 0 # file size
910
+ self.mtime = 0 # modification time
911
+ self.chksum = 0 # header checksum
912
+ self.type = REGTYPE # member type
913
+ self.linkname = "" # link name
914
+ self.uname = "" # user name
915
+ self.gname = "" # group name
916
+ self.devmajor = 0 # device major number
917
+ self.devminor = 0 # device minor number
918
+
919
+ self.offset = 0 # the tar header starts here
920
+ self.offset_data = 0 # the file's data starts here
921
+
922
+ self.sparse = None # sparse member information
923
+ self.pax_headers = {} # pax header information
924
+
925
+ @property
926
+ def path(self):
927
+ 'In pax headers, "name" is called "path".'
928
+ return self.name
929
+
930
+ @path.setter
931
+ def path(self, name):
932
+ self.name = name
933
+
934
+ @property
935
+ def linkpath(self):
936
+ 'In pax headers, "linkname" is called "linkpath".'
937
+ return self.linkname
938
+
939
+ @linkpath.setter
940
+ def linkpath(self, linkname):
941
+ self.linkname = linkname
942
+
943
+ def __repr__(self):
944
+ return "<%s %r at %#x>" % (self.__class__.__name__,self.name,id(self))
945
+
946
+ def replace(self, *,
947
+ name=_KEEP, mtime=_KEEP, mode=_KEEP, linkname=_KEEP,
948
+ uid=_KEEP, gid=_KEEP, uname=_KEEP, gname=_KEEP,
949
+ deep=True, _KEEP=_KEEP):
950
+ """Return a deep copy of self with the given attributes replaced.
951
+ """
952
+ if deep:
953
+ result = copy.deepcopy(self)
954
+ else:
955
+ result = copy.copy(self)
956
+ if name is not _KEEP:
957
+ result.name = name
958
+ if mtime is not _KEEP:
959
+ result.mtime = mtime
960
+ if mode is not _KEEP:
961
+ result.mode = mode
962
+ if linkname is not _KEEP:
963
+ result.linkname = linkname
964
+ if uid is not _KEEP:
965
+ result.uid = uid
966
+ if gid is not _KEEP:
967
+ result.gid = gid
968
+ if uname is not _KEEP:
969
+ result.uname = uname
970
+ if gname is not _KEEP:
971
+ result.gname = gname
972
+ return result
973
+
974
+ def get_info(self):
975
+ """Return the TarInfo's attributes as a dictionary.
976
+ """
977
+ if self.mode is None:
978
+ mode = None
979
+ else:
980
+ mode = self.mode & 0o7777
981
+ info = {
982
+ "name": self.name,
983
+ "mode": mode,
984
+ "uid": self.uid,
985
+ "gid": self.gid,
986
+ "size": self.size,
987
+ "mtime": self.mtime,
988
+ "chksum": self.chksum,
989
+ "type": self.type,
990
+ "linkname": self.linkname,
991
+ "uname": self.uname,
992
+ "gname": self.gname,
993
+ "devmajor": self.devmajor,
994
+ "devminor": self.devminor
995
+ }
996
+
997
+ if info["type"] == DIRTYPE and not info["name"].endswith("/"):
998
+ info["name"] += "/"
999
+
1000
+ return info
1001
+
1002
+ def tobuf(self, format=DEFAULT_FORMAT, encoding=ENCODING, errors="surrogateescape"):
1003
+ """Return a tar header as a string of 512 byte blocks.
1004
+ """
1005
+ info = self.get_info()
1006
+ for name, value in info.items():
1007
+ if value is None:
1008
+ raise ValueError("%s may not be None" % name)
1009
+
1010
+ if format == USTAR_FORMAT:
1011
+ return self.create_ustar_header(info, encoding, errors)
1012
+ elif format == GNU_FORMAT:
1013
+ return self.create_gnu_header(info, encoding, errors)
1014
+ elif format == PAX_FORMAT:
1015
+ return self.create_pax_header(info, encoding)
1016
+ else:
1017
+ raise ValueError("invalid format")
1018
+
1019
+ def create_ustar_header(self, info, encoding, errors):
1020
+ """Return the object as a ustar header block.
1021
+ """
1022
+ info["magic"] = POSIX_MAGIC
1023
+
1024
+ if len(info["linkname"].encode(encoding, errors)) > LENGTH_LINK:
1025
+ raise ValueError("linkname is too long")
1026
+
1027
+ if len(info["name"].encode(encoding, errors)) > LENGTH_NAME:
1028
+ info["prefix"], info["name"] = self._posix_split_name(info["name"], encoding, errors)
1029
+
1030
+ return self._create_header(info, USTAR_FORMAT, encoding, errors)
1031
+
1032
+ def create_gnu_header(self, info, encoding, errors):
1033
+ """Return the object as a GNU header block sequence.
1034
+ """
1035
+ info["magic"] = GNU_MAGIC
1036
+
1037
+ buf = b""
1038
+ if len(info["linkname"].encode(encoding, errors)) > LENGTH_LINK:
1039
+ buf += self._create_gnu_long_header(info["linkname"], GNUTYPE_LONGLINK, encoding, errors)
1040
+
1041
+ if len(info["name"].encode(encoding, errors)) > LENGTH_NAME:
1042
+ buf += self._create_gnu_long_header(info["name"], GNUTYPE_LONGNAME, encoding, errors)
1043
+
1044
+ return buf + self._create_header(info, GNU_FORMAT, encoding, errors)
1045
+
1046
+ def create_pax_header(self, info, encoding):
1047
+ """Return the object as a ustar header block. If it cannot be
1048
+ represented this way, prepend a pax extended header sequence
1049
+ with supplement information.
1050
+ """
1051
+ info["magic"] = POSIX_MAGIC
1052
+ pax_headers = self.pax_headers.copy()
1053
+
1054
+ # Test string fields for values that exceed the field length or cannot
1055
+ # be represented in ASCII encoding.
1056
+ for name, hname, length in (
1057
+ ("name", "path", LENGTH_NAME), ("linkname", "linkpath", LENGTH_LINK),
1058
+ ("uname", "uname", 32), ("gname", "gname", 32)):
1059
+
1060
+ if hname in pax_headers:
1061
+ # The pax header has priority.
1062
+ continue
1063
+
1064
+ # Try to encode the string as ASCII.
1065
+ try:
1066
+ info[name].encode("ascii", "strict")
1067
+ except UnicodeEncodeError:
1068
+ pax_headers[hname] = info[name]
1069
+ continue
1070
+
1071
+ if len(info[name]) > length:
1072
+ pax_headers[hname] = info[name]
1073
+
1074
+ # Test number fields for values that exceed the field limit or values
1075
+ # that like to be stored as float.
1076
+ for name, digits in (("uid", 8), ("gid", 8), ("size", 12), ("mtime", 12)):
1077
+ needs_pax = False
1078
+
1079
+ val = info[name]
1080
+ val_is_float = isinstance(val, float)
1081
+ val_int = round(val) if val_is_float else val
1082
+ if not 0 <= val_int < 8 ** (digits - 1):
1083
+ # Avoid overflow.
1084
+ info[name] = 0
1085
+ needs_pax = True
1086
+ elif val_is_float:
1087
+ # Put rounded value in ustar header, and full
1088
+ # precision value in pax header.
1089
+ info[name] = val_int
1090
+ needs_pax = True
1091
+
1092
+ # The existing pax header has priority.
1093
+ if needs_pax and name not in pax_headers:
1094
+ pax_headers[name] = str(val)
1095
+
1096
+ # Create a pax extended header if necessary.
1097
+ if pax_headers:
1098
+ buf = self._create_pax_generic_header(pax_headers, XHDTYPE, encoding)
1099
+ else:
1100
+ buf = b""
1101
+
1102
+ return buf + self._create_header(info, USTAR_FORMAT, "ascii", "replace")
1103
+
1104
+ @classmethod
1105
+ def create_pax_global_header(cls, pax_headers):
1106
+ """Return the object as a pax global header block sequence.
1107
+ """
1108
+ return cls._create_pax_generic_header(pax_headers, XGLTYPE, "utf-8")
1109
+
1110
+ def _posix_split_name(self, name, encoding, errors):
1111
+ """Split a name longer than 100 chars into a prefix
1112
+ and a name part.
1113
+ """
1114
+ components = name.split("/")
1115
+ for i in range(1, len(components)):
1116
+ prefix = "/".join(components[:i])
1117
+ name = "/".join(components[i:])
1118
+ if len(prefix.encode(encoding, errors)) <= LENGTH_PREFIX and \
1119
+ len(name.encode(encoding, errors)) <= LENGTH_NAME:
1120
+ break
1121
+ else:
1122
+ raise ValueError("name is too long")
1123
+
1124
+ return prefix, name
1125
+
1126
+ @staticmethod
1127
+ def _create_header(info, format, encoding, errors):
1128
+ """Return a header block. info is a dictionary with file
1129
+ information, format must be one of the *_FORMAT constants.
1130
+ """
1131
+ has_device_fields = info.get("type") in (CHRTYPE, BLKTYPE)
1132
+ if has_device_fields:
1133
+ devmajor = itn(info.get("devmajor", 0), 8, format)
1134
+ devminor = itn(info.get("devminor", 0), 8, format)
1135
+ else:
1136
+ devmajor = stn("", 8, encoding, errors)
1137
+ devminor = stn("", 8, encoding, errors)
1138
+
1139
+ # None values in metadata should cause ValueError.
1140
+ # itn()/stn() do this for all fields except type.
1141
+ filetype = info.get("type", REGTYPE)
1142
+ if filetype is None:
1143
+ raise ValueError("TarInfo.type must not be None")
1144
+
1145
+ parts = [
1146
+ stn(info.get("name", ""), 100, encoding, errors),
1147
+ itn(info.get("mode", 0) & 0o7777, 8, format),
1148
+ itn(info.get("uid", 0), 8, format),
1149
+ itn(info.get("gid", 0), 8, format),
1150
+ itn(info.get("size", 0), 12, format),
1151
+ itn(info.get("mtime", 0), 12, format),
1152
+ b" ", # checksum field
1153
+ filetype,
1154
+ stn(info.get("linkname", ""), 100, encoding, errors),
1155
+ info.get("magic", POSIX_MAGIC),
1156
+ stn(info.get("uname", ""), 32, encoding, errors),
1157
+ stn(info.get("gname", ""), 32, encoding, errors),
1158
+ devmajor,
1159
+ devminor,
1160
+ stn(info.get("prefix", ""), 155, encoding, errors)
1161
+ ]
1162
+
1163
+ buf = struct.pack("%ds" % BLOCKSIZE, b"".join(parts))
1164
+ chksum = calc_chksums(buf[-BLOCKSIZE:])[0]
1165
+ buf = buf[:-364] + bytes("%06o\0" % chksum, "ascii") + buf[-357:]
1166
+ return buf
1167
+
1168
+ @staticmethod
1169
+ def _create_payload(payload):
1170
+ """Return the string payload filled with zero bytes
1171
+ up to the next 512 byte border.
1172
+ """
1173
+ blocks, remainder = divmod(len(payload), BLOCKSIZE)
1174
+ if remainder > 0:
1175
+ payload += (BLOCKSIZE - remainder) * NUL
1176
+ return payload
1177
+
1178
+ @classmethod
1179
+ def _create_gnu_long_header(cls, name, type, encoding, errors):
1180
+ """Return a GNUTYPE_LONGNAME or GNUTYPE_LONGLINK sequence
1181
+ for name.
1182
+ """
1183
+ name = name.encode(encoding, errors) + NUL
1184
+
1185
+ info = {}
1186
+ info["name"] = "././@LongLink"
1187
+ info["type"] = type
1188
+ info["size"] = len(name)
1189
+ info["magic"] = GNU_MAGIC
1190
+
1191
+ # create extended header + name blocks.
1192
+ return cls._create_header(info, USTAR_FORMAT, encoding, errors) + \
1193
+ cls._create_payload(name)
1194
+
1195
+ @classmethod
1196
+ def _create_pax_generic_header(cls, pax_headers, type, encoding):
1197
+ """Return a POSIX.1-2008 extended or global header sequence
1198
+ that contains a list of keyword, value pairs. The values
1199
+ must be strings.
1200
+ """
1201
+ # Check if one of the fields contains surrogate characters and thereby
1202
+ # forces hdrcharset=BINARY, see _proc_pax() for more information.
1203
+ binary = False
1204
+ for keyword, value in pax_headers.items():
1205
+ try:
1206
+ value.encode("utf-8", "strict")
1207
+ except UnicodeEncodeError:
1208
+ binary = True
1209
+ break
1210
+
1211
+ records = b""
1212
+ if binary:
1213
+ # Put the hdrcharset field at the beginning of the header.
1214
+ records += b"21 hdrcharset=BINARY\n"
1215
+
1216
+ for keyword, value in pax_headers.items():
1217
+ keyword = keyword.encode("utf-8")
1218
+ if binary:
1219
+ # Try to restore the original byte representation of `value'.
1220
+ # Needless to say, that the encoding must match the string.
1221
+ value = value.encode(encoding, "surrogateescape")
1222
+ else:
1223
+ value = value.encode("utf-8")
1224
+
1225
+ l = len(keyword) + len(value) + 3 # ' ' + '=' + '\n'
1226
+ n = p = 0
1227
+ while True:
1228
+ n = l + len(str(p))
1229
+ if n == p:
1230
+ break
1231
+ p = n
1232
+ records += bytes(str(p), "ascii") + b" " + keyword + b"=" + value + b"\n"
1233
+
1234
+ # We use a hardcoded "././@PaxHeader" name like star does
1235
+ # instead of the one that POSIX recommends.
1236
+ info = {}
1237
+ info["name"] = "././@PaxHeader"
1238
+ info["type"] = type
1239
+ info["size"] = len(records)
1240
+ info["magic"] = POSIX_MAGIC
1241
+
1242
+ # Create pax header + record blocks.
1243
+ return cls._create_header(info, USTAR_FORMAT, "ascii", "replace") + \
1244
+ cls._create_payload(records)
1245
+
1246
+ @classmethod
1247
+ def frombuf(cls, buf, encoding, errors):
1248
+ """Construct a TarInfo object from a 512 byte bytes object.
1249
+ """
1250
+ if len(buf) == 0:
1251
+ raise EmptyHeaderError("empty header")
1252
+ if len(buf) != BLOCKSIZE:
1253
+ raise TruncatedHeaderError("truncated header")
1254
+ if buf.count(NUL) == BLOCKSIZE:
1255
+ raise EOFHeaderError("end of file header")
1256
+
1257
+ chksum = nti(buf[148:156])
1258
+ if chksum not in calc_chksums(buf):
1259
+ raise InvalidHeaderError("bad checksum")
1260
+
1261
+ obj = cls()
1262
+ obj.name = nts(buf[0:100], encoding, errors)
1263
+ obj.mode = nti(buf[100:108])
1264
+ obj.uid = nti(buf[108:116])
1265
+ obj.gid = nti(buf[116:124])
1266
+ obj.size = nti(buf[124:136])
1267
+ obj.mtime = nti(buf[136:148])
1268
+ obj.chksum = chksum
1269
+ obj.type = buf[156:157]
1270
+ obj.linkname = nts(buf[157:257], encoding, errors)
1271
+ obj.uname = nts(buf[265:297], encoding, errors)
1272
+ obj.gname = nts(buf[297:329], encoding, errors)
1273
+ obj.devmajor = nti(buf[329:337])
1274
+ obj.devminor = nti(buf[337:345])
1275
+ prefix = nts(buf[345:500], encoding, errors)
1276
+
1277
+ # Old V7 tar format represents a directory as a regular
1278
+ # file with a trailing slash.
1279
+ if obj.type == AREGTYPE and obj.name.endswith("/"):
1280
+ obj.type = DIRTYPE
1281
+
1282
+ # The old GNU sparse format occupies some of the unused
1283
+ # space in the buffer for up to 4 sparse structures.
1284
+ # Save them for later processing in _proc_sparse().
1285
+ if obj.type == GNUTYPE_SPARSE:
1286
+ pos = 386
1287
+ structs = []
1288
+ for i in range(4):
1289
+ try:
1290
+ offset = nti(buf[pos:pos + 12])
1291
+ numbytes = nti(buf[pos + 12:pos + 24])
1292
+ except ValueError:
1293
+ break
1294
+ structs.append((offset, numbytes))
1295
+ pos += 24
1296
+ isextended = bool(buf[482])
1297
+ origsize = nti(buf[483:495])
1298
+ obj._sparse_structs = (structs, isextended, origsize)
1299
+
1300
+ # Remove redundant slashes from directories.
1301
+ if obj.isdir():
1302
+ obj.name = obj.name.rstrip("/")
1303
+
1304
+ # Reconstruct a ustar longname.
1305
+ if prefix and obj.type not in GNU_TYPES:
1306
+ obj.name = prefix + "/" + obj.name
1307
+ return obj
1308
+
1309
+ @classmethod
1310
+ def fromtarfile(cls, tarfile):
1311
+ """Return the next TarInfo object from TarFile object
1312
+ tarfile.
1313
+ """
1314
+ buf = tarfile.fileobj.read(BLOCKSIZE)
1315
+ obj = cls.frombuf(buf, tarfile.encoding, tarfile.errors)
1316
+ obj.offset = tarfile.fileobj.tell() - BLOCKSIZE
1317
+ return obj._proc_member(tarfile)
1318
+
1319
+ #--------------------------------------------------------------------------
1320
+ # The following are methods that are called depending on the type of a
1321
+ # member. The entry point is _proc_member() which can be overridden in a
1322
+ # subclass to add custom _proc_*() methods. A _proc_*() method MUST
1323
+ # implement the following
1324
+ # operations:
1325
+ # 1. Set self.offset_data to the position where the data blocks begin,
1326
+ # if there is data that follows.
1327
+ # 2. Set tarfile.offset to the position where the next member's header will
1328
+ # begin.
1329
+ # 3. Return self or another valid TarInfo object.
1330
+ def _proc_member(self, tarfile):
1331
+ """Choose the right processing method depending on
1332
+ the type and call it.
1333
+ """
1334
+ if self.type in (GNUTYPE_LONGNAME, GNUTYPE_LONGLINK):
1335
+ return self._proc_gnulong(tarfile)
1336
+ elif self.type == GNUTYPE_SPARSE:
1337
+ return self._proc_sparse(tarfile)
1338
+ elif self.type in (XHDTYPE, XGLTYPE, SOLARIS_XHDTYPE):
1339
+ return self._proc_pax(tarfile)
1340
+ else:
1341
+ return self._proc_builtin(tarfile)
1342
+
1343
+ def _proc_builtin(self, tarfile):
1344
+ """Process a builtin type or an unknown type which
1345
+ will be treated as a regular file.
1346
+ """
1347
+ self.offset_data = tarfile.fileobj.tell()
1348
+ offset = self.offset_data
1349
+ if self.isreg() or self.type not in SUPPORTED_TYPES:
1350
+ # Skip the following data blocks.
1351
+ offset += self._block(self.size)
1352
+ tarfile.offset = offset
1353
+
1354
+ # Patch the TarInfo object with saved global
1355
+ # header information.
1356
+ self._apply_pax_info(tarfile.pax_headers, tarfile.encoding, tarfile.errors)
1357
+
1358
+ # Remove redundant slashes from directories. This is to be consistent
1359
+ # with frombuf().
1360
+ if self.isdir():
1361
+ self.name = self.name.rstrip("/")
1362
+
1363
+ return self
1364
+
1365
+ def _proc_gnulong(self, tarfile):
1366
+ """Process the blocks that hold a GNU longname
1367
+ or longlink member.
1368
+ """
1369
+ buf = tarfile.fileobj.read(self._block(self.size))
1370
+
1371
+ # Fetch the next header and process it.
1372
+ try:
1373
+ next = self.fromtarfile(tarfile)
1374
+ except HeaderError as e:
1375
+ raise SubsequentHeaderError(str(e)) from None
1376
+
1377
+ # Patch the TarInfo object from the next header with
1378
+ # the longname information.
1379
+ next.offset = self.offset
1380
+ if self.type == GNUTYPE_LONGNAME:
1381
+ next.name = nts(buf, tarfile.encoding, tarfile.errors)
1382
+ elif self.type == GNUTYPE_LONGLINK:
1383
+ next.linkname = nts(buf, tarfile.encoding, tarfile.errors)
1384
+
1385
+ # Remove redundant slashes from directories. This is to be consistent
1386
+ # with frombuf().
1387
+ if next.isdir():
1388
+ next.name = next.name.removesuffix("/")
1389
+
1390
+ return next
1391
+
1392
+ def _proc_sparse(self, tarfile):
1393
+ """Process a GNU sparse header plus extra headers.
1394
+ """
1395
+ # We already collected some sparse structures in frombuf().
1396
+ structs, isextended, origsize = self._sparse_structs
1397
+ del self._sparse_structs
1398
+
1399
+ # Collect sparse structures from extended header blocks.
1400
+ while isextended:
1401
+ buf = tarfile.fileobj.read(BLOCKSIZE)
1402
+ pos = 0
1403
+ for i in range(21):
1404
+ try:
1405
+ offset = nti(buf[pos:pos + 12])
1406
+ numbytes = nti(buf[pos + 12:pos + 24])
1407
+ except ValueError:
1408
+ break
1409
+ if offset and numbytes:
1410
+ structs.append((offset, numbytes))
1411
+ pos += 24
1412
+ isextended = bool(buf[504])
1413
+ self.sparse = structs
1414
+
1415
+ self.offset_data = tarfile.fileobj.tell()
1416
+ tarfile.offset = self.offset_data + self._block(self.size)
1417
+ self.size = origsize
1418
+ return self
1419
+
1420
+ def _proc_pax(self, tarfile):
1421
+ """Process an extended or global header as described in
1422
+ POSIX.1-2008.
1423
+ """
1424
+ # Read the header information.
1425
+ buf = tarfile.fileobj.read(self._block(self.size))
1426
+
1427
+ # A pax header stores supplemental information for either
1428
+ # the following file (extended) or all following files
1429
+ # (global).
1430
+ if self.type == XGLTYPE:
1431
+ pax_headers = tarfile.pax_headers
1432
+ else:
1433
+ pax_headers = tarfile.pax_headers.copy()
1434
+
1435
+ # Parse pax header information. A record looks like that:
1436
+ # "%d %s=%s\n" % (length, keyword, value). length is the size
1437
+ # of the complete record including the length field itself and
1438
+ # the newline.
1439
+ pos = 0
1440
+ encoding = None
1441
+ raw_headers = []
1442
+ while len(buf) > pos and buf[pos] != 0x00:
1443
+ if not (match := _header_length_prefix_re.match(buf, pos)):
1444
+ raise InvalidHeaderError("invalid header")
1445
+ try:
1446
+ length = int(match.group(1))
1447
+ except ValueError:
1448
+ raise InvalidHeaderError("invalid header")
1449
+ # Headers must be at least 5 bytes, shortest being '5 x=\n'.
1450
+ # Value is allowed to be empty.
1451
+ if length < 5:
1452
+ raise InvalidHeaderError("invalid header")
1453
+ if pos + length > len(buf):
1454
+ raise InvalidHeaderError("invalid header")
1455
+
1456
+ header_value_end_offset = match.start(1) + length - 1 # Last byte of the header
1457
+ keyword_and_value = buf[match.end(1) + 1:header_value_end_offset]
1458
+ raw_keyword, equals, raw_value = keyword_and_value.partition(b"=")
1459
+
1460
+ # Check the framing of the header. The last character must be '\n' (0x0A)
1461
+ if not raw_keyword or equals != b"=" or buf[header_value_end_offset] != 0x0A:
1462
+ raise InvalidHeaderError("invalid header")
1463
+ raw_headers.append((length, raw_keyword, raw_value))
1464
+
1465
+ # Check if the pax header contains a hdrcharset field. This tells us
1466
+ # the encoding of the path, linkpath, uname and gname fields. Normally,
1467
+ # these fields are UTF-8 encoded but since POSIX.1-2008 tar
1468
+ # implementations are allowed to store them as raw binary strings if
1469
+ # the translation to UTF-8 fails. For the time being, we don't care about
1470
+ # anything other than "BINARY". The only other value that is currently
1471
+ # allowed by the standard is "ISO-IR 10646 2000 UTF-8" in other words UTF-8.
1472
+ # Note that we only follow the initial 'hdrcharset' setting to preserve
1473
+ # the initial behavior of the 'tarfile' module.
1474
+ if raw_keyword == b"hdrcharset" and encoding is None:
1475
+ if raw_value == b"BINARY":
1476
+ encoding = tarfile.encoding
1477
+ else: # This branch ensures only the first 'hdrcharset' header is used.
1478
+ encoding = "utf-8"
1479
+
1480
+ pos += length
1481
+
1482
+ # If no explicit hdrcharset is set, we use UTF-8 as a default.
1483
+ if encoding is None:
1484
+ encoding = "utf-8"
1485
+
1486
+ # After parsing the raw headers we can decode them to text.
1487
+ for length, raw_keyword, raw_value in raw_headers:
1488
+ # Normally, we could just use "utf-8" as the encoding and "strict"
1489
+ # as the error handler, but we better not take the risk. For
1490
+ # example, GNU tar <= 1.23 is known to store filenames it cannot
1491
+ # translate to UTF-8 as raw strings (unfortunately without a
1492
+ # hdrcharset=BINARY header).
1493
+ # We first try the strict standard encoding, and if that fails we
1494
+ # fall back on the user's encoding and error handler.
1495
+ keyword = self._decode_pax_field(raw_keyword, "utf-8", "utf-8",
1496
+ tarfile.errors)
1497
+ if keyword in PAX_NAME_FIELDS:
1498
+ value = self._decode_pax_field(raw_value, encoding, tarfile.encoding,
1499
+ tarfile.errors)
1500
+ else:
1501
+ value = self._decode_pax_field(raw_value, "utf-8", "utf-8",
1502
+ tarfile.errors)
1503
+
1504
+ pax_headers[keyword] = value
1505
+
1506
+ # Fetch the next header.
1507
+ try:
1508
+ next = self.fromtarfile(tarfile)
1509
+ except HeaderError as e:
1510
+ raise SubsequentHeaderError(str(e)) from None
1511
+
1512
+ # Process GNU sparse information.
1513
+ if "GNU.sparse.map" in pax_headers:
1514
+ # GNU extended sparse format version 0.1.
1515
+ self._proc_gnusparse_01(next, pax_headers)
1516
+
1517
+ elif "GNU.sparse.size" in pax_headers:
1518
+ # GNU extended sparse format version 0.0.
1519
+ self._proc_gnusparse_00(next, raw_headers)
1520
+
1521
+ elif pax_headers.get("GNU.sparse.major") == "1" and pax_headers.get("GNU.sparse.minor") == "0":
1522
+ # GNU extended sparse format version 1.0.
1523
+ self._proc_gnusparse_10(next, pax_headers, tarfile)
1524
+
1525
+ if self.type in (XHDTYPE, SOLARIS_XHDTYPE):
1526
+ # Patch the TarInfo object with the extended header info.
1527
+ next._apply_pax_info(pax_headers, tarfile.encoding, tarfile.errors)
1528
+ next.offset = self.offset
1529
+
1530
+ if "size" in pax_headers:
1531
+ # If the extended header replaces the size field,
1532
+ # we need to recalculate the offset where the next
1533
+ # header starts.
1534
+ offset = next.offset_data
1535
+ if next.isreg() or next.type not in SUPPORTED_TYPES:
1536
+ offset += next._block(next.size)
1537
+ tarfile.offset = offset
1538
+
1539
+ return next
1540
+
1541
+ def _proc_gnusparse_00(self, next, raw_headers):
1542
+ """Process a GNU tar extended sparse header, version 0.0.
1543
+ """
1544
+ offsets = []
1545
+ numbytes = []
1546
+ for _, keyword, value in raw_headers:
1547
+ if keyword == b"GNU.sparse.offset":
1548
+ try:
1549
+ offsets.append(int(value.decode()))
1550
+ except ValueError:
1551
+ raise InvalidHeaderError("invalid header")
1552
+
1553
+ elif keyword == b"GNU.sparse.numbytes":
1554
+ try:
1555
+ numbytes.append(int(value.decode()))
1556
+ except ValueError:
1557
+ raise InvalidHeaderError("invalid header")
1558
+
1559
+ next.sparse = list(zip(offsets, numbytes))
1560
+
1561
+ def _proc_gnusparse_01(self, next, pax_headers):
1562
+ """Process a GNU tar extended sparse header, version 0.1.
1563
+ """
1564
+ sparse = [int(x) for x in pax_headers["GNU.sparse.map"].split(",")]
1565
+ next.sparse = list(zip(sparse[::2], sparse[1::2]))
1566
+
1567
+ def _proc_gnusparse_10(self, next, pax_headers, tarfile):
1568
+ """Process a GNU tar extended sparse header, version 1.0.
1569
+ """
1570
+ fields = None
1571
+ sparse = []
1572
+ buf = tarfile.fileobj.read(BLOCKSIZE)
1573
+ fields, buf = buf.split(b"\n", 1)
1574
+ fields = int(fields)
1575
+ while len(sparse) < fields * 2:
1576
+ if b"\n" not in buf:
1577
+ buf += tarfile.fileobj.read(BLOCKSIZE)
1578
+ number, buf = buf.split(b"\n", 1)
1579
+ sparse.append(int(number))
1580
+ next.offset_data = tarfile.fileobj.tell()
1581
+ next.sparse = list(zip(sparse[::2], sparse[1::2]))
1582
+
1583
+ def _apply_pax_info(self, pax_headers, encoding, errors):
1584
+ """Replace fields with supplemental information from a previous
1585
+ pax extended or global header.
1586
+ """
1587
+ for keyword, value in pax_headers.items():
1588
+ if keyword == "GNU.sparse.name":
1589
+ setattr(self, "path", value)
1590
+ elif keyword == "GNU.sparse.size":
1591
+ setattr(self, "size", int(value))
1592
+ elif keyword == "GNU.sparse.realsize":
1593
+ setattr(self, "size", int(value))
1594
+ elif keyword in PAX_FIELDS:
1595
+ if keyword in PAX_NUMBER_FIELDS:
1596
+ try:
1597
+ value = PAX_NUMBER_FIELDS[keyword](value)
1598
+ except ValueError:
1599
+ value = 0
1600
+ if keyword == "path":
1601
+ value = value.rstrip("/")
1602
+ setattr(self, keyword, value)
1603
+
1604
+ self.pax_headers = pax_headers.copy()
1605
+
1606
+ def _decode_pax_field(self, value, encoding, fallback_encoding, fallback_errors):
1607
+ """Decode a single field from a pax record.
1608
+ """
1609
+ try:
1610
+ return value.decode(encoding, "strict")
1611
+ except UnicodeDecodeError:
1612
+ return value.decode(fallback_encoding, fallback_errors)
1613
+
1614
+ def _block(self, count):
1615
+ """Round up a byte count by BLOCKSIZE and return it,
1616
+ e.g. _block(834) => 1024.
1617
+ """
1618
+ # Only non-negative offsets are allowed
1619
+ if count < 0:
1620
+ raise InvalidHeaderError("invalid offset")
1621
+ blocks, remainder = divmod(count, BLOCKSIZE)
1622
+ if remainder:
1623
+ blocks += 1
1624
+ return blocks * BLOCKSIZE
1625
+
1626
+ def isreg(self):
1627
+ 'Return True if the Tarinfo object is a regular file.'
1628
+ return self.type in REGULAR_TYPES
1629
+
1630
+ def isfile(self):
1631
+ 'Return True if the Tarinfo object is a regular file.'
1632
+ return self.isreg()
1633
+
1634
+ def isdir(self):
1635
+ 'Return True if it is a directory.'
1636
+ return self.type == DIRTYPE
1637
+
1638
+ def issym(self):
1639
+ 'Return True if it is a symbolic link.'
1640
+ return self.type == SYMTYPE
1641
+
1642
+ def islnk(self):
1643
+ 'Return True if it is a hard link.'
1644
+ return self.type == LNKTYPE
1645
+
1646
+ def ischr(self):
1647
+ 'Return True if it is a character device.'
1648
+ return self.type == CHRTYPE
1649
+
1650
+ def isblk(self):
1651
+ 'Return True if it is a block device.'
1652
+ return self.type == BLKTYPE
1653
+
1654
+ def isfifo(self):
1655
+ 'Return True if it is a FIFO.'
1656
+ return self.type == FIFOTYPE
1657
+
1658
+ def issparse(self):
1659
+ return self.sparse is not None
1660
+
1661
+ def isdev(self):
1662
+ 'Return True if it is one of character device, block device or FIFO.'
1663
+ return self.type in (CHRTYPE, BLKTYPE, FIFOTYPE)
1664
+ # class TarInfo
1665
+
1666
+ class TarFile(object):
1667
+ """The TarFile Class provides an interface to tar archives.
1668
+ """
1669
+
1670
+ debug = 0 # May be set from 0 (no msgs) to 3 (all msgs)
1671
+
1672
+ dereference = False # If true, add content of linked file to the
1673
+ # tar file, else the link.
1674
+
1675
+ ignore_zeros = False # If true, skips empty or invalid blocks and
1676
+ # continues processing.
1677
+
1678
+ errorlevel = 1 # If 0, fatal errors only appear in debug
1679
+ # messages (if debug >= 0). If > 0, errors
1680
+ # are passed to the caller as exceptions.
1681
+
1682
+ format = DEFAULT_FORMAT # The format to use when creating an archive.
1683
+
1684
+ encoding = ENCODING # Encoding for 8-bit character strings.
1685
+
1686
+ errors = None # Error handler for unicode conversion.
1687
+
1688
+ tarinfo = TarInfo # The default TarInfo class to use.
1689
+
1690
+ fileobject = ExFileObject # The file-object for extractfile().
1691
+
1692
+ extraction_filter = None # The default filter for extraction.
1693
+
1694
+ def __init__(self, name=None, mode="r", fileobj=None, format=None,
1695
+ tarinfo=None, dereference=None, ignore_zeros=None, encoding=None,
1696
+ errors="surrogateescape", pax_headers=None, debug=None,
1697
+ errorlevel=None, copybufsize=None):
1698
+ """Open an (uncompressed) tar archive `name'. `mode' is either 'r' to
1699
+ read from an existing archive, 'a' to append data to an existing
1700
+ file or 'w' to create a new file overwriting an existing one. `mode'
1701
+ defaults to 'r'.
1702
+ If `fileobj' is given, it is used for reading or writing data. If it
1703
+ can be determined, `mode' is overridden by `fileobj's mode.
1704
+ `fileobj' is not closed, when TarFile is closed.
1705
+ """
1706
+ modes = {"r": "rb", "a": "r+b", "w": "wb", "x": "xb"}
1707
+ if mode not in modes:
1708
+ raise ValueError("mode must be 'r', 'a', 'w' or 'x'")
1709
+ self.mode = mode
1710
+ self._mode = modes[mode]
1711
+
1712
+ if not fileobj:
1713
+ if self.mode == "a" and not os.path.exists(name):
1714
+ # Create nonexistent files in append mode.
1715
+ self.mode = "w"
1716
+ self._mode = "wb"
1717
+ fileobj = bltn_open(name, self._mode)
1718
+ self._extfileobj = False
1719
+ else:
1720
+ if (name is None and hasattr(fileobj, "name") and
1721
+ isinstance(fileobj.name, (str, bytes))):
1722
+ name = fileobj.name
1723
+ if hasattr(fileobj, "mode"):
1724
+ self._mode = fileobj.mode
1725
+ self._extfileobj = True
1726
+ self.name = os.path.abspath(name) if name else None
1727
+ self.fileobj = fileobj
1728
+
1729
+ # Init attributes.
1730
+ if format is not None:
1731
+ self.format = format
1732
+ if tarinfo is not None:
1733
+ self.tarinfo = tarinfo
1734
+ if dereference is not None:
1735
+ self.dereference = dereference
1736
+ if ignore_zeros is not None:
1737
+ self.ignore_zeros = ignore_zeros
1738
+ if encoding is not None:
1739
+ self.encoding = encoding
1740
+ self.errors = errors
1741
+
1742
+ if pax_headers is not None and self.format == PAX_FORMAT:
1743
+ self.pax_headers = pax_headers
1744
+ else:
1745
+ self.pax_headers = {}
1746
+
1747
+ if debug is not None:
1748
+ self.debug = debug
1749
+ if errorlevel is not None:
1750
+ self.errorlevel = errorlevel
1751
+
1752
+ # Init datastructures.
1753
+ self.copybufsize = copybufsize
1754
+ self.closed = False
1755
+ self.members = [] # list of members as TarInfo objects
1756
+ self._loaded = False # flag if all members have been read
1757
+ self.offset = self.fileobj.tell()
1758
+ # current position in the archive file
1759
+ self.inodes = {} # dictionary caching the inodes of
1760
+ # archive members already added
1761
+
1762
+ try:
1763
+ if self.mode == "r":
1764
+ self.firstmember = None
1765
+ self.firstmember = self.next()
1766
+
1767
+ if self.mode == "a":
1768
+ # Move to the end of the archive,
1769
+ # before the first empty block.
1770
+ while True:
1771
+ self.fileobj.seek(self.offset)
1772
+ try:
1773
+ tarinfo = self.tarinfo.fromtarfile(self)
1774
+ self.members.append(tarinfo)
1775
+ except EOFHeaderError:
1776
+ self.fileobj.seek(self.offset)
1777
+ break
1778
+ except HeaderError as e:
1779
+ raise ReadError(str(e)) from None
1780
+
1781
+ if self.mode in ("a", "w", "x"):
1782
+ self._loaded = True
1783
+
1784
+ if self.pax_headers:
1785
+ buf = self.tarinfo.create_pax_global_header(self.pax_headers.copy())
1786
+ self.fileobj.write(buf)
1787
+ self.offset += len(buf)
1788
+ except:
1789
+ if not self._extfileobj:
1790
+ self.fileobj.close()
1791
+ self.closed = True
1792
+ raise
1793
+
1794
+ #--------------------------------------------------------------------------
1795
+ # Below are the classmethods which act as alternate constructors to the
1796
+ # TarFile class. The open() method is the only one that is needed for
1797
+ # public use; it is the "super"-constructor and is able to select an
1798
+ # adequate "sub"-constructor for a particular compression using the mapping
1799
+ # from OPEN_METH.
1800
+ #
1801
+ # This concept allows one to subclass TarFile without losing the comfort of
1802
+ # the super-constructor. A sub-constructor is registered and made available
1803
+ # by adding it to the mapping in OPEN_METH.
1804
+
1805
+ @classmethod
1806
+ def open(cls, name=None, mode="r", fileobj=None, bufsize=RECORDSIZE, **kwargs):
1807
+ """Open a tar archive for reading, writing or appending. Return
1808
+ an appropriate TarFile class.
1809
+
1810
+ mode:
1811
+ 'r' or 'r:*' open for reading with transparent compression
1812
+ 'r:' open for reading exclusively uncompressed
1813
+ 'r:gz' open for reading with gzip compression
1814
+ 'r:bz2' open for reading with bzip2 compression
1815
+ 'r:xz' open for reading with lzma compression
1816
+ 'a' or 'a:' open for appending, creating the file if necessary
1817
+ 'w' or 'w:' open for writing without compression
1818
+ 'w:gz' open for writing with gzip compression
1819
+ 'w:bz2' open for writing with bzip2 compression
1820
+ 'w:xz' open for writing with lzma compression
1821
+
1822
+ 'x' or 'x:' create a tarfile exclusively without compression, raise
1823
+ an exception if the file is already created
1824
+ 'x:gz' create a gzip compressed tarfile, raise an exception
1825
+ if the file is already created
1826
+ 'x:bz2' create a bzip2 compressed tarfile, raise an exception
1827
+ if the file is already created
1828
+ 'x:xz' create an lzma compressed tarfile, raise an exception
1829
+ if the file is already created
1830
+
1831
+ 'r|*' open a stream of tar blocks with transparent compression
1832
+ 'r|' open an uncompressed stream of tar blocks for reading
1833
+ 'r|gz' open a gzip compressed stream of tar blocks
1834
+ 'r|bz2' open a bzip2 compressed stream of tar blocks
1835
+ 'r|xz' open an lzma compressed stream of tar blocks
1836
+ 'w|' open an uncompressed stream for writing
1837
+ 'w|gz' open a gzip compressed stream for writing
1838
+ 'w|bz2' open a bzip2 compressed stream for writing
1839
+ 'w|xz' open an lzma compressed stream for writing
1840
+ """
1841
+
1842
+ if not name and not fileobj:
1843
+ raise ValueError("nothing to open")
1844
+
1845
+ if mode in ("r", "r:*"):
1846
+ # Find out which *open() is appropriate for opening the file.
1847
+ def not_compressed(comptype):
1848
+ return cls.OPEN_METH[comptype] == 'taropen'
1849
+ error_msgs = []
1850
+ for comptype in sorted(cls.OPEN_METH, key=not_compressed):
1851
+ func = getattr(cls, cls.OPEN_METH[comptype])
1852
+ if fileobj is not None:
1853
+ saved_pos = fileobj.tell()
1854
+ try:
1855
+ return func(name, "r", fileobj, **kwargs)
1856
+ except (ReadError, CompressionError) as e:
1857
+ error_msgs.append(f'- method {comptype}: {e!r}')
1858
+ if fileobj is not None:
1859
+ fileobj.seek(saved_pos)
1860
+ continue
1861
+ error_msgs_summary = '\n'.join(error_msgs)
1862
+ raise ReadError(f"file could not be opened successfully:\n{error_msgs_summary}")
1863
+
1864
+ elif ":" in mode:
1865
+ filemode, comptype = mode.split(":", 1)
1866
+ filemode = filemode or "r"
1867
+ comptype = comptype or "tar"
1868
+
1869
+ # Select the *open() function according to
1870
+ # given compression.
1871
+ if comptype in cls.OPEN_METH:
1872
+ func = getattr(cls, cls.OPEN_METH[comptype])
1873
+ else:
1874
+ raise CompressionError("unknown compression type %r" % comptype)
1875
+ return func(name, filemode, fileobj, **kwargs)
1876
+
1877
+ elif "|" in mode:
1878
+ filemode, comptype = mode.split("|", 1)
1879
+ filemode = filemode or "r"
1880
+ comptype = comptype or "tar"
1881
+
1882
+ if filemode not in ("r", "w"):
1883
+ raise ValueError("mode must be 'r' or 'w'")
1884
+
1885
+ compresslevel = kwargs.pop("compresslevel", 9)
1886
+ stream = _Stream(name, filemode, comptype, fileobj, bufsize,
1887
+ compresslevel)
1888
+ try:
1889
+ t = cls(name, filemode, stream, **kwargs)
1890
+ except:
1891
+ stream.close()
1892
+ raise
1893
+ t._extfileobj = False
1894
+ return t
1895
+
1896
+ elif mode in ("a", "w", "x"):
1897
+ return cls.taropen(name, mode, fileobj, **kwargs)
1898
+
1899
+ raise ValueError("undiscernible mode")
1900
+
1901
+ @classmethod
1902
+ def taropen(cls, name, mode="r", fileobj=None, **kwargs):
1903
+ """Open uncompressed tar archive name for reading or writing.
1904
+ """
1905
+ if mode not in ("r", "a", "w", "x"):
1906
+ raise ValueError("mode must be 'r', 'a', 'w' or 'x'")
1907
+ return cls(name, mode, fileobj, **kwargs)
1908
+
1909
+ @classmethod
1910
+ def gzopen(cls, name, mode="r", fileobj=None, compresslevel=9, **kwargs):
1911
+ """Open gzip compressed tar archive name for reading or writing.
1912
+ Appending is not allowed.
1913
+ """
1914
+ if mode not in ("r", "w", "x"):
1915
+ raise ValueError("mode must be 'r', 'w' or 'x'")
1916
+
1917
+ try:
1918
+ from gzip import GzipFile
1919
+ except ImportError:
1920
+ raise CompressionError("gzip module is not available") from None
1921
+
1922
+ try:
1923
+ fileobj = GzipFile(name, mode + "b", compresslevel, fileobj)
1924
+ except OSError as e:
1925
+ if fileobj is not None and mode == 'r':
1926
+ raise ReadError("not a gzip file") from e
1927
+ raise
1928
+
1929
+ try:
1930
+ t = cls.taropen(name, mode, fileobj, **kwargs)
1931
+ except OSError as e:
1932
+ fileobj.close()
1933
+ if mode == 'r':
1934
+ raise ReadError("not a gzip file") from e
1935
+ raise
1936
+ except:
1937
+ fileobj.close()
1938
+ raise
1939
+ t._extfileobj = False
1940
+ return t
1941
+
1942
+ @classmethod
1943
+ def bz2open(cls, name, mode="r", fileobj=None, compresslevel=9, **kwargs):
1944
+ """Open bzip2 compressed tar archive name for reading or writing.
1945
+ Appending is not allowed.
1946
+ """
1947
+ if mode not in ("r", "w", "x"):
1948
+ raise ValueError("mode must be 'r', 'w' or 'x'")
1949
+
1950
+ try:
1951
+ from bz2 import BZ2File
1952
+ except ImportError:
1953
+ raise CompressionError("bz2 module is not available") from None
1954
+
1955
+ fileobj = BZ2File(fileobj or name, mode, compresslevel=compresslevel)
1956
+
1957
+ try:
1958
+ t = cls.taropen(name, mode, fileobj, **kwargs)
1959
+ except (OSError, EOFError) as e:
1960
+ fileobj.close()
1961
+ if mode == 'r':
1962
+ raise ReadError("not a bzip2 file") from e
1963
+ raise
1964
+ except:
1965
+ fileobj.close()
1966
+ raise
1967
+ t._extfileobj = False
1968
+ return t
1969
+
1970
+ @classmethod
1971
+ def xzopen(cls, name, mode="r", fileobj=None, preset=None, **kwargs):
1972
+ """Open lzma compressed tar archive name for reading or writing.
1973
+ Appending is not allowed.
1974
+ """
1975
+ if mode not in ("r", "w", "x"):
1976
+ raise ValueError("mode must be 'r', 'w' or 'x'")
1977
+
1978
+ try:
1979
+ from lzma import LZMAFile, LZMAError
1980
+ except ImportError:
1981
+ raise CompressionError("lzma module is not available") from None
1982
+
1983
+ fileobj = LZMAFile(fileobj or name, mode, preset=preset)
1984
+
1985
+ try:
1986
+ t = cls.taropen(name, mode, fileobj, **kwargs)
1987
+ except (LZMAError, EOFError) as e:
1988
+ fileobj.close()
1989
+ if mode == 'r':
1990
+ raise ReadError("not an lzma file") from e
1991
+ raise
1992
+ except:
1993
+ fileobj.close()
1994
+ raise
1995
+ t._extfileobj = False
1996
+ return t
1997
+
1998
+ # All *open() methods are registered here.
1999
+ OPEN_METH = {
2000
+ "tar": "taropen", # uncompressed tar
2001
+ "gz": "gzopen", # gzip compressed tar
2002
+ "bz2": "bz2open", # bzip2 compressed tar
2003
+ "xz": "xzopen" # lzma compressed tar
2004
+ }
2005
+
2006
+ #--------------------------------------------------------------------------
2007
+ # The public methods which TarFile provides:
2008
+
2009
+ def close(self):
2010
+ """Close the TarFile. In write-mode, two finishing zero blocks are
2011
+ appended to the archive.
2012
+ """
2013
+ if self.closed:
2014
+ return
2015
+
2016
+ self.closed = True
2017
+ try:
2018
+ if self.mode in ("a", "w", "x"):
2019
+ self.fileobj.write(NUL * (BLOCKSIZE * 2))
2020
+ self.offset += (BLOCKSIZE * 2)
2021
+ # fill up the end with zero-blocks
2022
+ # (like option -b20 for tar does)
2023
+ blocks, remainder = divmod(self.offset, RECORDSIZE)
2024
+ if remainder > 0:
2025
+ self.fileobj.write(NUL * (RECORDSIZE - remainder))
2026
+ finally:
2027
+ if not self._extfileobj:
2028
+ self.fileobj.close()
2029
+
2030
+ def getmember(self, name):
2031
+ """Return a TarInfo object for member `name'. If `name' can not be
2032
+ found in the archive, KeyError is raised. If a member occurs more
2033
+ than once in the archive, its last occurrence is assumed to be the
2034
+ most up-to-date version.
2035
+ """
2036
+ tarinfo = self._getmember(name.rstrip('/'))
2037
+ if tarinfo is None:
2038
+ raise KeyError("filename %r not found" % name)
2039
+ return tarinfo
2040
+
2041
+ def getmembers(self):
2042
+ """Return the members of the archive as a list of TarInfo objects. The
2043
+ list has the same order as the members in the archive.
2044
+ """
2045
+ self._check()
2046
+ if not self._loaded: # if we want to obtain a list of
2047
+ self._load() # all members, we first have to
2048
+ # scan the whole archive.
2049
+ return self.members
2050
+
2051
+ def getnames(self):
2052
+ """Return the members of the archive as a list of their names. It has
2053
+ the same order as the list returned by getmembers().
2054
+ """
2055
+ return [tarinfo.name for tarinfo in self.getmembers()]
2056
+
2057
+ def gettarinfo(self, name=None, arcname=None, fileobj=None):
2058
+ """Create a TarInfo object from the result of os.stat or equivalent
2059
+ on an existing file. The file is either named by `name', or
2060
+ specified as a file object `fileobj' with a file descriptor. If
2061
+ given, `arcname' specifies an alternative name for the file in the
2062
+ archive, otherwise, the name is taken from the 'name' attribute of
2063
+ 'fileobj', or the 'name' argument. The name should be a text
2064
+ string.
2065
+ """
2066
+ self._check("awx")
2067
+
2068
+ # When fileobj is given, replace name by
2069
+ # fileobj's real name.
2070
+ if fileobj is not None:
2071
+ name = fileobj.name
2072
+
2073
+ # Building the name of the member in the archive.
2074
+ # Backward slashes are converted to forward slashes,
2075
+ # Absolute paths are turned to relative paths.
2076
+ if arcname is None:
2077
+ arcname = name
2078
+ drv, arcname = os.path.splitdrive(arcname)
2079
+ arcname = arcname.replace(os.sep, "/")
2080
+ arcname = arcname.lstrip("/")
2081
+
2082
+ # Now, fill the TarInfo object with
2083
+ # information specific for the file.
2084
+ tarinfo = self.tarinfo()
2085
+ tarinfo.tarfile = self # Not needed
2086
+
2087
+ # Use os.stat or os.lstat, depending on if symlinks shall be resolved.
2088
+ if fileobj is None:
2089
+ if not self.dereference:
2090
+ statres = os.lstat(name)
2091
+ else:
2092
+ statres = os.stat(name)
2093
+ else:
2094
+ statres = os.fstat(fileobj.fileno())
2095
+ linkname = ""
2096
+
2097
+ stmd = statres.st_mode
2098
+ if stat.S_ISREG(stmd):
2099
+ inode = (statres.st_ino, statres.st_dev)
2100
+ if not self.dereference and statres.st_nlink > 1 and \
2101
+ inode in self.inodes and arcname != self.inodes[inode]:
2102
+ # Is it a hardlink to an already
2103
+ # archived file?
2104
+ type = LNKTYPE
2105
+ linkname = self.inodes[inode]
2106
+ else:
2107
+ # The inode is added only if its valid.
2108
+ # For win32 it is always 0.
2109
+ type = REGTYPE
2110
+ if inode[0]:
2111
+ self.inodes[inode] = arcname
2112
+ elif stat.S_ISDIR(stmd):
2113
+ type = DIRTYPE
2114
+ elif stat.S_ISFIFO(stmd):
2115
+ type = FIFOTYPE
2116
+ elif stat.S_ISLNK(stmd):
2117
+ type = SYMTYPE
2118
+ linkname = os.readlink(name)
2119
+ elif stat.S_ISCHR(stmd):
2120
+ type = CHRTYPE
2121
+ elif stat.S_ISBLK(stmd):
2122
+ type = BLKTYPE
2123
+ else:
2124
+ return None
2125
+
2126
+ # Fill the TarInfo object with all
2127
+ # information we can get.
2128
+ tarinfo.name = arcname
2129
+ tarinfo.mode = stmd
2130
+ tarinfo.uid = statres.st_uid
2131
+ tarinfo.gid = statres.st_gid
2132
+ if type == REGTYPE:
2133
+ tarinfo.size = statres.st_size
2134
+ else:
2135
+ tarinfo.size = 0
2136
+ tarinfo.mtime = statres.st_mtime
2137
+ tarinfo.type = type
2138
+ tarinfo.linkname = linkname
2139
+ if pwd:
2140
+ try:
2141
+ tarinfo.uname = pwd.getpwuid(tarinfo.uid)[0]
2142
+ except KeyError:
2143
+ pass
2144
+ if grp:
2145
+ try:
2146
+ tarinfo.gname = grp.getgrgid(tarinfo.gid)[0]
2147
+ except KeyError:
2148
+ pass
2149
+
2150
+ if type in (CHRTYPE, BLKTYPE):
2151
+ if hasattr(os, "major") and hasattr(os, "minor"):
2152
+ tarinfo.devmajor = os.major(statres.st_rdev)
2153
+ tarinfo.devminor = os.minor(statres.st_rdev)
2154
+ return tarinfo
2155
+
2156
+ def list(self, verbose=True, *, members=None):
2157
+ """Print a table of contents to sys.stdout. If `verbose' is False, only
2158
+ the names of the members are printed. If it is True, an `ls -l'-like
2159
+ output is produced. `members' is optional and must be a subset of the
2160
+ list returned by getmembers().
2161
+ """
2162
+ self._check()
2163
+
2164
+ if members is None:
2165
+ members = self
2166
+ for tarinfo in members:
2167
+ if verbose:
2168
+ if tarinfo.mode is None:
2169
+ _safe_print("??????????")
2170
+ else:
2171
+ _safe_print(stat.filemode(tarinfo.mode))
2172
+ _safe_print("%s/%s" % (tarinfo.uname or tarinfo.uid,
2173
+ tarinfo.gname or tarinfo.gid))
2174
+ if tarinfo.ischr() or tarinfo.isblk():
2175
+ _safe_print("%10s" %
2176
+ ("%d,%d" % (tarinfo.devmajor, tarinfo.devminor)))
2177
+ else:
2178
+ _safe_print("%10d" % tarinfo.size)
2179
+ if tarinfo.mtime is None:
2180
+ _safe_print("????-??-?? ??:??:??")
2181
+ else:
2182
+ _safe_print("%d-%02d-%02d %02d:%02d:%02d" \
2183
+ % time.localtime(tarinfo.mtime)[:6])
2184
+
2185
+ _safe_print(tarinfo.name + ("/" if tarinfo.isdir() else ""))
2186
+
2187
+ if verbose:
2188
+ if tarinfo.issym():
2189
+ _safe_print("-> " + tarinfo.linkname)
2190
+ if tarinfo.islnk():
2191
+ _safe_print("link to " + tarinfo.linkname)
2192
+ print()
2193
+
2194
+ def add(self, name, arcname=None, recursive=True, *, filter=None):
2195
+ """Add the file `name' to the archive. `name' may be any type of file
2196
+ (directory, fifo, symbolic link, etc.). If given, `arcname'
2197
+ specifies an alternative name for the file in the archive.
2198
+ Directories are added recursively by default. This can be avoided by
2199
+ setting `recursive' to False. `filter' is a function
2200
+ that expects a TarInfo object argument and returns the changed
2201
+ TarInfo object, if it returns None the TarInfo object will be
2202
+ excluded from the archive.
2203
+ """
2204
+ self._check("awx")
2205
+
2206
+ if arcname is None:
2207
+ arcname = name
2208
+
2209
+ # Skip if somebody tries to archive the archive...
2210
+ if self.name is not None and os.path.abspath(name) == self.name:
2211
+ self._dbg(2, "tarfile: Skipped %r" % name)
2212
+ return
2213
+
2214
+ self._dbg(1, name)
2215
+
2216
+ # Create a TarInfo object from the file.
2217
+ tarinfo = self.gettarinfo(name, arcname)
2218
+
2219
+ if tarinfo is None:
2220
+ self._dbg(1, "tarfile: Unsupported type %r" % name)
2221
+ return
2222
+
2223
+ # Change or exclude the TarInfo object.
2224
+ if filter is not None:
2225
+ tarinfo = filter(tarinfo)
2226
+ if tarinfo is None:
2227
+ self._dbg(2, "tarfile: Excluded %r" % name)
2228
+ return
2229
+
2230
+ # Append the tar header and data to the archive.
2231
+ if tarinfo.isreg():
2232
+ with bltn_open(name, "rb") as f:
2233
+ self.addfile(tarinfo, f)
2234
+
2235
+ elif tarinfo.isdir():
2236
+ self.addfile(tarinfo)
2237
+ if recursive:
2238
+ for f in sorted(os.listdir(name)):
2239
+ self.add(os.path.join(name, f), os.path.join(arcname, f),
2240
+ recursive, filter=filter)
2241
+
2242
+ else:
2243
+ self.addfile(tarinfo)
2244
+
2245
+ def addfile(self, tarinfo, fileobj=None):
2246
+ """Add the TarInfo object `tarinfo' to the archive. If `fileobj' is
2247
+ given, it should be a binary file, and tarinfo.size bytes are read
2248
+ from it and added to the archive. You can create TarInfo objects
2249
+ directly, or by using gettarinfo().
2250
+ """
2251
+ self._check("awx")
2252
+
2253
+ tarinfo = copy.copy(tarinfo)
2254
+
2255
+ buf = tarinfo.tobuf(self.format, self.encoding, self.errors)
2256
+ self.fileobj.write(buf)
2257
+ self.offset += len(buf)
2258
+ bufsize=self.copybufsize
2259
+ # If there's data to follow, append it.
2260
+ if fileobj is not None:
2261
+ copyfileobj(fileobj, self.fileobj, tarinfo.size, bufsize=bufsize)
2262
+ blocks, remainder = divmod(tarinfo.size, BLOCKSIZE)
2263
+ if remainder > 0:
2264
+ self.fileobj.write(NUL * (BLOCKSIZE - remainder))
2265
+ blocks += 1
2266
+ self.offset += blocks * BLOCKSIZE
2267
+
2268
+ self.members.append(tarinfo)
2269
+
2270
+ def _get_filter_function(self, filter):
2271
+ if filter is None:
2272
+ filter = self.extraction_filter
2273
+ if filter is None:
2274
+ warnings.warn(
2275
+ 'Python 3.14 will, by default, filter extracted tar '
2276
+ + 'archives and reject files or modify their metadata. '
2277
+ + 'Use the filter argument to control this behavior.',
2278
+ DeprecationWarning, stacklevel=3)
2279
+ return fully_trusted_filter
2280
+ if isinstance(filter, str):
2281
+ raise TypeError(
2282
+ 'String names are not supported for '
2283
+ + 'TarFile.extraction_filter. Use a function such as '
2284
+ + 'tarfile.data_filter directly.')
2285
+ return filter
2286
+ if callable(filter):
2287
+ return filter
2288
+ try:
2289
+ return _NAMED_FILTERS[filter]
2290
+ except KeyError:
2291
+ raise ValueError(f"filter {filter!r} not found") from None
2292
+
2293
+ def extractall(self, path=".", members=None, *, numeric_owner=False,
2294
+ filter=None):
2295
+ """Extract all members from the archive to the current working
2296
+ directory and set owner, modification time and permissions on
2297
+ directories afterwards. `path' specifies a different directory
2298
+ to extract to. `members' is optional and must be a subset of the
2299
+ list returned by getmembers(). If `numeric_owner` is True, only
2300
+ the numbers for user/group names are used and not the names.
2301
+
2302
+ The `filter` function will be called on each member just
2303
+ before extraction.
2304
+ It can return a changed TarInfo or None to skip the member.
2305
+ String names of common filters are accepted.
2306
+ """
2307
+ directories = []
2308
+
2309
+ filter_function = self._get_filter_function(filter)
2310
+ if members is None:
2311
+ members = self
2312
+
2313
+ for member in members:
2314
+ tarinfo, unfiltered = self._get_extract_tarinfo(
2315
+ member, filter_function, path)
2316
+ if tarinfo is None:
2317
+ continue
2318
+ if tarinfo.isdir():
2319
+ # For directories, delay setting attributes until later,
2320
+ # since permissions can interfere with extraction and
2321
+ # extracting contents can reset mtime.
2322
+ directories.append(unfiltered)
2323
+ self._extract_one(tarinfo, path, set_attrs=not tarinfo.isdir(),
2324
+ numeric_owner=numeric_owner,
2325
+ filter_function=filter_function)
2326
+
2327
+ # Reverse sort directories.
2328
+ directories.sort(key=lambda a: a.name, reverse=True)
2329
+
2330
+
2331
+ # Set correct owner, mtime and filemode on directories.
2332
+ for unfiltered in directories:
2333
+ try:
2334
+ # Need to re-apply any filter, to take the *current* filesystem
2335
+ # state into account.
2336
+ try:
2337
+ tarinfo = filter_function(unfiltered, path)
2338
+ except _FILTER_ERRORS as exc:
2339
+ self._log_no_directory_fixup(unfiltered, repr(exc))
2340
+ continue
2341
+ if tarinfo is None:
2342
+ self._log_no_directory_fixup(unfiltered,
2343
+ 'excluded by filter')
2344
+ continue
2345
+ dirpath = os.path.join(path, tarinfo.name)
2346
+ try:
2347
+ lstat = os.lstat(dirpath)
2348
+ except FileNotFoundError:
2349
+ self._log_no_directory_fixup(tarinfo, 'missing')
2350
+ continue
2351
+ if not stat.S_ISDIR(lstat.st_mode):
2352
+ # This is no longer a directory; presumably a later
2353
+ # member overwrote the entry.
2354
+ self._log_no_directory_fixup(tarinfo, 'not a directory')
2355
+ continue
2356
+ self.chown(tarinfo, dirpath, numeric_owner=numeric_owner)
2357
+ self.utime(tarinfo, dirpath)
2358
+ self.chmod(tarinfo, dirpath)
2359
+ except ExtractError as e:
2360
+ self._handle_nonfatal_error(e)
2361
+
2362
+ def _log_no_directory_fixup(self, member, reason):
2363
+ self._dbg(2, "tarfile: Not fixing up directory %r (%s)" %
2364
+ (member.name, reason))
2365
+
2366
+ def extract(self, member, path="", set_attrs=True, *, numeric_owner=False,
2367
+ filter=None):
2368
+ """Extract a member from the archive to the current working directory,
2369
+ using its full name. Its file information is extracted as accurately
2370
+ as possible. `member' may be a filename or a TarInfo object. You can
2371
+ specify a different directory using `path'. File attributes (owner,
2372
+ mtime, mode) are set unless `set_attrs' is False. If `numeric_owner`
2373
+ is True, only the numbers for user/group names are used and not
2374
+ the names.
2375
+
2376
+ The `filter` function will be called before extraction.
2377
+ It can return a changed TarInfo or None to skip the member.
2378
+ String names of common filters are accepted.
2379
+ """
2380
+ filter_function = self._get_filter_function(filter)
2381
+ tarinfo, unfiltered = self._get_extract_tarinfo(
2382
+ member, filter_function, path)
2383
+ if tarinfo is not None:
2384
+ self._extract_one(tarinfo, path, set_attrs, numeric_owner)
2385
+
2386
+ def _get_extract_tarinfo(self, member, filter_function, path):
2387
+ """Get (filtered, unfiltered) TarInfos from *member*
2388
+
2389
+ *member* might be a string.
2390
+
2391
+ Return (None, None) if not found.
2392
+ """
2393
+
2394
+ if isinstance(member, str):
2395
+ unfiltered = self.getmember(member)
2396
+ else:
2397
+ unfiltered = member
2398
+
2399
+ filtered = None
2400
+ try:
2401
+ filtered = filter_function(unfiltered, path)
2402
+ except (OSError, FilterError) as e:
2403
+ self._handle_fatal_error(e)
2404
+ except ExtractError as e:
2405
+ self._handle_nonfatal_error(e)
2406
+ if filtered is None:
2407
+ self._dbg(2, "tarfile: Excluded %r" % unfiltered.name)
2408
+ return None, None
2409
+
2410
+ # Prepare the link target for makelink().
2411
+ if filtered.islnk():
2412
+ filtered = copy.copy(filtered)
2413
+ filtered._link_target = os.path.join(path, filtered.linkname)
2414
+ return filtered, unfiltered
2415
+
2416
+ def _extract_one(self, tarinfo, path, set_attrs, numeric_owner,
2417
+ filter_function=None):
2418
+ """Extract from filtered tarinfo to disk.
2419
+
2420
+ filter_function is only used when extracting a *different*
2421
+ member (e.g. as fallback to creating a symlink)
2422
+ """
2423
+ self._check("r")
2424
+
2425
+ try:
2426
+ self._extract_member(tarinfo, os.path.join(path, tarinfo.name),
2427
+ set_attrs=set_attrs,
2428
+ numeric_owner=numeric_owner,
2429
+ filter_function=filter_function,
2430
+ extraction_root=path)
2431
+ except OSError as e:
2432
+ self._handle_fatal_error(e)
2433
+ except ExtractError as e:
2434
+ self._handle_nonfatal_error(e)
2435
+
2436
+ def _handle_nonfatal_error(self, e):
2437
+ """Handle non-fatal error (ExtractError) according to errorlevel"""
2438
+ if self.errorlevel > 1:
2439
+ raise
2440
+ else:
2441
+ self._dbg(1, "tarfile: %s" % e)
2442
+
2443
+ def _handle_fatal_error(self, e):
2444
+ """Handle "fatal" error according to self.errorlevel"""
2445
+ if self.errorlevel > 0:
2446
+ raise
2447
+ elif isinstance(e, OSError):
2448
+ if e.filename is None:
2449
+ self._dbg(1, "tarfile: %s" % e.strerror)
2450
+ else:
2451
+ self._dbg(1, "tarfile: %s %r" % (e.strerror, e.filename))
2452
+ else:
2453
+ self._dbg(1, "tarfile: %s %s" % (type(e).__name__, e))
2454
+
2455
+ def extractfile(self, member):
2456
+ """Extract a member from the archive as a file object. `member' may be
2457
+ a filename or a TarInfo object. If `member' is a regular file or
2458
+ a link, an io.BufferedReader object is returned. For all other
2459
+ existing members, None is returned. If `member' does not appear
2460
+ in the archive, KeyError is raised.
2461
+ """
2462
+ self._check("r")
2463
+
2464
+ if isinstance(member, str):
2465
+ tarinfo = self.getmember(member)
2466
+ else:
2467
+ tarinfo = member
2468
+
2469
+ if tarinfo.isreg() or tarinfo.type not in SUPPORTED_TYPES:
2470
+ # Members with unknown types are treated as regular files.
2471
+ return self.fileobject(self, tarinfo)
2472
+
2473
+ elif tarinfo.islnk() or tarinfo.issym():
2474
+ if isinstance(self.fileobj, _Stream):
2475
+ # A small but ugly workaround for the case that someone tries
2476
+ # to extract a (sym)link as a file-object from a non-seekable
2477
+ # stream of tar blocks.
2478
+ raise StreamError("cannot extract (sym)link as file object")
2479
+ else:
2480
+ # A (sym)link's file object is its target's file object.
2481
+ return self.extractfile(self._find_link_target(tarinfo))
2482
+ else:
2483
+ # If there's no data associated with the member (directory, chrdev,
2484
+ # blkdev, etc.), return None instead of a file object.
2485
+ return None
2486
+
2487
+ def _extract_member(self, tarinfo, targetpath, set_attrs=True,
2488
+ numeric_owner=False, *, filter_function=None,
2489
+ extraction_root=None):
2490
+ """Extract the filtered TarInfo object tarinfo to a physical
2491
+ file called targetpath.
2492
+
2493
+ filter_function is only used when extracting a *different*
2494
+ member (e.g. as fallback to creating a symlink)
2495
+ """
2496
+ # Fetch the TarInfo object for the given name
2497
+ # and build the destination pathname, replacing
2498
+ # forward slashes to platform specific separators.
2499
+ targetpath = targetpath.rstrip("/")
2500
+ targetpath = targetpath.replace("/", os.sep)
2501
+
2502
+ # Create all upper directories.
2503
+ upperdirs = os.path.dirname(targetpath)
2504
+ if upperdirs and not os.path.exists(upperdirs):
2505
+ # Create directories that are not part of the archive with
2506
+ # default permissions.
2507
+ os.makedirs(upperdirs)
2508
+
2509
+ if tarinfo.islnk() or tarinfo.issym():
2510
+ self._dbg(1, "%s -> %s" % (tarinfo.name, tarinfo.linkname))
2511
+ else:
2512
+ self._dbg(1, tarinfo.name)
2513
+
2514
+ if tarinfo.isreg():
2515
+ self.makefile(tarinfo, targetpath)
2516
+ elif tarinfo.isdir():
2517
+ self.makedir(tarinfo, targetpath)
2518
+ elif tarinfo.isfifo():
2519
+ self.makefifo(tarinfo, targetpath)
2520
+ elif tarinfo.ischr() or tarinfo.isblk():
2521
+ self.makedev(tarinfo, targetpath)
2522
+ elif tarinfo.islnk() or tarinfo.issym():
2523
+ self.makelink_with_filter(
2524
+ tarinfo, targetpath,
2525
+ filter_function=filter_function,
2526
+ extraction_root=extraction_root)
2527
+ elif tarinfo.type not in SUPPORTED_TYPES:
2528
+ self.makeunknown(tarinfo, targetpath)
2529
+ else:
2530
+ self.makefile(tarinfo, targetpath)
2531
+
2532
+ if set_attrs:
2533
+ self.chown(tarinfo, targetpath, numeric_owner)
2534
+ if not tarinfo.issym():
2535
+ self.chmod(tarinfo, targetpath)
2536
+ self.utime(tarinfo, targetpath)
2537
+
2538
+ #--------------------------------------------------------------------------
2539
+ # Below are the different file methods. They are called via
2540
+ # _extract_member() when extract() is called. They can be replaced in a
2541
+ # subclass to implement other functionality.
2542
+
2543
+ def makedir(self, tarinfo, targetpath):
2544
+ """Make a directory called targetpath.
2545
+ """
2546
+ try:
2547
+ if tarinfo.mode is None:
2548
+ # Use the system's default mode
2549
+ os.mkdir(targetpath)
2550
+ else:
2551
+ # Use a safe mode for the directory, the real mode is set
2552
+ # later in _extract_member().
2553
+ os.mkdir(targetpath, 0o700)
2554
+ except FileExistsError:
2555
+ if not os.path.isdir(targetpath):
2556
+ raise
2557
+
2558
+ def makefile(self, tarinfo, targetpath):
2559
+ """Make a file called targetpath.
2560
+ """
2561
+ source = self.fileobj
2562
+ source.seek(tarinfo.offset_data)
2563
+ bufsize = self.copybufsize
2564
+ with bltn_open(targetpath, "wb") as target:
2565
+ if tarinfo.sparse is not None:
2566
+ for offset, size in tarinfo.sparse:
2567
+ target.seek(offset)
2568
+ copyfileobj(source, target, size, ReadError, bufsize)
2569
+ target.seek(tarinfo.size)
2570
+ target.truncate()
2571
+ else:
2572
+ copyfileobj(source, target, tarinfo.size, ReadError, bufsize)
2573
+
2574
+ def makeunknown(self, tarinfo, targetpath):
2575
+ """Make a file from a TarInfo object with an unknown type
2576
+ at targetpath.
2577
+ """
2578
+ self.makefile(tarinfo, targetpath)
2579
+ self._dbg(1, "tarfile: Unknown file type %r, " \
2580
+ "extracted as regular file." % tarinfo.type)
2581
+
2582
+ def makefifo(self, tarinfo, targetpath):
2583
+ """Make a fifo called targetpath.
2584
+ """
2585
+ if hasattr(os, "mkfifo"):
2586
+ os.mkfifo(targetpath)
2587
+ else:
2588
+ raise ExtractError("fifo not supported by system")
2589
+
2590
+ def makedev(self, tarinfo, targetpath):
2591
+ """Make a character or block device called targetpath.
2592
+ """
2593
+ if not hasattr(os, "mknod") or not hasattr(os, "makedev"):
2594
+ raise ExtractError("special devices not supported by system")
2595
+
2596
+ mode = tarinfo.mode
2597
+ if mode is None:
2598
+ # Use mknod's default
2599
+ mode = 0o600
2600
+ if tarinfo.isblk():
2601
+ mode |= stat.S_IFBLK
2602
+ else:
2603
+ mode |= stat.S_IFCHR
2604
+
2605
+ os.mknod(targetpath, mode,
2606
+ os.makedev(tarinfo.devmajor, tarinfo.devminor))
2607
+
2608
+ def makelink(self, tarinfo, targetpath):
2609
+ return self.makelink_with_filter(tarinfo, targetpath, None, None)
2610
+
2611
+ def makelink_with_filter(self, tarinfo, targetpath,
2612
+ filter_function, extraction_root):
2613
+ """Make a (symbolic) link called targetpath. If it cannot be created
2614
+ (platform limitation), we try to make a copy of the referenced file
2615
+ instead of a link.
2616
+
2617
+ filter_function is only used when extracting a *different*
2618
+ member (e.g. as fallback to creating a link).
2619
+ """
2620
+ keyerror_to_extracterror = False
2621
+ try:
2622
+ # For systems that support symbolic and hard links.
2623
+ if tarinfo.issym():
2624
+ if os.path.lexists(targetpath):
2625
+ # Avoid FileExistsError on following os.symlink.
2626
+ os.unlink(targetpath)
2627
+ os.symlink(tarinfo.linkname, targetpath)
2628
+ return
2629
+ else:
2630
+ if os.path.exists(tarinfo._link_target):
2631
+ os.link(tarinfo._link_target, targetpath)
2632
+ return
2633
+ except symlink_exception:
2634
+ keyerror_to_extracterror = True
2635
+
2636
+ try:
2637
+ unfiltered = self._find_link_target(tarinfo)
2638
+ except KeyError:
2639
+ if keyerror_to_extracterror:
2640
+ raise ExtractError(
2641
+ "unable to resolve link inside archive") from None
2642
+ else:
2643
+ raise
2644
+
2645
+ if filter_function is None:
2646
+ filtered = unfiltered
2647
+ else:
2648
+ if extraction_root is None:
2649
+ raise ExtractError(
2650
+ "makelink_with_filter: if filter_function is not None, "
2651
+ + "extraction_root must also not be None")
2652
+ try:
2653
+ filtered = filter_function(unfiltered, extraction_root)
2654
+ except _FILTER_ERRORS as cause:
2655
+ raise LinkFallbackError(tarinfo, unfiltered.name) from cause
2656
+ if filtered is not None:
2657
+ self._extract_member(filtered, targetpath,
2658
+ filter_function=filter_function,
2659
+ extraction_root=extraction_root)
2660
+
2661
+ def chown(self, tarinfo, targetpath, numeric_owner):
2662
+ """Set owner of targetpath according to tarinfo. If numeric_owner
2663
+ is True, use .gid/.uid instead of .gname/.uname. If numeric_owner
2664
+ is False, fall back to .gid/.uid when the search based on name
2665
+ fails.
2666
+ """
2667
+ if hasattr(os, "geteuid") and os.geteuid() == 0:
2668
+ # We have to be root to do so.
2669
+ g = tarinfo.gid
2670
+ u = tarinfo.uid
2671
+ if not numeric_owner:
2672
+ try:
2673
+ if grp and tarinfo.gname:
2674
+ g = grp.getgrnam(tarinfo.gname)[2]
2675
+ except KeyError:
2676
+ pass
2677
+ try:
2678
+ if pwd and tarinfo.uname:
2679
+ u = pwd.getpwnam(tarinfo.uname)[2]
2680
+ except KeyError:
2681
+ pass
2682
+ if g is None:
2683
+ g = -1
2684
+ if u is None:
2685
+ u = -1
2686
+ try:
2687
+ if tarinfo.issym() and hasattr(os, "lchown"):
2688
+ os.lchown(targetpath, u, g)
2689
+ else:
2690
+ os.chown(targetpath, u, g)
2691
+ except OSError as e:
2692
+ raise ExtractError("could not change owner") from e
2693
+
2694
+ def chmod(self, tarinfo, targetpath):
2695
+ """Set file permissions of targetpath according to tarinfo.
2696
+ """
2697
+ if tarinfo.mode is None:
2698
+ return
2699
+ try:
2700
+ os.chmod(targetpath, tarinfo.mode)
2701
+ except OSError as e:
2702
+ raise ExtractError("could not change mode") from e
2703
+
2704
+ def utime(self, tarinfo, targetpath):
2705
+ """Set modification time of targetpath according to tarinfo.
2706
+ """
2707
+ mtime = tarinfo.mtime
2708
+ if mtime is None:
2709
+ return
2710
+ if not hasattr(os, 'utime'):
2711
+ return
2712
+ try:
2713
+ os.utime(targetpath, (mtime, mtime))
2714
+ except OSError as e:
2715
+ raise ExtractError("could not change modification time") from e
2716
+
2717
+ #--------------------------------------------------------------------------
2718
+ def next(self):
2719
+ """Return the next member of the archive as a TarInfo object, when
2720
+ TarFile is opened for reading. Return None if there is no more
2721
+ available.
2722
+ """
2723
+ self._check("ra")
2724
+ if self.firstmember is not None:
2725
+ m = self.firstmember
2726
+ self.firstmember = None
2727
+ return m
2728
+
2729
+ # Advance the file pointer.
2730
+ if self.offset != self.fileobj.tell():
2731
+ if self.offset == 0:
2732
+ return None
2733
+ self.fileobj.seek(self.offset - 1)
2734
+ if not self.fileobj.read(1):
2735
+ raise ReadError("unexpected end of data")
2736
+
2737
+ # Read the next block.
2738
+ tarinfo = None
2739
+ while True:
2740
+ try:
2741
+ tarinfo = self.tarinfo.fromtarfile(self)
2742
+ except EOFHeaderError as e:
2743
+ if self.ignore_zeros:
2744
+ self._dbg(2, "0x%X: %s" % (self.offset, e))
2745
+ self.offset += BLOCKSIZE
2746
+ continue
2747
+ except InvalidHeaderError as e:
2748
+ if self.ignore_zeros:
2749
+ self._dbg(2, "0x%X: %s" % (self.offset, e))
2750
+ self.offset += BLOCKSIZE
2751
+ continue
2752
+ elif self.offset == 0:
2753
+ raise ReadError(str(e)) from None
2754
+ except EmptyHeaderError:
2755
+ if self.offset == 0:
2756
+ raise ReadError("empty file") from None
2757
+ except TruncatedHeaderError as e:
2758
+ if self.offset == 0:
2759
+ raise ReadError(str(e)) from None
2760
+ except SubsequentHeaderError as e:
2761
+ raise ReadError(str(e)) from None
2762
+ except Exception as e:
2763
+ try:
2764
+ import zlib
2765
+ if isinstance(e, zlib.error):
2766
+ raise ReadError(f'zlib error: {e}') from None
2767
+ else:
2768
+ raise e
2769
+ except ImportError:
2770
+ raise e
2771
+ break
2772
+
2773
+ if tarinfo is not None:
2774
+ self.members.append(tarinfo)
2775
+ else:
2776
+ self._loaded = True
2777
+
2778
+ return tarinfo
2779
+
2780
+ #--------------------------------------------------------------------------
2781
+ # Little helper methods:
2782
+
2783
+ def _getmember(self, name, tarinfo=None, normalize=False):
2784
+ """Find an archive member by name from bottom to top.
2785
+ If tarinfo is given, it is used as the starting point.
2786
+ """
2787
+ # Ensure that all members have been loaded.
2788
+ members = self.getmembers()
2789
+
2790
+ # Limit the member search list up to tarinfo.
2791
+ skipping = False
2792
+ if tarinfo is not None:
2793
+ try:
2794
+ index = members.index(tarinfo)
2795
+ except ValueError:
2796
+ # The given starting point might be a (modified) copy.
2797
+ # We'll later skip members until we find an equivalent.
2798
+ skipping = True
2799
+ else:
2800
+ # Happy fast path
2801
+ members = members[:index]
2802
+
2803
+ if normalize:
2804
+ name = os.path.normpath(name)
2805
+
2806
+ for member in reversed(members):
2807
+ if skipping:
2808
+ if tarinfo.offset == member.offset:
2809
+ skipping = False
2810
+ continue
2811
+ if normalize:
2812
+ member_name = os.path.normpath(member.name)
2813
+ else:
2814
+ member_name = member.name
2815
+
2816
+ if name == member_name:
2817
+ return member
2818
+
2819
+ if skipping:
2820
+ # Starting point was not found
2821
+ raise ValueError(tarinfo)
2822
+
2823
+ def _load(self):
2824
+ """Read through the entire archive file and look for readable
2825
+ members.
2826
+ """
2827
+ while self.next() is not None:
2828
+ pass
2829
+ self._loaded = True
2830
+
2831
+ def _check(self, mode=None):
2832
+ """Check if TarFile is still open, and if the operation's mode
2833
+ corresponds to TarFile's mode.
2834
+ """
2835
+ if self.closed:
2836
+ raise OSError("%s is closed" % self.__class__.__name__)
2837
+ if mode is not None and self.mode not in mode:
2838
+ raise OSError("bad operation for mode %r" % self.mode)
2839
+
2840
+ def _find_link_target(self, tarinfo):
2841
+ """Find the target member of a symlink or hardlink member in the
2842
+ archive.
2843
+ """
2844
+ if tarinfo.issym():
2845
+ # Always search the entire archive.
2846
+ linkname = "/".join(filter(None, (os.path.dirname(tarinfo.name), tarinfo.linkname)))
2847
+ limit = None
2848
+ else:
2849
+ # Search the archive before the link, because a hard link is
2850
+ # just a reference to an already archived file.
2851
+ linkname = tarinfo.linkname
2852
+ limit = tarinfo
2853
+
2854
+ member = self._getmember(linkname, tarinfo=limit, normalize=True)
2855
+ if member is None:
2856
+ raise KeyError("linkname %r not found" % linkname)
2857
+ return member
2858
+
2859
+ def __iter__(self):
2860
+ """Provide an iterator object.
2861
+ """
2862
+ if self._loaded:
2863
+ yield from self.members
2864
+ return
2865
+
2866
+ # Yield items using TarFile's next() method.
2867
+ # When all members have been read, set TarFile as _loaded.
2868
+ index = 0
2869
+ # Fix for SF #1100429: Under rare circumstances it can
2870
+ # happen that getmembers() is called during iteration,
2871
+ # which will have already exhausted the next() method.
2872
+ if self.firstmember is not None:
2873
+ tarinfo = self.next()
2874
+ index += 1
2875
+ yield tarinfo
2876
+
2877
+ while True:
2878
+ if index < len(self.members):
2879
+ tarinfo = self.members[index]
2880
+ elif not self._loaded:
2881
+ tarinfo = self.next()
2882
+ if not tarinfo:
2883
+ self._loaded = True
2884
+ return
2885
+ else:
2886
+ return
2887
+ index += 1
2888
+ yield tarinfo
2889
+
2890
+ def _dbg(self, level, msg):
2891
+ """Write debugging output to sys.stderr.
2892
+ """
2893
+ if level <= self.debug:
2894
+ print(msg, file=sys.stderr)
2895
+
2896
+ def __enter__(self):
2897
+ self._check()
2898
+ return self
2899
+
2900
+ def __exit__(self, type, value, traceback):
2901
+ if type is None:
2902
+ self.close()
2903
+ else:
2904
+ # An exception occurred. We must not call close() because
2905
+ # it would try to write end-of-archive blocks and padding.
2906
+ if not self._extfileobj:
2907
+ self.fileobj.close()
2908
+ self.closed = True
2909
+
2910
+ #--------------------
2911
+ # exported functions
2912
+ #--------------------
2913
+
2914
+ def is_tarfile(name):
2915
+ """Return True if name points to a tar archive that we
2916
+ are able to handle, else return False.
2917
+
2918
+ 'name' should be a string, file, or file-like object.
2919
+ """
2920
+ try:
2921
+ if hasattr(name, "read"):
2922
+ pos = name.tell()
2923
+ t = open(fileobj=name)
2924
+ name.seek(pos)
2925
+ else:
2926
+ t = open(name)
2927
+ t.close()
2928
+ return True
2929
+ except TarError:
2930
+ return False
2931
+
2932
+ open = TarFile.open
2933
+
2934
+
2935
+ def main():
2936
+ import argparse
2937
+
2938
+ description = 'A simple command-line interface for tarfile module.'
2939
+ parser = argparse.ArgumentParser(description=description)
2940
+ parser.add_argument('-v', '--verbose', action='store_true', default=False,
2941
+ help='Verbose output')
2942
+ parser.add_argument('--filter', metavar='<filtername>',
2943
+ choices=_NAMED_FILTERS,
2944
+ help='Filter for extraction')
2945
+
2946
+ group = parser.add_mutually_exclusive_group(required=True)
2947
+ group.add_argument('-l', '--list', metavar='<tarfile>',
2948
+ help='Show listing of a tarfile')
2949
+ group.add_argument('-e', '--extract', nargs='+',
2950
+ metavar=('<tarfile>', '<output_dir>'),
2951
+ help='Extract tarfile into target dir')
2952
+ group.add_argument('-c', '--create', nargs='+',
2953
+ metavar=('<name>', '<file>'),
2954
+ help='Create tarfile from sources')
2955
+ group.add_argument('-t', '--test', metavar='<tarfile>',
2956
+ help='Test if a tarfile is valid')
2957
+
2958
+ args = parser.parse_args()
2959
+
2960
+ if args.filter and args.extract is None:
2961
+ parser.exit(1, '--filter is only valid for extraction\n')
2962
+
2963
+ if args.test is not None:
2964
+ src = args.test
2965
+ if is_tarfile(src):
2966
+ with open(src, 'r') as tar:
2967
+ tar.getmembers()
2968
+ print(tar.getmembers(), file=sys.stderr)
2969
+ if args.verbose:
2970
+ print('{!r} is a tar archive.'.format(src))
2971
+ else:
2972
+ parser.exit(1, '{!r} is not a tar archive.\n'.format(src))
2973
+
2974
+ elif args.list is not None:
2975
+ src = args.list
2976
+ if is_tarfile(src):
2977
+ with TarFile.open(src, 'r:*') as tf:
2978
+ tf.list(verbose=args.verbose)
2979
+ else:
2980
+ parser.exit(1, '{!r} is not a tar archive.\n'.format(src))
2981
+
2982
+ elif args.extract is not None:
2983
+ if len(args.extract) == 1:
2984
+ src = args.extract[0]
2985
+ curdir = os.curdir
2986
+ elif len(args.extract) == 2:
2987
+ src, curdir = args.extract
2988
+ else:
2989
+ parser.exit(1, parser.format_help())
2990
+
2991
+ if is_tarfile(src):
2992
+ with TarFile.open(src, 'r:*') as tf:
2993
+ tf.extractall(path=curdir, filter=args.filter)
2994
+ if args.verbose:
2995
+ if curdir == '.':
2996
+ msg = '{!r} file is extracted.'.format(src)
2997
+ else:
2998
+ msg = ('{!r} file is extracted '
2999
+ 'into {!r} directory.').format(src, curdir)
3000
+ print(msg)
3001
+ else:
3002
+ parser.exit(1, '{!r} is not a tar archive.\n'.format(src))
3003
+
3004
+ elif args.create is not None:
3005
+ tar_name = args.create.pop(0)
3006
+ _, ext = os.path.splitext(tar_name)
3007
+ compressions = {
3008
+ # gz
3009
+ '.gz': 'gz',
3010
+ '.tgz': 'gz',
3011
+ # xz
3012
+ '.xz': 'xz',
3013
+ '.txz': 'xz',
3014
+ # bz2
3015
+ '.bz2': 'bz2',
3016
+ '.tbz': 'bz2',
3017
+ '.tbz2': 'bz2',
3018
+ '.tb2': 'bz2',
3019
+ }
3020
+ tar_mode = 'w:' + compressions[ext] if ext in compressions else 'w'
3021
+ tar_files = args.create
3022
+
3023
+ with TarFile.open(tar_name, tar_mode) as tf:
3024
+ for file_name in tar_files:
3025
+ tf.add(file_name)
3026
+
3027
+ if args.verbose:
3028
+ print('{!r} file created.'.format(tar_name))
3029
+
3030
+ if __name__ == '__main__':
3031
+ main()