@ecmaos-apps/python3 0.0.0-stage → 3.14.9-ecmaos.1

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