@tedbrain/vlink 0.0.0-dpv2.ted-runner.python-linux-x64.3.9.0-dpv2.1.r6 → 0.0.0-dpv2.ted-runner.vlink-linux-x64.0.2.24.r6

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 (660) hide show
  1. package/bin/vlink +0 -0
  2. package/package.json +1 -1
  3. package/bin/python3 +0 -0
  4. package/lib/libX11.so.6 +0 -0
  5. package/lib/libXau.so.6 +0 -0
  6. package/lib/libXdmcp.so.6 +0 -0
  7. package/lib/libcrypt.so.1 +0 -0
  8. package/lib/libcrypto.so.1.1 +0 -0
  9. package/lib/libffi.so.7 +0 -0
  10. package/lib/libfreebl3.so +0 -0
  11. package/lib/liblzma.so.5 +0 -0
  12. package/lib/libncursesw.so.6 +0 -0
  13. package/lib/libnsl.so.1 +0 -0
  14. package/lib/libpanelw.so.6 +0 -0
  15. package/lib/libpython3.9.so.1.0 +0 -0
  16. package/lib/libreadline.so.8 +0 -0
  17. package/lib/libsqlite3.so.0 +0 -0
  18. package/lib/libssl.so.1.1 +0 -0
  19. package/lib/libtcl8.6.so +0 -0
  20. package/lib/libtinfow.so.6 +0 -0
  21. package/lib/libtk8.6.so +0 -0
  22. package/lib/libxcb.so.1 +0 -0
  23. package/lib/libz.so.1 +0 -0
  24. package/lib/python3.9/LICENSE.txt +0 -279
  25. package/lib/python3.9/__future__.py +0 -147
  26. package/lib/python3.9/__phello__.foo.py +0 -1
  27. package/lib/python3.9/_aix_support.py +0 -89
  28. package/lib/python3.9/_bootlocale.py +0 -46
  29. package/lib/python3.9/_bootsubprocess.py +0 -97
  30. package/lib/python3.9/_collections_abc.py +0 -1031
  31. package/lib/python3.9/_compat_pickle.py +0 -251
  32. package/lib/python3.9/_compression.py +0 -152
  33. package/lib/python3.9/_markupbase.py +0 -395
  34. package/lib/python3.9/_osx_support.py +0 -515
  35. package/lib/python3.9/_py_abc.py +0 -147
  36. package/lib/python3.9/_pydecimal.py +0 -6410
  37. package/lib/python3.9/_pyio.py +0 -2692
  38. package/lib/python3.9/_sitebuiltins.py +0 -103
  39. package/lib/python3.9/_strptime.py +0 -579
  40. package/lib/python3.9/_sysconfigdata__linux_x86_64-linux-gnu.py +0 -969
  41. package/lib/python3.9/_sysconfigdata__linux_x86_64-linux-gnu.py.orig +0 -969
  42. package/lib/python3.9/_sysconfigdata_x86_64_conda_cos6_linux_gnu.py +0 -969
  43. package/lib/python3.9/_threading_local.py +0 -242
  44. package/lib/python3.9/_weakrefset.py +0 -202
  45. package/lib/python3.9/abc.py +0 -129
  46. package/lib/python3.9/aifc.py +0 -947
  47. package/lib/python3.9/antigravity.py +0 -17
  48. package/lib/python3.9/argparse.py +0 -2575
  49. package/lib/python3.9/ast.py +0 -1530
  50. package/lib/python3.9/asynchat.py +0 -307
  51. package/lib/python3.9/asyncio/__init__.py +0 -47
  52. package/lib/python3.9/asyncio/__main__.py +0 -125
  53. package/lib/python3.9/asyncio/base_events.py +0 -1915
  54. package/lib/python3.9/asyncio/base_futures.py +0 -61
  55. package/lib/python3.9/asyncio/base_subprocess.py +0 -285
  56. package/lib/python3.9/asyncio/base_tasks.py +0 -85
  57. package/lib/python3.9/asyncio/constants.py +0 -27
  58. package/lib/python3.9/asyncio/coroutines.py +0 -269
  59. package/lib/python3.9/asyncio/events.py +0 -795
  60. package/lib/python3.9/asyncio/exceptions.py +0 -57
  61. package/lib/python3.9/asyncio/format_helpers.py +0 -76
  62. package/lib/python3.9/asyncio/futures.py +0 -423
  63. package/lib/python3.9/asyncio/locks.py +0 -451
  64. package/lib/python3.9/asyncio/log.py +0 -7
  65. package/lib/python3.9/asyncio/proactor_events.py +0 -868
  66. package/lib/python3.9/asyncio/protocols.py +0 -220
  67. package/lib/python3.9/asyncio/queues.py +0 -252
  68. package/lib/python3.9/asyncio/runners.py +0 -74
  69. package/lib/python3.9/asyncio/selector_events.py +0 -1099
  70. package/lib/python3.9/asyncio/sslproto.py +0 -733
  71. package/lib/python3.9/asyncio/staggered.py +0 -149
  72. package/lib/python3.9/asyncio/streams.py +0 -741
  73. package/lib/python3.9/asyncio/subprocess.py +0 -241
  74. package/lib/python3.9/asyncio/tasks.py +0 -980
  75. package/lib/python3.9/asyncio/threads.py +0 -25
  76. package/lib/python3.9/asyncio/transports.py +0 -329
  77. package/lib/python3.9/asyncio/trsock.py +0 -206
  78. package/lib/python3.9/asyncio/unix_events.py +0 -1466
  79. package/lib/python3.9/asyncio/windows_events.py +0 -908
  80. package/lib/python3.9/asyncio/windows_utils.py +0 -173
  81. package/lib/python3.9/asyncore.py +0 -642
  82. package/lib/python3.9/base64.py +0 -579
  83. package/lib/python3.9/bdb.py +0 -864
  84. package/lib/python3.9/binhex.py +0 -502
  85. package/lib/python3.9/bisect.py +0 -80
  86. package/lib/python3.9/bz2.py +0 -350
  87. package/lib/python3.9/cProfile.py +0 -180
  88. package/lib/python3.9/calendar.py +0 -770
  89. package/lib/python3.9/cgi.py +0 -996
  90. package/lib/python3.9/cgitb.py +0 -321
  91. package/lib/python3.9/chunk.py +0 -169
  92. package/lib/python3.9/cmd.py +0 -401
  93. package/lib/python3.9/code.py +0 -315
  94. package/lib/python3.9/codecs.py +0 -1126
  95. package/lib/python3.9/codeop.py +0 -178
  96. package/lib/python3.9/collections/__init__.py +0 -1508
  97. package/lib/python3.9/collections/abc.py +0 -2
  98. package/lib/python3.9/colorsys.py +0 -164
  99. package/lib/python3.9/compileall.py +0 -461
  100. package/lib/python3.9/concurrent/__init__.py +0 -1
  101. package/lib/python3.9/concurrent/futures/__init__.py +0 -53
  102. package/lib/python3.9/concurrent/futures/_base.py +0 -635
  103. package/lib/python3.9/concurrent/futures/process.py +0 -751
  104. package/lib/python3.9/concurrent/futures/thread.py +0 -230
  105. package/lib/python3.9/config-3.9-x86_64-linux-gnu/Makefile +0 -2015
  106. package/lib/python3.9/config-3.9-x86_64-linux-gnu/Setup +0 -372
  107. package/lib/python3.9/config-3.9-x86_64-linux-gnu/Setup.local +0 -1
  108. package/lib/python3.9/config-3.9-x86_64-linux-gnu/config.c +0 -116
  109. package/lib/python3.9/config-3.9-x86_64-linux-gnu/config.c.in +0 -67
  110. package/lib/python3.9/config-3.9-x86_64-linux-gnu/install-sh +0 -518
  111. package/lib/python3.9/config-3.9-x86_64-linux-gnu/makesetup +0 -309
  112. package/lib/python3.9/config-3.9-x86_64-linux-gnu/python-config.py +0 -74
  113. package/lib/python3.9/config-3.9-x86_64-linux-gnu/python.o +0 -0
  114. package/lib/python3.9/configparser.py +0 -1363
  115. package/lib/python3.9/contextlib.py +0 -676
  116. package/lib/python3.9/contextvars.py +0 -4
  117. package/lib/python3.9/copy.py +0 -303
  118. package/lib/python3.9/copyreg.py +0 -209
  119. package/lib/python3.9/crypt.py +0 -120
  120. package/lib/python3.9/csv.py +0 -448
  121. package/lib/python3.9/ctypes/__init__.py +0 -571
  122. package/lib/python3.9/ctypes/_aix.py +0 -331
  123. package/lib/python3.9/ctypes/_endian.py +0 -61
  124. package/lib/python3.9/ctypes/macholib/README.ctypes +0 -7
  125. package/lib/python3.9/ctypes/macholib/__init__.py +0 -9
  126. package/lib/python3.9/ctypes/macholib/dyld.py +0 -182
  127. package/lib/python3.9/ctypes/macholib/dylib.py +0 -63
  128. package/lib/python3.9/ctypes/macholib/fetch_macholib +0 -2
  129. package/lib/python3.9/ctypes/macholib/fetch_macholib.bat +0 -1
  130. package/lib/python3.9/ctypes/macholib/framework.py +0 -65
  131. package/lib/python3.9/ctypes/util.py +0 -379
  132. package/lib/python3.9/ctypes/wintypes.py +0 -202
  133. package/lib/python3.9/curses/__init__.py +0 -101
  134. package/lib/python3.9/curses/ascii.py +0 -99
  135. package/lib/python3.9/curses/has_key.py +0 -192
  136. package/lib/python3.9/curses/panel.py +0 -6
  137. package/lib/python3.9/curses/textpad.py +0 -201
  138. package/lib/python3.9/dataclasses.py +0 -1284
  139. package/lib/python3.9/datetime.py +0 -2555
  140. package/lib/python3.9/dbm/__init__.py +0 -189
  141. package/lib/python3.9/dbm/dumb.py +0 -316
  142. package/lib/python3.9/dbm/gnu.py +0 -3
  143. package/lib/python3.9/dbm/ndbm.py +0 -3
  144. package/lib/python3.9/decimal.py +0 -11
  145. package/lib/python3.9/difflib.py +0 -2096
  146. package/lib/python3.9/dis.py +0 -553
  147. package/lib/python3.9/distutils/README +0 -11
  148. package/lib/python3.9/distutils/__init__.py +0 -13
  149. package/lib/python3.9/distutils/_msvccompiler.py +0 -546
  150. package/lib/python3.9/distutils/archive_util.py +0 -256
  151. package/lib/python3.9/distutils/bcppcompiler.py +0 -393
  152. package/lib/python3.9/distutils/ccompiler.py +0 -1116
  153. package/lib/python3.9/distutils/cmd.py +0 -403
  154. package/lib/python3.9/distutils/command/__init__.py +0 -31
  155. package/lib/python3.9/distutils/command/bdist.py +0 -143
  156. package/lib/python3.9/distutils/command/bdist_dumb.py +0 -123
  157. package/lib/python3.9/distutils/command/bdist_msi.py +0 -749
  158. package/lib/python3.9/distutils/command/bdist_rpm.py +0 -579
  159. package/lib/python3.9/distutils/command/bdist_wininst.py +0 -377
  160. package/lib/python3.9/distutils/command/build.py +0 -157
  161. package/lib/python3.9/distutils/command/build_clib.py +0 -209
  162. package/lib/python3.9/distutils/command/build_ext.py +0 -754
  163. package/lib/python3.9/distutils/command/build_py.py +0 -416
  164. package/lib/python3.9/distutils/command/build_scripts.py +0 -160
  165. package/lib/python3.9/distutils/command/check.py +0 -148
  166. package/lib/python3.9/distutils/command/clean.py +0 -76
  167. package/lib/python3.9/distutils/command/command_template +0 -33
  168. package/lib/python3.9/distutils/command/config.py +0 -344
  169. package/lib/python3.9/distutils/command/install.py +0 -657
  170. package/lib/python3.9/distutils/command/install_data.py +0 -79
  171. package/lib/python3.9/distutils/command/install_egg_info.py +0 -77
  172. package/lib/python3.9/distutils/command/install_headers.py +0 -47
  173. package/lib/python3.9/distutils/command/install_lib.py +0 -217
  174. package/lib/python3.9/distutils/command/install_scripts.py +0 -60
  175. package/lib/python3.9/distutils/command/register.py +0 -304
  176. package/lib/python3.9/distutils/command/sdist.py +0 -494
  177. package/lib/python3.9/distutils/command/upload.py +0 -214
  178. package/lib/python3.9/distutils/config.py +0 -130
  179. package/lib/python3.9/distutils/core.py +0 -234
  180. package/lib/python3.9/distutils/cygwinccompiler.py +0 -410
  181. package/lib/python3.9/distutils/debug.py +0 -5
  182. package/lib/python3.9/distutils/dep_util.py +0 -92
  183. package/lib/python3.9/distutils/dir_util.py +0 -210
  184. package/lib/python3.9/distutils/dist.py +0 -1256
  185. package/lib/python3.9/distutils/errors.py +0 -97
  186. package/lib/python3.9/distutils/extension.py +0 -240
  187. package/lib/python3.9/distutils/fancy_getopt.py +0 -457
  188. package/lib/python3.9/distutils/file_util.py +0 -238
  189. package/lib/python3.9/distutils/filelist.py +0 -327
  190. package/lib/python3.9/distutils/log.py +0 -77
  191. package/lib/python3.9/distutils/msvc9compiler.py +0 -788
  192. package/lib/python3.9/distutils/msvccompiler.py +0 -643
  193. package/lib/python3.9/distutils/spawn.py +0 -125
  194. package/lib/python3.9/distutils/sysconfig.py +0 -560
  195. package/lib/python3.9/distutils/text_file.py +0 -286
  196. package/lib/python3.9/distutils/unixccompiler.py +0 -330
  197. package/lib/python3.9/distutils/util.py +0 -559
  198. package/lib/python3.9/distutils/version.py +0 -347
  199. package/lib/python3.9/distutils/versionpredicate.py +0 -166
  200. package/lib/python3.9/doctest.py +0 -2793
  201. package/lib/python3.9/email/__init__.py +0 -62
  202. package/lib/python3.9/email/_encoded_words.py +0 -233
  203. package/lib/python3.9/email/_header_value_parser.py +0 -3003
  204. package/lib/python3.9/email/_parseaddr.py +0 -549
  205. package/lib/python3.9/email/_policybase.py +0 -374
  206. package/lib/python3.9/email/architecture.rst +0 -216
  207. package/lib/python3.9/email/base64mime.py +0 -119
  208. package/lib/python3.9/email/charset.py +0 -404
  209. package/lib/python3.9/email/contentmanager.py +0 -250
  210. package/lib/python3.9/email/encoders.py +0 -69
  211. package/lib/python3.9/email/errors.py +0 -110
  212. package/lib/python3.9/email/feedparser.py +0 -536
  213. package/lib/python3.9/email/generator.py +0 -508
  214. package/lib/python3.9/email/header.py +0 -578
  215. package/lib/python3.9/email/headerregistry.py +0 -601
  216. package/lib/python3.9/email/iterators.py +0 -71
  217. package/lib/python3.9/email/message.py +0 -1173
  218. package/lib/python3.9/email/mime/__init__.py +0 -0
  219. package/lib/python3.9/email/mime/application.py +0 -37
  220. package/lib/python3.9/email/mime/audio.py +0 -74
  221. package/lib/python3.9/email/mime/base.py +0 -30
  222. package/lib/python3.9/email/mime/image.py +0 -47
  223. package/lib/python3.9/email/mime/message.py +0 -34
  224. package/lib/python3.9/email/mime/multipart.py +0 -48
  225. package/lib/python3.9/email/mime/nonmultipart.py +0 -22
  226. package/lib/python3.9/email/mime/text.py +0 -42
  227. package/lib/python3.9/email/parser.py +0 -131
  228. package/lib/python3.9/email/policy.py +0 -224
  229. package/lib/python3.9/email/quoprimime.py +0 -299
  230. package/lib/python3.9/email/utils.py +0 -368
  231. package/lib/python3.9/encodings/__init__.py +0 -169
  232. package/lib/python3.9/encodings/aliases.py +0 -551
  233. package/lib/python3.9/encodings/ascii.py +0 -50
  234. package/lib/python3.9/encodings/base64_codec.py +0 -55
  235. package/lib/python3.9/encodings/big5.py +0 -39
  236. package/lib/python3.9/encodings/big5hkscs.py +0 -39
  237. package/lib/python3.9/encodings/bz2_codec.py +0 -78
  238. package/lib/python3.9/encodings/charmap.py +0 -69
  239. package/lib/python3.9/encodings/cp037.py +0 -307
  240. package/lib/python3.9/encodings/cp1006.py +0 -307
  241. package/lib/python3.9/encodings/cp1026.py +0 -307
  242. package/lib/python3.9/encodings/cp1125.py +0 -698
  243. package/lib/python3.9/encodings/cp1140.py +0 -307
  244. package/lib/python3.9/encodings/cp1250.py +0 -307
  245. package/lib/python3.9/encodings/cp1251.py +0 -307
  246. package/lib/python3.9/encodings/cp1252.py +0 -307
  247. package/lib/python3.9/encodings/cp1253.py +0 -307
  248. package/lib/python3.9/encodings/cp1254.py +0 -307
  249. package/lib/python3.9/encodings/cp1255.py +0 -307
  250. package/lib/python3.9/encodings/cp1256.py +0 -307
  251. package/lib/python3.9/encodings/cp1257.py +0 -307
  252. package/lib/python3.9/encodings/cp1258.py +0 -307
  253. package/lib/python3.9/encodings/cp273.py +0 -307
  254. package/lib/python3.9/encodings/cp424.py +0 -307
  255. package/lib/python3.9/encodings/cp437.py +0 -698
  256. package/lib/python3.9/encodings/cp500.py +0 -307
  257. package/lib/python3.9/encodings/cp720.py +0 -309
  258. package/lib/python3.9/encodings/cp737.py +0 -698
  259. package/lib/python3.9/encodings/cp775.py +0 -697
  260. package/lib/python3.9/encodings/cp850.py +0 -698
  261. package/lib/python3.9/encodings/cp852.py +0 -698
  262. package/lib/python3.9/encodings/cp855.py +0 -698
  263. package/lib/python3.9/encodings/cp856.py +0 -307
  264. package/lib/python3.9/encodings/cp857.py +0 -694
  265. package/lib/python3.9/encodings/cp858.py +0 -698
  266. package/lib/python3.9/encodings/cp860.py +0 -698
  267. package/lib/python3.9/encodings/cp861.py +0 -698
  268. package/lib/python3.9/encodings/cp862.py +0 -698
  269. package/lib/python3.9/encodings/cp863.py +0 -698
  270. package/lib/python3.9/encodings/cp864.py +0 -690
  271. package/lib/python3.9/encodings/cp865.py +0 -698
  272. package/lib/python3.9/encodings/cp866.py +0 -698
  273. package/lib/python3.9/encodings/cp869.py +0 -689
  274. package/lib/python3.9/encodings/cp874.py +0 -307
  275. package/lib/python3.9/encodings/cp875.py +0 -307
  276. package/lib/python3.9/encodings/cp932.py +0 -39
  277. package/lib/python3.9/encodings/cp949.py +0 -39
  278. package/lib/python3.9/encodings/cp950.py +0 -39
  279. package/lib/python3.9/encodings/euc_jis_2004.py +0 -39
  280. package/lib/python3.9/encodings/euc_jisx0213.py +0 -39
  281. package/lib/python3.9/encodings/euc_jp.py +0 -39
  282. package/lib/python3.9/encodings/euc_kr.py +0 -39
  283. package/lib/python3.9/encodings/gb18030.py +0 -39
  284. package/lib/python3.9/encodings/gb2312.py +0 -39
  285. package/lib/python3.9/encodings/gbk.py +0 -39
  286. package/lib/python3.9/encodings/hex_codec.py +0 -55
  287. package/lib/python3.9/encodings/hp_roman8.py +0 -314
  288. package/lib/python3.9/encodings/hz.py +0 -39
  289. package/lib/python3.9/encodings/idna.py +0 -309
  290. package/lib/python3.9/encodings/iso2022_jp.py +0 -39
  291. package/lib/python3.9/encodings/iso2022_jp_1.py +0 -39
  292. package/lib/python3.9/encodings/iso2022_jp_2.py +0 -39
  293. package/lib/python3.9/encodings/iso2022_jp_2004.py +0 -39
  294. package/lib/python3.9/encodings/iso2022_jp_3.py +0 -39
  295. package/lib/python3.9/encodings/iso2022_jp_ext.py +0 -39
  296. package/lib/python3.9/encodings/iso2022_kr.py +0 -39
  297. package/lib/python3.9/encodings/iso8859_1.py +0 -307
  298. package/lib/python3.9/encodings/iso8859_10.py +0 -307
  299. package/lib/python3.9/encodings/iso8859_11.py +0 -307
  300. package/lib/python3.9/encodings/iso8859_13.py +0 -307
  301. package/lib/python3.9/encodings/iso8859_14.py +0 -307
  302. package/lib/python3.9/encodings/iso8859_15.py +0 -307
  303. package/lib/python3.9/encodings/iso8859_16.py +0 -307
  304. package/lib/python3.9/encodings/iso8859_2.py +0 -307
  305. package/lib/python3.9/encodings/iso8859_3.py +0 -307
  306. package/lib/python3.9/encodings/iso8859_4.py +0 -307
  307. package/lib/python3.9/encodings/iso8859_5.py +0 -307
  308. package/lib/python3.9/encodings/iso8859_6.py +0 -307
  309. package/lib/python3.9/encodings/iso8859_7.py +0 -307
  310. package/lib/python3.9/encodings/iso8859_8.py +0 -307
  311. package/lib/python3.9/encodings/iso8859_9.py +0 -307
  312. package/lib/python3.9/encodings/johab.py +0 -39
  313. package/lib/python3.9/encodings/koi8_r.py +0 -307
  314. package/lib/python3.9/encodings/koi8_t.py +0 -308
  315. package/lib/python3.9/encodings/koi8_u.py +0 -307
  316. package/lib/python3.9/encodings/kz1048.py +0 -307
  317. package/lib/python3.9/encodings/latin_1.py +0 -50
  318. package/lib/python3.9/encodings/mac_arabic.py +0 -698
  319. package/lib/python3.9/encodings/mac_croatian.py +0 -307
  320. package/lib/python3.9/encodings/mac_cyrillic.py +0 -307
  321. package/lib/python3.9/encodings/mac_farsi.py +0 -307
  322. package/lib/python3.9/encodings/mac_greek.py +0 -307
  323. package/lib/python3.9/encodings/mac_iceland.py +0 -307
  324. package/lib/python3.9/encodings/mac_latin2.py +0 -312
  325. package/lib/python3.9/encodings/mac_roman.py +0 -307
  326. package/lib/python3.9/encodings/mac_romanian.py +0 -307
  327. package/lib/python3.9/encodings/mac_turkish.py +0 -307
  328. package/lib/python3.9/encodings/mbcs.py +0 -47
  329. package/lib/python3.9/encodings/oem.py +0 -41
  330. package/lib/python3.9/encodings/palmos.py +0 -308
  331. package/lib/python3.9/encodings/ptcp154.py +0 -312
  332. package/lib/python3.9/encodings/punycode.py +0 -237
  333. package/lib/python3.9/encodings/quopri_codec.py +0 -56
  334. package/lib/python3.9/encodings/raw_unicode_escape.py +0 -45
  335. package/lib/python3.9/encodings/rot_13.py +0 -113
  336. package/lib/python3.9/encodings/shift_jis.py +0 -39
  337. package/lib/python3.9/encodings/shift_jis_2004.py +0 -39
  338. package/lib/python3.9/encodings/shift_jisx0213.py +0 -39
  339. package/lib/python3.9/encodings/tis_620.py +0 -307
  340. package/lib/python3.9/encodings/undefined.py +0 -49
  341. package/lib/python3.9/encodings/unicode_escape.py +0 -45
  342. package/lib/python3.9/encodings/utf_16.py +0 -155
  343. package/lib/python3.9/encodings/utf_16_be.py +0 -42
  344. package/lib/python3.9/encodings/utf_16_le.py +0 -42
  345. package/lib/python3.9/encodings/utf_32.py +0 -150
  346. package/lib/python3.9/encodings/utf_32_be.py +0 -37
  347. package/lib/python3.9/encodings/utf_32_le.py +0 -37
  348. package/lib/python3.9/encodings/utf_7.py +0 -38
  349. package/lib/python3.9/encodings/utf_8.py +0 -42
  350. package/lib/python3.9/encodings/utf_8_sig.py +0 -130
  351. package/lib/python3.9/encodings/uu_codec.py +0 -103
  352. package/lib/python3.9/encodings/zlib_codec.py +0 -77
  353. package/lib/python3.9/enum.py +0 -913
  354. package/lib/python3.9/filecmp.py +0 -309
  355. package/lib/python3.9/fileinput.py +0 -432
  356. package/lib/python3.9/fnmatch.py +0 -183
  357. package/lib/python3.9/formatter.py +0 -452
  358. package/lib/python3.9/fractions.py +0 -641
  359. package/lib/python3.9/ftplib.py +0 -974
  360. package/lib/python3.9/functools.py +0 -980
  361. package/lib/python3.9/genericpath.py +0 -155
  362. package/lib/python3.9/getopt.py +0 -215
  363. package/lib/python3.9/getpass.py +0 -185
  364. package/lib/python3.9/gettext.py +0 -788
  365. package/lib/python3.9/glob.py +0 -173
  366. package/lib/python3.9/graphlib.py +0 -245
  367. package/lib/python3.9/gzip.py +0 -609
  368. package/lib/python3.9/hashlib.py +0 -262
  369. package/lib/python3.9/heapq.py +0 -601
  370. package/lib/python3.9/hmac.py +0 -203
  371. package/lib/python3.9/html/__init__.py +0 -132
  372. package/lib/python3.9/html/entities.py +0 -2509
  373. package/lib/python3.9/html/parser.py +0 -462
  374. package/lib/python3.9/http/__init__.py +0 -149
  375. package/lib/python3.9/http/client.py +0 -1495
  376. package/lib/python3.9/http/cookiejar.py +0 -2113
  377. package/lib/python3.9/http/cookies.py +0 -612
  378. package/lib/python3.9/http/server.py +0 -1299
  379. package/lib/python3.9/imaplib.py +0 -1650
  380. package/lib/python3.9/imghdr.py +0 -168
  381. package/lib/python3.9/imp.py +0 -345
  382. package/lib/python3.9/importlib/__init__.py +0 -176
  383. package/lib/python3.9/importlib/_bootstrap.py +0 -1189
  384. package/lib/python3.9/importlib/_bootstrap_external.py +0 -1637
  385. package/lib/python3.9/importlib/_common.py +0 -62
  386. package/lib/python3.9/importlib/abc.py +0 -474
  387. package/lib/python3.9/importlib/machinery.py +0 -21
  388. package/lib/python3.9/importlib/metadata.py +0 -586
  389. package/lib/python3.9/importlib/resources.py +0 -215
  390. package/lib/python3.9/importlib/util.py +0 -300
  391. package/lib/python3.9/inspect.py +0 -3180
  392. package/lib/python3.9/io.py +0 -99
  393. package/lib/python3.9/ipaddress.py +0 -2280
  394. package/lib/python3.9/json/__init__.py +0 -359
  395. package/lib/python3.9/json/decoder.py +0 -356
  396. package/lib/python3.9/json/encoder.py +0 -442
  397. package/lib/python3.9/json/scanner.py +0 -73
  398. package/lib/python3.9/json/tool.py +0 -78
  399. package/lib/python3.9/keyword.py +0 -62
  400. package/lib/python3.9/lib-dynload/_asyncio.cpython-39-x86_64-linux-gnu.so +0 -0
  401. package/lib/python3.9/lib-dynload/_bisect.cpython-39-x86_64-linux-gnu.so +0 -0
  402. package/lib/python3.9/lib-dynload/_blake2.cpython-39-x86_64-linux-gnu.so +0 -0
  403. package/lib/python3.9/lib-dynload/_bz2.cpython-39-x86_64-linux-gnu.so +0 -0
  404. package/lib/python3.9/lib-dynload/_codecs_cn.cpython-39-x86_64-linux-gnu.so +0 -0
  405. package/lib/python3.9/lib-dynload/_codecs_hk.cpython-39-x86_64-linux-gnu.so +0 -0
  406. package/lib/python3.9/lib-dynload/_codecs_iso2022.cpython-39-x86_64-linux-gnu.so +0 -0
  407. package/lib/python3.9/lib-dynload/_codecs_jp.cpython-39-x86_64-linux-gnu.so +0 -0
  408. package/lib/python3.9/lib-dynload/_codecs_kr.cpython-39-x86_64-linux-gnu.so +0 -0
  409. package/lib/python3.9/lib-dynload/_codecs_tw.cpython-39-x86_64-linux-gnu.so +0 -0
  410. package/lib/python3.9/lib-dynload/_contextvars.cpython-39-x86_64-linux-gnu.so +0 -0
  411. package/lib/python3.9/lib-dynload/_crypt.cpython-39-x86_64-linux-gnu.so +0 -0
  412. package/lib/python3.9/lib-dynload/_csv.cpython-39-x86_64-linux-gnu.so +0 -0
  413. package/lib/python3.9/lib-dynload/_ctypes.cpython-39-x86_64-linux-gnu.so +0 -0
  414. package/lib/python3.9/lib-dynload/_ctypes_test.cpython-39-x86_64-linux-gnu.so +0 -0
  415. package/lib/python3.9/lib-dynload/_curses.cpython-39-x86_64-linux-gnu.so +0 -0
  416. package/lib/python3.9/lib-dynload/_curses_panel.cpython-39-x86_64-linux-gnu.so +0 -0
  417. package/lib/python3.9/lib-dynload/_datetime.cpython-39-x86_64-linux-gnu.so +0 -0
  418. package/lib/python3.9/lib-dynload/_decimal.cpython-39-x86_64-linux-gnu.so +0 -0
  419. package/lib/python3.9/lib-dynload/_elementtree.cpython-39-x86_64-linux-gnu.so +0 -0
  420. package/lib/python3.9/lib-dynload/_hashlib.cpython-39-x86_64-linux-gnu.so +0 -0
  421. package/lib/python3.9/lib-dynload/_heapq.cpython-39-x86_64-linux-gnu.so +0 -0
  422. package/lib/python3.9/lib-dynload/_json.cpython-39-x86_64-linux-gnu.so +0 -0
  423. package/lib/python3.9/lib-dynload/_lsprof.cpython-39-x86_64-linux-gnu.so +0 -0
  424. package/lib/python3.9/lib-dynload/_lzma.cpython-39-x86_64-linux-gnu.so +0 -0
  425. package/lib/python3.9/lib-dynload/_md5.cpython-39-x86_64-linux-gnu.so +0 -0
  426. package/lib/python3.9/lib-dynload/_multibytecodec.cpython-39-x86_64-linux-gnu.so +0 -0
  427. package/lib/python3.9/lib-dynload/_multiprocessing.cpython-39-x86_64-linux-gnu.so +0 -0
  428. package/lib/python3.9/lib-dynload/_opcode.cpython-39-x86_64-linux-gnu.so +0 -0
  429. package/lib/python3.9/lib-dynload/_pickle.cpython-39-x86_64-linux-gnu.so +0 -0
  430. package/lib/python3.9/lib-dynload/_posixshmem.cpython-39-x86_64-linux-gnu.so +0 -0
  431. package/lib/python3.9/lib-dynload/_posixsubprocess.cpython-39-x86_64-linux-gnu.so +0 -0
  432. package/lib/python3.9/lib-dynload/_queue.cpython-39-x86_64-linux-gnu.so +0 -0
  433. package/lib/python3.9/lib-dynload/_random.cpython-39-x86_64-linux-gnu.so +0 -0
  434. package/lib/python3.9/lib-dynload/_sha1.cpython-39-x86_64-linux-gnu.so +0 -0
  435. package/lib/python3.9/lib-dynload/_sha256.cpython-39-x86_64-linux-gnu.so +0 -0
  436. package/lib/python3.9/lib-dynload/_sha3.cpython-39-x86_64-linux-gnu.so +0 -0
  437. package/lib/python3.9/lib-dynload/_sha512.cpython-39-x86_64-linux-gnu.so +0 -0
  438. package/lib/python3.9/lib-dynload/_socket.cpython-39-x86_64-linux-gnu.so +0 -0
  439. package/lib/python3.9/lib-dynload/_sqlite3.cpython-39-x86_64-linux-gnu.so +0 -0
  440. package/lib/python3.9/lib-dynload/_ssl.cpython-39-x86_64-linux-gnu.so +0 -0
  441. package/lib/python3.9/lib-dynload/_statistics.cpython-39-x86_64-linux-gnu.so +0 -0
  442. package/lib/python3.9/lib-dynload/_struct.cpython-39-x86_64-linux-gnu.so +0 -0
  443. package/lib/python3.9/lib-dynload/_testbuffer.cpython-39-x86_64-linux-gnu.so +0 -0
  444. package/lib/python3.9/lib-dynload/_testcapi.cpython-39-x86_64-linux-gnu.so +0 -0
  445. package/lib/python3.9/lib-dynload/_testimportmultiple.cpython-39-x86_64-linux-gnu.so +0 -0
  446. package/lib/python3.9/lib-dynload/_testinternalcapi.cpython-39-x86_64-linux-gnu.so +0 -0
  447. package/lib/python3.9/lib-dynload/_testmultiphase.cpython-39-x86_64-linux-gnu.so +0 -0
  448. package/lib/python3.9/lib-dynload/_tkinter.cpython-39-x86_64-linux-gnu.so +0 -0
  449. package/lib/python3.9/lib-dynload/_xxsubinterpreters.cpython-39-x86_64-linux-gnu.so +0 -0
  450. package/lib/python3.9/lib-dynload/_xxtestfuzz.cpython-39-x86_64-linux-gnu.so +0 -0
  451. package/lib/python3.9/lib-dynload/_zoneinfo.cpython-39-x86_64-linux-gnu.so +0 -0
  452. package/lib/python3.9/lib-dynload/array.cpython-39-x86_64-linux-gnu.so +0 -0
  453. package/lib/python3.9/lib-dynload/audioop.cpython-39-x86_64-linux-gnu.so +0 -0
  454. package/lib/python3.9/lib-dynload/binascii.cpython-39-x86_64-linux-gnu.so +0 -0
  455. package/lib/python3.9/lib-dynload/cmath.cpython-39-x86_64-linux-gnu.so +0 -0
  456. package/lib/python3.9/lib-dynload/fcntl.cpython-39-x86_64-linux-gnu.so +0 -0
  457. package/lib/python3.9/lib-dynload/grp.cpython-39-x86_64-linux-gnu.so +0 -0
  458. package/lib/python3.9/lib-dynload/math.cpython-39-x86_64-linux-gnu.so +0 -0
  459. package/lib/python3.9/lib-dynload/mmap.cpython-39-x86_64-linux-gnu.so +0 -0
  460. package/lib/python3.9/lib-dynload/nis.cpython-39-x86_64-linux-gnu.so +0 -0
  461. package/lib/python3.9/lib-dynload/ossaudiodev.cpython-39-x86_64-linux-gnu.so +0 -0
  462. package/lib/python3.9/lib-dynload/parser.cpython-39-x86_64-linux-gnu.so +0 -0
  463. package/lib/python3.9/lib-dynload/pyexpat.cpython-39-x86_64-linux-gnu.so +0 -0
  464. package/lib/python3.9/lib-dynload/readline.cpython-39-x86_64-linux-gnu.so +0 -0
  465. package/lib/python3.9/lib-dynload/resource.cpython-39-x86_64-linux-gnu.so +0 -0
  466. package/lib/python3.9/lib-dynload/select.cpython-39-x86_64-linux-gnu.so +0 -0
  467. package/lib/python3.9/lib-dynload/spwd.cpython-39-x86_64-linux-gnu.so +0 -0
  468. package/lib/python3.9/lib-dynload/syslog.cpython-39-x86_64-linux-gnu.so +0 -0
  469. package/lib/python3.9/lib-dynload/termios.cpython-39-x86_64-linux-gnu.so +0 -0
  470. package/lib/python3.9/lib-dynload/unicodedata.cpython-39-x86_64-linux-gnu.so +0 -0
  471. package/lib/python3.9/lib-dynload/xxlimited.cpython-39-x86_64-linux-gnu.so +0 -0
  472. package/lib/python3.9/lib-dynload/zlib.cpython-39-x86_64-linux-gnu.so +0 -0
  473. package/lib/python3.9/linecache.py +0 -177
  474. package/lib/python3.9/locale.py +0 -1755
  475. package/lib/python3.9/logging/__init__.py +0 -2208
  476. package/lib/python3.9/logging/config.py +0 -945
  477. package/lib/python3.9/logging/handlers.py +0 -1543
  478. package/lib/python3.9/lzma.py +0 -347
  479. package/lib/python3.9/mailbox.py +0 -2151
  480. package/lib/python3.9/mailcap.py +0 -276
  481. package/lib/python3.9/mimetypes.py +0 -614
  482. package/lib/python3.9/modulefinder.py +0 -685
  483. package/lib/python3.9/multiprocessing/__init__.py +0 -37
  484. package/lib/python3.9/multiprocessing/connection.py +0 -978
  485. package/lib/python3.9/multiprocessing/context.py +0 -362
  486. package/lib/python3.9/multiprocessing/dummy/__init__.py +0 -126
  487. package/lib/python3.9/multiprocessing/dummy/connection.py +0 -75
  488. package/lib/python3.9/multiprocessing/forkserver.py +0 -348
  489. package/lib/python3.9/multiprocessing/heap.py +0 -337
  490. package/lib/python3.9/multiprocessing/managers.py +0 -1369
  491. package/lib/python3.9/multiprocessing/pool.py +0 -954
  492. package/lib/python3.9/multiprocessing/popen_fork.py +0 -83
  493. package/lib/python3.9/multiprocessing/popen_forkserver.py +0 -74
  494. package/lib/python3.9/multiprocessing/popen_spawn_posix.py +0 -72
  495. package/lib/python3.9/multiprocessing/popen_spawn_win32.py +0 -131
  496. package/lib/python3.9/multiprocessing/process.py +0 -432
  497. package/lib/python3.9/multiprocessing/queues.py +0 -380
  498. package/lib/python3.9/multiprocessing/reduction.py +0 -281
  499. package/lib/python3.9/multiprocessing/resource_sharer.py +0 -154
  500. package/lib/python3.9/multiprocessing/resource_tracker.py +0 -231
  501. package/lib/python3.9/multiprocessing/shared_memory.py +0 -532
  502. package/lib/python3.9/multiprocessing/sharedctypes.py +0 -240
  503. package/lib/python3.9/multiprocessing/spawn.py +0 -297
  504. package/lib/python3.9/multiprocessing/synchronize.py +0 -394
  505. package/lib/python3.9/multiprocessing/util.py +0 -489
  506. package/lib/python3.9/netrc.py +0 -139
  507. package/lib/python3.9/nntplib.py +0 -1090
  508. package/lib/python3.9/ntpath.py +0 -794
  509. package/lib/python3.9/nturl2path.py +0 -73
  510. package/lib/python3.9/numbers.py +0 -389
  511. package/lib/python3.9/opcode.py +0 -217
  512. package/lib/python3.9/operator.py +0 -460
  513. package/lib/python3.9/optparse.py +0 -1681
  514. package/lib/python3.9/os.py +0 -1116
  515. package/lib/python3.9/pathlib.py +0 -1576
  516. package/lib/python3.9/pdb.py +0 -1731
  517. package/lib/python3.9/pickle.py +0 -1817
  518. package/lib/python3.9/pickletools.py +0 -2890
  519. package/lib/python3.9/pipes.py +0 -247
  520. package/lib/python3.9/pkgutil.py +0 -707
  521. package/lib/python3.9/platform.py +0 -1259
  522. package/lib/python3.9/plistlib.py +0 -881
  523. package/lib/python3.9/poplib.py +0 -483
  524. package/lib/python3.9/posixpath.py +0 -525
  525. package/lib/python3.9/pprint.py +0 -638
  526. package/lib/python3.9/profile.py +0 -600
  527. package/lib/python3.9/pstats.py +0 -779
  528. package/lib/python3.9/pty.py +0 -172
  529. package/lib/python3.9/py_compile.py +0 -215
  530. package/lib/python3.9/pyclbr.py +0 -404
  531. package/lib/python3.9/pydoc.py +0 -2855
  532. package/lib/python3.9/pydoc_data/__init__.py +0 -0
  533. package/lib/python3.9/pydoc_data/_pydoc.css +0 -6
  534. package/lib/python3.9/pydoc_data/topics.py +0 -13968
  535. package/lib/python3.9/queue.py +0 -326
  536. package/lib/python3.9/quopri.py +0 -242
  537. package/lib/python3.9/random.py +0 -887
  538. package/lib/python3.9/re.py +0 -384
  539. package/lib/python3.9/reprlib.py +0 -161
  540. package/lib/python3.9/rlcompleter.py +0 -205
  541. package/lib/python3.9/runpy.py +0 -300
  542. package/lib/python3.9/sched.py +0 -167
  543. package/lib/python3.9/secrets.py +0 -72
  544. package/lib/python3.9/selectors.py +0 -619
  545. package/lib/python3.9/shelve.py +0 -243
  546. package/lib/python3.9/shlex.py +0 -350
  547. package/lib/python3.9/shutil.py +0 -1443
  548. package/lib/python3.9/signal.py +0 -85
  549. package/lib/python3.9/site.py +0 -643
  550. package/lib/python3.9/smtpd.py +0 -967
  551. package/lib/python3.9/smtplib.py +0 -1123
  552. package/lib/python3.9/sndhdr.py +0 -257
  553. package/lib/python3.9/socket.py +0 -958
  554. package/lib/python3.9/socketserver.py +0 -817
  555. package/lib/python3.9/sqlite3/__init__.py +0 -23
  556. package/lib/python3.9/sqlite3/dbapi2.py +0 -89
  557. package/lib/python3.9/sqlite3/dump.py +0 -70
  558. package/lib/python3.9/sre_compile.py +0 -784
  559. package/lib/python3.9/sre_constants.py +0 -259
  560. package/lib/python3.9/sre_parse.py +0 -1064
  561. package/lib/python3.9/ssl.py +0 -1489
  562. package/lib/python3.9/stat.py +0 -195
  563. package/lib/python3.9/statistics.py +0 -1120
  564. package/lib/python3.9/string.py +0 -280
  565. package/lib/python3.9/stringprep.py +0 -272
  566. package/lib/python3.9/struct.py +0 -15
  567. package/lib/python3.9/subprocess.py +0 -2074
  568. package/lib/python3.9/sunau.py +0 -526
  569. package/lib/python3.9/symbol.py +0 -122
  570. package/lib/python3.9/symtable.py +0 -243
  571. package/lib/python3.9/sysconfig.py +0 -720
  572. package/lib/python3.9/tabnanny.py +0 -333
  573. package/lib/python3.9/tarfile.py +0 -2576
  574. package/lib/python3.9/telnetlib.py +0 -677
  575. package/lib/python3.9/tempfile.py +0 -832
  576. package/lib/python3.9/textwrap.py +0 -486
  577. package/lib/python3.9/this.py +0 -28
  578. package/lib/python3.9/threading.py +0 -1502
  579. package/lib/python3.9/timeit.py +0 -375
  580. package/lib/python3.9/token.py +0 -136
  581. package/lib/python3.9/tokenize.py +0 -682
  582. package/lib/python3.9/trace.py +0 -740
  583. package/lib/python3.9/traceback.py +0 -623
  584. package/lib/python3.9/tracemalloc.py +0 -560
  585. package/lib/python3.9/tty.py +0 -36
  586. package/lib/python3.9/turtle.py +0 -4140
  587. package/lib/python3.9/types.py +0 -299
  588. package/lib/python3.9/typing.py +0 -2147
  589. package/lib/python3.9/unittest/__init__.py +0 -95
  590. package/lib/python3.9/unittest/__main__.py +0 -18
  591. package/lib/python3.9/unittest/_log.py +0 -69
  592. package/lib/python3.9/unittest/async_case.py +0 -160
  593. package/lib/python3.9/unittest/case.py +0 -1437
  594. package/lib/python3.9/unittest/loader.py +0 -517
  595. package/lib/python3.9/unittest/main.py +0 -275
  596. package/lib/python3.9/unittest/mock.py +0 -2891
  597. package/lib/python3.9/unittest/result.py +0 -216
  598. package/lib/python3.9/unittest/runner.py +0 -221
  599. package/lib/python3.9/unittest/signals.py +0 -71
  600. package/lib/python3.9/unittest/suite.py +0 -361
  601. package/lib/python3.9/unittest/util.py +0 -170
  602. package/lib/python3.9/urllib/__init__.py +0 -0
  603. package/lib/python3.9/urllib/error.py +0 -77
  604. package/lib/python3.9/urllib/parse.py +0 -1179
  605. package/lib/python3.9/urllib/request.py +0 -2765
  606. package/lib/python3.9/urllib/response.py +0 -84
  607. package/lib/python3.9/urllib/robotparser.py +0 -273
  608. package/lib/python3.9/uu.py +0 -206
  609. package/lib/python3.9/uuid.py +0 -728
  610. package/lib/python3.9/venv/__init__.py +0 -504
  611. package/lib/python3.9/venv/__main__.py +0 -10
  612. package/lib/python3.9/venv/scripts/common/Activate.ps1 +0 -241
  613. package/lib/python3.9/venv/scripts/common/activate +0 -66
  614. package/lib/python3.9/venv/scripts/posix/activate.csh +0 -25
  615. package/lib/python3.9/venv/scripts/posix/activate.fish +0 -64
  616. package/lib/python3.9/warnings.py +0 -549
  617. package/lib/python3.9/wave.py +0 -513
  618. package/lib/python3.9/weakref.py +0 -664
  619. package/lib/python3.9/webbrowser.py +0 -713
  620. package/lib/python3.9/wsgiref/__init__.py +0 -23
  621. package/lib/python3.9/wsgiref/handlers.py +0 -571
  622. package/lib/python3.9/wsgiref/headers.py +0 -184
  623. package/lib/python3.9/wsgiref/simple_server.py +0 -165
  624. package/lib/python3.9/wsgiref/util.py +0 -172
  625. package/lib/python3.9/wsgiref/validate.py +0 -441
  626. package/lib/python3.9/xdrlib.py +0 -241
  627. package/lib/python3.9/xml/__init__.py +0 -20
  628. package/lib/python3.9/xml/dom/NodeFilter.py +0 -27
  629. package/lib/python3.9/xml/dom/__init__.py +0 -140
  630. package/lib/python3.9/xml/dom/domreg.py +0 -99
  631. package/lib/python3.9/xml/dom/expatbuilder.py +0 -965
  632. package/lib/python3.9/xml/dom/minicompat.py +0 -109
  633. package/lib/python3.9/xml/dom/minidom.py +0 -2011
  634. package/lib/python3.9/xml/dom/pulldom.py +0 -349
  635. package/lib/python3.9/xml/dom/xmlbuilder.py +0 -387
  636. package/lib/python3.9/xml/etree/ElementInclude.py +0 -185
  637. package/lib/python3.9/xml/etree/ElementPath.py +0 -405
  638. package/lib/python3.9/xml/etree/ElementTree.py +0 -2085
  639. package/lib/python3.9/xml/etree/__init__.py +0 -33
  640. package/lib/python3.9/xml/etree/cElementTree.py +0 -3
  641. package/lib/python3.9/xml/parsers/__init__.py +0 -8
  642. package/lib/python3.9/xml/parsers/expat.py +0 -8
  643. package/lib/python3.9/xml/sax/__init__.py +0 -107
  644. package/lib/python3.9/xml/sax/_exceptions.py +0 -131
  645. package/lib/python3.9/xml/sax/expatreader.py +0 -446
  646. package/lib/python3.9/xml/sax/handler.py +0 -342
  647. package/lib/python3.9/xml/sax/saxutils.py +0 -369
  648. package/lib/python3.9/xml/sax/xmlreader.py +0 -380
  649. package/lib/python3.9/xmlrpc/__init__.py +0 -1
  650. package/lib/python3.9/xmlrpc/client.py +0 -1524
  651. package/lib/python3.9/xmlrpc/server.py +0 -993
  652. package/lib/python3.9/zipapp.py +0 -206
  653. package/lib/python3.9/zipfile.py +0 -2426
  654. package/lib/python3.9/zipimport.py +0 -792
  655. package/lib/python3.9/zoneinfo/__init__.py +0 -31
  656. package/lib/python3.9/zoneinfo/_common.py +0 -165
  657. package/lib/python3.9/zoneinfo/_tzpath.py +0 -175
  658. package/lib/python3.9/zoneinfo/_zoneinfo.py +0 -752
  659. package/runtime.json +0 -1
  660. package/ssl/cacert.pem +0 -3959
@@ -1,1443 +0,0 @@
1
- """Utility functions for copying and archiving files and directory trees.
2
-
3
- XXX The functions here don't copy the resource fork or other metadata on Mac.
4
-
5
- """
6
-
7
- import os
8
- import sys
9
- import stat
10
- import fnmatch
11
- import collections
12
- import errno
13
-
14
- try:
15
- import zlib
16
- del zlib
17
- _ZLIB_SUPPORTED = True
18
- except ImportError:
19
- _ZLIB_SUPPORTED = False
20
-
21
- try:
22
- import bz2
23
- del bz2
24
- _BZ2_SUPPORTED = True
25
- except ImportError:
26
- _BZ2_SUPPORTED = False
27
-
28
- try:
29
- import lzma
30
- del lzma
31
- _LZMA_SUPPORTED = True
32
- except ImportError:
33
- _LZMA_SUPPORTED = False
34
-
35
- try:
36
- from pwd import getpwnam
37
- except ImportError:
38
- getpwnam = None
39
-
40
- try:
41
- from grp import getgrnam
42
- except ImportError:
43
- getgrnam = None
44
-
45
- _WINDOWS = os.name == 'nt'
46
- posix = nt = None
47
- if os.name == 'posix':
48
- import posix
49
- elif _WINDOWS:
50
- import nt
51
-
52
- COPY_BUFSIZE = 1024 * 1024 if _WINDOWS else 64 * 1024
53
- _USE_CP_SENDFILE = hasattr(os, "sendfile") and sys.platform.startswith("linux")
54
- _HAS_FCOPYFILE = posix and hasattr(posix, "_fcopyfile") # macOS
55
-
56
- __all__ = ["copyfileobj", "copyfile", "copymode", "copystat", "copy", "copy2",
57
- "copytree", "move", "rmtree", "Error", "SpecialFileError",
58
- "ExecError", "make_archive", "get_archive_formats",
59
- "register_archive_format", "unregister_archive_format",
60
- "get_unpack_formats", "register_unpack_format",
61
- "unregister_unpack_format", "unpack_archive",
62
- "ignore_patterns", "chown", "which", "get_terminal_size",
63
- "SameFileError"]
64
- # disk_usage is added later, if available on the platform
65
-
66
- class Error(OSError):
67
- pass
68
-
69
- class SameFileError(Error):
70
- """Raised when source and destination are the same file."""
71
-
72
- class SpecialFileError(OSError):
73
- """Raised when trying to do a kind of operation (e.g. copying) which is
74
- not supported on a special file (e.g. a named pipe)"""
75
-
76
- class ExecError(OSError):
77
- """Raised when a command could not be executed"""
78
-
79
- class ReadError(OSError):
80
- """Raised when an archive cannot be read"""
81
-
82
- class RegistryError(Exception):
83
- """Raised when a registry operation with the archiving
84
- and unpacking registries fails"""
85
-
86
- class _GiveupOnFastCopy(Exception):
87
- """Raised as a signal to fallback on using raw read()/write()
88
- file copy when fast-copy functions fail to do so.
89
- """
90
-
91
- def _fastcopy_fcopyfile(fsrc, fdst, flags):
92
- """Copy a regular file content or metadata by using high-performance
93
- fcopyfile(3) syscall (macOS).
94
- """
95
- try:
96
- infd = fsrc.fileno()
97
- outfd = fdst.fileno()
98
- except Exception as err:
99
- raise _GiveupOnFastCopy(err) # not a regular file
100
-
101
- try:
102
- posix._fcopyfile(infd, outfd, flags)
103
- except OSError as err:
104
- err.filename = fsrc.name
105
- err.filename2 = fdst.name
106
- if err.errno in {errno.EINVAL, errno.ENOTSUP}:
107
- raise _GiveupOnFastCopy(err)
108
- else:
109
- raise err from None
110
-
111
- def _fastcopy_sendfile(fsrc, fdst):
112
- """Copy data from one regular mmap-like fd to another by using
113
- high-performance sendfile(2) syscall.
114
- This should work on Linux >= 2.6.33 only.
115
- """
116
- # Note: copyfileobj() is left alone in order to not introduce any
117
- # unexpected breakage. Possible risks by using zero-copy calls
118
- # in copyfileobj() are:
119
- # - fdst cannot be open in "a"(ppend) mode
120
- # - fsrc and fdst may be open in "t"(ext) mode
121
- # - fsrc may be a BufferedReader (which hides unread data in a buffer),
122
- # GzipFile (which decompresses data), HTTPResponse (which decodes
123
- # chunks).
124
- # - possibly others (e.g. encrypted fs/partition?)
125
- global _USE_CP_SENDFILE
126
- try:
127
- infd = fsrc.fileno()
128
- outfd = fdst.fileno()
129
- except Exception as err:
130
- raise _GiveupOnFastCopy(err) # not a regular file
131
-
132
- # Hopefully the whole file will be copied in a single call.
133
- # sendfile() is called in a loop 'till EOF is reached (0 return)
134
- # so a bufsize smaller or bigger than the actual file size
135
- # should not make any difference, also in case the file content
136
- # changes while being copied.
137
- try:
138
- blocksize = max(os.fstat(infd).st_size, 2 ** 23) # min 8MiB
139
- except OSError:
140
- blocksize = 2 ** 27 # 128MiB
141
- # On 32-bit architectures truncate to 1GiB to avoid OverflowError,
142
- # see bpo-38319.
143
- if sys.maxsize < 2 ** 32:
144
- blocksize = min(blocksize, 2 ** 30)
145
-
146
- offset = 0
147
- while True:
148
- try:
149
- sent = os.sendfile(outfd, infd, offset, blocksize)
150
- except OSError as err:
151
- # ...in oder to have a more informative exception.
152
- err.filename = fsrc.name
153
- err.filename2 = fdst.name
154
-
155
- if err.errno == errno.ENOTSOCK:
156
- # sendfile() on this platform (probably Linux < 2.6.33)
157
- # does not support copies between regular files (only
158
- # sockets).
159
- _USE_CP_SENDFILE = False
160
- raise _GiveupOnFastCopy(err)
161
-
162
- if err.errno == errno.ENOSPC: # filesystem is full
163
- raise err from None
164
-
165
- # Give up on first call and if no data was copied.
166
- if offset == 0 and os.lseek(outfd, 0, os.SEEK_CUR) == 0:
167
- raise _GiveupOnFastCopy(err)
168
-
169
- raise err
170
- else:
171
- if sent == 0:
172
- break # EOF
173
- offset += sent
174
-
175
- def _copyfileobj_readinto(fsrc, fdst, length=COPY_BUFSIZE):
176
- """readinto()/memoryview() based variant of copyfileobj().
177
- *fsrc* must support readinto() method and both files must be
178
- open in binary mode.
179
- """
180
- # Localize variable access to minimize overhead.
181
- fsrc_readinto = fsrc.readinto
182
- fdst_write = fdst.write
183
- with memoryview(bytearray(length)) as mv:
184
- while True:
185
- n = fsrc_readinto(mv)
186
- if not n:
187
- break
188
- elif n < length:
189
- with mv[:n] as smv:
190
- fdst.write(smv)
191
- else:
192
- fdst_write(mv)
193
-
194
- def copyfileobj(fsrc, fdst, length=0):
195
- """copy data from file-like object fsrc to file-like object fdst"""
196
- # Localize variable access to minimize overhead.
197
- if not length:
198
- length = COPY_BUFSIZE
199
- fsrc_read = fsrc.read
200
- fdst_write = fdst.write
201
- while True:
202
- buf = fsrc_read(length)
203
- if not buf:
204
- break
205
- fdst_write(buf)
206
-
207
- def _samefile(src, dst):
208
- # Macintosh, Unix.
209
- if isinstance(src, os.DirEntry) and hasattr(os.path, 'samestat'):
210
- try:
211
- return os.path.samestat(src.stat(), os.stat(dst))
212
- except OSError:
213
- return False
214
-
215
- if hasattr(os.path, 'samefile'):
216
- try:
217
- return os.path.samefile(src, dst)
218
- except OSError:
219
- return False
220
-
221
- # All other platforms: check for same pathname.
222
- return (os.path.normcase(os.path.abspath(src)) ==
223
- os.path.normcase(os.path.abspath(dst)))
224
-
225
- def _stat(fn):
226
- return fn.stat() if isinstance(fn, os.DirEntry) else os.stat(fn)
227
-
228
- def _islink(fn):
229
- return fn.is_symlink() if isinstance(fn, os.DirEntry) else os.path.islink(fn)
230
-
231
- def copyfile(src, dst, *, follow_symlinks=True):
232
- """Copy data from src to dst in the most efficient way possible.
233
-
234
- If follow_symlinks is not set and src is a symbolic link, a new
235
- symlink will be created instead of copying the file it points to.
236
-
237
- """
238
- sys.audit("shutil.copyfile", src, dst)
239
-
240
- if _samefile(src, dst):
241
- raise SameFileError("{!r} and {!r} are the same file".format(src, dst))
242
-
243
- file_size = 0
244
- for i, fn in enumerate([src, dst]):
245
- try:
246
- st = _stat(fn)
247
- except OSError:
248
- # File most likely does not exist
249
- pass
250
- else:
251
- # XXX What about other special files? (sockets, devices...)
252
- if stat.S_ISFIFO(st.st_mode):
253
- fn = fn.path if isinstance(fn, os.DirEntry) else fn
254
- raise SpecialFileError("`%s` is a named pipe" % fn)
255
- if _WINDOWS and i == 0:
256
- file_size = st.st_size
257
-
258
- if not follow_symlinks and _islink(src):
259
- os.symlink(os.readlink(src), dst)
260
- else:
261
- with open(src, 'rb') as fsrc, open(dst, 'wb') as fdst:
262
- # macOS
263
- if _HAS_FCOPYFILE:
264
- try:
265
- _fastcopy_fcopyfile(fsrc, fdst, posix._COPYFILE_DATA)
266
- return dst
267
- except _GiveupOnFastCopy:
268
- pass
269
- # Linux
270
- elif _USE_CP_SENDFILE:
271
- try:
272
- _fastcopy_sendfile(fsrc, fdst)
273
- return dst
274
- except _GiveupOnFastCopy:
275
- pass
276
- # Windows, see:
277
- # https://github.com/python/cpython/pull/7160#discussion_r195405230
278
- elif _WINDOWS and file_size > 0:
279
- _copyfileobj_readinto(fsrc, fdst, min(file_size, COPY_BUFSIZE))
280
- return dst
281
-
282
- copyfileobj(fsrc, fdst)
283
-
284
- return dst
285
-
286
- def copymode(src, dst, *, follow_symlinks=True):
287
- """Copy mode bits from src to dst.
288
-
289
- If follow_symlinks is not set, symlinks aren't followed if and only
290
- if both `src` and `dst` are symlinks. If `lchmod` isn't available
291
- (e.g. Linux) this method does nothing.
292
-
293
- """
294
- sys.audit("shutil.copymode", src, dst)
295
-
296
- if not follow_symlinks and _islink(src) and os.path.islink(dst):
297
- if hasattr(os, 'lchmod'):
298
- stat_func, chmod_func = os.lstat, os.lchmod
299
- else:
300
- return
301
- else:
302
- stat_func, chmod_func = _stat, os.chmod
303
-
304
- st = stat_func(src)
305
- chmod_func(dst, stat.S_IMODE(st.st_mode))
306
-
307
- if hasattr(os, 'listxattr'):
308
- def _copyxattr(src, dst, *, follow_symlinks=True):
309
- """Copy extended filesystem attributes from `src` to `dst`.
310
-
311
- Overwrite existing attributes.
312
-
313
- If `follow_symlinks` is false, symlinks won't be followed.
314
-
315
- """
316
-
317
- try:
318
- names = os.listxattr(src, follow_symlinks=follow_symlinks)
319
- except OSError as e:
320
- if e.errno not in (errno.ENOTSUP, errno.ENODATA, errno.EINVAL):
321
- raise
322
- return
323
- for name in names:
324
- try:
325
- value = os.getxattr(src, name, follow_symlinks=follow_symlinks)
326
- os.setxattr(dst, name, value, follow_symlinks=follow_symlinks)
327
- except OSError as e:
328
- if e.errno not in (errno.EPERM, errno.ENOTSUP, errno.ENODATA,
329
- errno.EINVAL):
330
- raise
331
- else:
332
- def _copyxattr(*args, **kwargs):
333
- pass
334
-
335
- def copystat(src, dst, *, follow_symlinks=True):
336
- """Copy file metadata
337
-
338
- Copy the permission bits, last access time, last modification time, and
339
- flags from `src` to `dst`. On Linux, copystat() also copies the "extended
340
- attributes" where possible. The file contents, owner, and group are
341
- unaffected. `src` and `dst` are path-like objects or path names given as
342
- strings.
343
-
344
- If the optional flag `follow_symlinks` is not set, symlinks aren't
345
- followed if and only if both `src` and `dst` are symlinks.
346
- """
347
- sys.audit("shutil.copystat", src, dst)
348
-
349
- def _nop(*args, ns=None, follow_symlinks=None):
350
- pass
351
-
352
- # follow symlinks (aka don't not follow symlinks)
353
- follow = follow_symlinks or not (_islink(src) and os.path.islink(dst))
354
- if follow:
355
- # use the real function if it exists
356
- def lookup(name):
357
- return getattr(os, name, _nop)
358
- else:
359
- # use the real function only if it exists
360
- # *and* it supports follow_symlinks
361
- def lookup(name):
362
- fn = getattr(os, name, _nop)
363
- if fn in os.supports_follow_symlinks:
364
- return fn
365
- return _nop
366
-
367
- if isinstance(src, os.DirEntry):
368
- st = src.stat(follow_symlinks=follow)
369
- else:
370
- st = lookup("stat")(src, follow_symlinks=follow)
371
- mode = stat.S_IMODE(st.st_mode)
372
- lookup("utime")(dst, ns=(st.st_atime_ns, st.st_mtime_ns),
373
- follow_symlinks=follow)
374
- # We must copy extended attributes before the file is (potentially)
375
- # chmod()'ed read-only, otherwise setxattr() will error with -EACCES.
376
- _copyxattr(src, dst, follow_symlinks=follow)
377
- try:
378
- lookup("chmod")(dst, mode, follow_symlinks=follow)
379
- except NotImplementedError:
380
- # if we got a NotImplementedError, it's because
381
- # * follow_symlinks=False,
382
- # * lchown() is unavailable, and
383
- # * either
384
- # * fchownat() is unavailable or
385
- # * fchownat() doesn't implement AT_SYMLINK_NOFOLLOW.
386
- # (it returned ENOSUP.)
387
- # therefore we're out of options--we simply cannot chown the
388
- # symlink. give up, suppress the error.
389
- # (which is what shutil always did in this circumstance.)
390
- pass
391
- if hasattr(st, 'st_flags'):
392
- try:
393
- lookup("chflags")(dst, st.st_flags, follow_symlinks=follow)
394
- except OSError as why:
395
- for err in 'EOPNOTSUPP', 'ENOTSUP':
396
- if hasattr(errno, err) and why.errno == getattr(errno, err):
397
- break
398
- else:
399
- raise
400
-
401
- def copy(src, dst, *, follow_symlinks=True):
402
- """Copy data and mode bits ("cp src dst"). Return the file's destination.
403
-
404
- The destination may be a directory.
405
-
406
- If follow_symlinks is false, symlinks won't be followed. This
407
- resembles GNU's "cp -P src dst".
408
-
409
- If source and destination are the same file, a SameFileError will be
410
- raised.
411
-
412
- """
413
- if os.path.isdir(dst):
414
- dst = os.path.join(dst, os.path.basename(src))
415
- copyfile(src, dst, follow_symlinks=follow_symlinks)
416
- copymode(src, dst, follow_symlinks=follow_symlinks)
417
- return dst
418
-
419
- def copy2(src, dst, *, follow_symlinks=True):
420
- """Copy data and metadata. Return the file's destination.
421
-
422
- Metadata is copied with copystat(). Please see the copystat function
423
- for more information.
424
-
425
- The destination may be a directory.
426
-
427
- If follow_symlinks is false, symlinks won't be followed. This
428
- resembles GNU's "cp -P src dst".
429
- """
430
- if os.path.isdir(dst):
431
- dst = os.path.join(dst, os.path.basename(src))
432
- copyfile(src, dst, follow_symlinks=follow_symlinks)
433
- copystat(src, dst, follow_symlinks=follow_symlinks)
434
- return dst
435
-
436
- def ignore_patterns(*patterns):
437
- """Function that can be used as copytree() ignore parameter.
438
-
439
- Patterns is a sequence of glob-style patterns
440
- that are used to exclude files"""
441
- def _ignore_patterns(path, names):
442
- ignored_names = []
443
- for pattern in patterns:
444
- ignored_names.extend(fnmatch.filter(names, pattern))
445
- return set(ignored_names)
446
- return _ignore_patterns
447
-
448
- def _copytree(entries, src, dst, symlinks, ignore, copy_function,
449
- ignore_dangling_symlinks, dirs_exist_ok=False):
450
- if ignore is not None:
451
- ignored_names = ignore(os.fspath(src), [x.name for x in entries])
452
- else:
453
- ignored_names = set()
454
-
455
- os.makedirs(dst, exist_ok=dirs_exist_ok)
456
- errors = []
457
- use_srcentry = copy_function is copy2 or copy_function is copy
458
-
459
- for srcentry in entries:
460
- if srcentry.name in ignored_names:
461
- continue
462
- srcname = os.path.join(src, srcentry.name)
463
- dstname = os.path.join(dst, srcentry.name)
464
- srcobj = srcentry if use_srcentry else srcname
465
- try:
466
- is_symlink = srcentry.is_symlink()
467
- if is_symlink and os.name == 'nt':
468
- # Special check for directory junctions, which appear as
469
- # symlinks but we want to recurse.
470
- lstat = srcentry.stat(follow_symlinks=False)
471
- if lstat.st_reparse_tag == stat.IO_REPARSE_TAG_MOUNT_POINT:
472
- is_symlink = False
473
- if is_symlink:
474
- linkto = os.readlink(srcname)
475
- if symlinks:
476
- # We can't just leave it to `copy_function` because legacy
477
- # code with a custom `copy_function` may rely on copytree
478
- # doing the right thing.
479
- os.symlink(linkto, dstname)
480
- copystat(srcobj, dstname, follow_symlinks=not symlinks)
481
- else:
482
- # ignore dangling symlink if the flag is on
483
- if not os.path.exists(linkto) and ignore_dangling_symlinks:
484
- continue
485
- # otherwise let the copy occur. copy2 will raise an error
486
- if srcentry.is_dir():
487
- copytree(srcobj, dstname, symlinks, ignore,
488
- copy_function, dirs_exist_ok=dirs_exist_ok)
489
- else:
490
- copy_function(srcobj, dstname)
491
- elif srcentry.is_dir():
492
- copytree(srcobj, dstname, symlinks, ignore, copy_function,
493
- dirs_exist_ok=dirs_exist_ok)
494
- else:
495
- # Will raise a SpecialFileError for unsupported file types
496
- copy_function(srcobj, dstname)
497
- # catch the Error from the recursive copytree so that we can
498
- # continue with other files
499
- except Error as err:
500
- errors.extend(err.args[0])
501
- except OSError as why:
502
- errors.append((srcname, dstname, str(why)))
503
- try:
504
- copystat(src, dst)
505
- except OSError as why:
506
- # Copying file access times may fail on Windows
507
- if getattr(why, 'winerror', None) is None:
508
- errors.append((src, dst, str(why)))
509
- if errors:
510
- raise Error(errors)
511
- return dst
512
-
513
- def copytree(src, dst, symlinks=False, ignore=None, copy_function=copy2,
514
- ignore_dangling_symlinks=False, dirs_exist_ok=False):
515
- """Recursively copy a directory tree and return the destination directory.
516
-
517
- dirs_exist_ok dictates whether to raise an exception in case dst or any
518
- missing parent directory already exists.
519
-
520
- If exception(s) occur, an Error is raised with a list of reasons.
521
-
522
- If the optional symlinks flag is true, symbolic links in the
523
- source tree result in symbolic links in the destination tree; if
524
- it is false, the contents of the files pointed to by symbolic
525
- links are copied. If the file pointed by the symlink doesn't
526
- exist, an exception will be added in the list of errors raised in
527
- an Error exception at the end of the copy process.
528
-
529
- You can set the optional ignore_dangling_symlinks flag to true if you
530
- want to silence this exception. Notice that this has no effect on
531
- platforms that don't support os.symlink.
532
-
533
- The optional ignore argument is a callable. If given, it
534
- is called with the `src` parameter, which is the directory
535
- being visited by copytree(), and `names` which is the list of
536
- `src` contents, as returned by os.listdir():
537
-
538
- callable(src, names) -> ignored_names
539
-
540
- Since copytree() is called recursively, the callable will be
541
- called once for each directory that is copied. It returns a
542
- list of names relative to the `src` directory that should
543
- not be copied.
544
-
545
- The optional copy_function argument is a callable that will be used
546
- to copy each file. It will be called with the source path and the
547
- destination path as arguments. By default, copy2() is used, but any
548
- function that supports the same signature (like copy()) can be used.
549
-
550
- """
551
- sys.audit("shutil.copytree", src, dst)
552
- with os.scandir(src) as itr:
553
- entries = list(itr)
554
- return _copytree(entries=entries, src=src, dst=dst, symlinks=symlinks,
555
- ignore=ignore, copy_function=copy_function,
556
- ignore_dangling_symlinks=ignore_dangling_symlinks,
557
- dirs_exist_ok=dirs_exist_ok)
558
-
559
- if hasattr(os.stat_result, 'st_file_attributes'):
560
- # Special handling for directory junctions to make them behave like
561
- # symlinks for shutil.rmtree, since in general they do not appear as
562
- # regular links.
563
- def _rmtree_isdir(entry):
564
- try:
565
- st = entry.stat(follow_symlinks=False)
566
- return (stat.S_ISDIR(st.st_mode) and not
567
- (st.st_file_attributes & stat.FILE_ATTRIBUTE_REPARSE_POINT
568
- and st.st_reparse_tag == stat.IO_REPARSE_TAG_MOUNT_POINT))
569
- except OSError:
570
- return False
571
-
572
- def _rmtree_islink(path):
573
- try:
574
- st = os.lstat(path)
575
- return (stat.S_ISLNK(st.st_mode) or
576
- (st.st_file_attributes & stat.FILE_ATTRIBUTE_REPARSE_POINT
577
- and st.st_reparse_tag == stat.IO_REPARSE_TAG_MOUNT_POINT))
578
- except OSError:
579
- return False
580
- else:
581
- def _rmtree_isdir(entry):
582
- try:
583
- return entry.is_dir(follow_symlinks=False)
584
- except OSError:
585
- return False
586
-
587
- def _rmtree_islink(path):
588
- return os.path.islink(path)
589
-
590
- # version vulnerable to race conditions
591
- def _rmtree_unsafe(path, onerror):
592
- try:
593
- with os.scandir(path) as scandir_it:
594
- entries = list(scandir_it)
595
- except OSError:
596
- onerror(os.scandir, path, sys.exc_info())
597
- entries = []
598
- for entry in entries:
599
- fullname = entry.path
600
- if _rmtree_isdir(entry):
601
- try:
602
- if entry.is_symlink():
603
- # This can only happen if someone replaces
604
- # a directory with a symlink after the call to
605
- # os.scandir or entry.is_dir above.
606
- raise OSError("Cannot call rmtree on a symbolic link")
607
- except OSError:
608
- onerror(os.path.islink, fullname, sys.exc_info())
609
- continue
610
- _rmtree_unsafe(fullname, onerror)
611
- else:
612
- try:
613
- os.unlink(fullname)
614
- except OSError:
615
- onerror(os.unlink, fullname, sys.exc_info())
616
- try:
617
- os.rmdir(path)
618
- except OSError:
619
- onerror(os.rmdir, path, sys.exc_info())
620
-
621
- # Version using fd-based APIs to protect against races
622
- def _rmtree_safe_fd(topfd, path, onerror):
623
- try:
624
- with os.scandir(topfd) as scandir_it:
625
- entries = list(scandir_it)
626
- except OSError as err:
627
- err.filename = path
628
- onerror(os.scandir, path, sys.exc_info())
629
- return
630
- for entry in entries:
631
- fullname = os.path.join(path, entry.name)
632
- try:
633
- is_dir = entry.is_dir(follow_symlinks=False)
634
- except OSError:
635
- is_dir = False
636
- else:
637
- if is_dir:
638
- try:
639
- orig_st = entry.stat(follow_symlinks=False)
640
- is_dir = stat.S_ISDIR(orig_st.st_mode)
641
- except OSError:
642
- onerror(os.lstat, fullname, sys.exc_info())
643
- continue
644
- if is_dir:
645
- try:
646
- dirfd = os.open(entry.name, os.O_RDONLY, dir_fd=topfd)
647
- except OSError:
648
- onerror(os.open, fullname, sys.exc_info())
649
- else:
650
- try:
651
- if os.path.samestat(orig_st, os.fstat(dirfd)):
652
- _rmtree_safe_fd(dirfd, fullname, onerror)
653
- try:
654
- os.rmdir(entry.name, dir_fd=topfd)
655
- except OSError:
656
- onerror(os.rmdir, fullname, sys.exc_info())
657
- else:
658
- try:
659
- # This can only happen if someone replaces
660
- # a directory with a symlink after the call to
661
- # os.scandir or stat.S_ISDIR above.
662
- raise OSError("Cannot call rmtree on a symbolic "
663
- "link")
664
- except OSError:
665
- onerror(os.path.islink, fullname, sys.exc_info())
666
- finally:
667
- os.close(dirfd)
668
- else:
669
- try:
670
- os.unlink(entry.name, dir_fd=topfd)
671
- except OSError:
672
- onerror(os.unlink, fullname, sys.exc_info())
673
-
674
- _use_fd_functions = ({os.open, os.stat, os.unlink, os.rmdir} <=
675
- os.supports_dir_fd and
676
- os.scandir in os.supports_fd and
677
- os.stat in os.supports_follow_symlinks)
678
-
679
- def rmtree(path, ignore_errors=False, onerror=None):
680
- """Recursively delete a directory tree.
681
-
682
- If ignore_errors is set, errors are ignored; otherwise, if onerror
683
- is set, it is called to handle the error with arguments (func,
684
- path, exc_info) where func is platform and implementation dependent;
685
- path is the argument to that function that caused it to fail; and
686
- exc_info is a tuple returned by sys.exc_info(). If ignore_errors
687
- is false and onerror is None, an exception is raised.
688
-
689
- """
690
- sys.audit("shutil.rmtree", path)
691
- if ignore_errors:
692
- def onerror(*args):
693
- pass
694
- elif onerror is None:
695
- def onerror(*args):
696
- raise
697
- if _use_fd_functions:
698
- # While the unsafe rmtree works fine on bytes, the fd based does not.
699
- if isinstance(path, bytes):
700
- path = os.fsdecode(path)
701
- # Note: To guard against symlink races, we use the standard
702
- # lstat()/open()/fstat() trick.
703
- try:
704
- orig_st = os.lstat(path)
705
- except Exception:
706
- onerror(os.lstat, path, sys.exc_info())
707
- return
708
- try:
709
- fd = os.open(path, os.O_RDONLY)
710
- except Exception:
711
- onerror(os.lstat, path, sys.exc_info())
712
- return
713
- try:
714
- if os.path.samestat(orig_st, os.fstat(fd)):
715
- _rmtree_safe_fd(fd, path, onerror)
716
- try:
717
- os.rmdir(path)
718
- except OSError:
719
- onerror(os.rmdir, path, sys.exc_info())
720
- else:
721
- try:
722
- # symlinks to directories are forbidden, see bug #1669
723
- raise OSError("Cannot call rmtree on a symbolic link")
724
- except OSError:
725
- onerror(os.path.islink, path, sys.exc_info())
726
- finally:
727
- os.close(fd)
728
- else:
729
- try:
730
- if _rmtree_islink(path):
731
- # symlinks to directories are forbidden, see bug #1669
732
- raise OSError("Cannot call rmtree on a symbolic link")
733
- except OSError:
734
- onerror(os.path.islink, path, sys.exc_info())
735
- # can't continue even if onerror hook returns
736
- return
737
- return _rmtree_unsafe(path, onerror)
738
-
739
- # Allow introspection of whether or not the hardening against symlink
740
- # attacks is supported on the current platform
741
- rmtree.avoids_symlink_attacks = _use_fd_functions
742
-
743
- def _basename(path):
744
- """A basename() variant which first strips the trailing slash, if present.
745
- Thus we always get the last component of the path, even for directories.
746
-
747
- path: Union[PathLike, str]
748
-
749
- e.g.
750
- >>> os.path.basename('/bar/foo')
751
- 'foo'
752
- >>> os.path.basename('/bar/foo/')
753
- ''
754
- >>> _basename('/bar/foo/')
755
- 'foo'
756
- """
757
- path = os.fspath(path)
758
- sep = os.path.sep + (os.path.altsep or '')
759
- return os.path.basename(path.rstrip(sep))
760
-
761
- def move(src, dst, copy_function=copy2):
762
- """Recursively move a file or directory to another location. This is
763
- similar to the Unix "mv" command. Return the file or directory's
764
- destination.
765
-
766
- If the destination is a directory or a symlink to a directory, the source
767
- is moved inside the directory. The destination path must not already
768
- exist.
769
-
770
- If the destination already exists but is not a directory, it may be
771
- overwritten depending on os.rename() semantics.
772
-
773
- If the destination is on our current filesystem, then rename() is used.
774
- Otherwise, src is copied to the destination and then removed. Symlinks are
775
- recreated under the new name if os.rename() fails because of cross
776
- filesystem renames.
777
-
778
- The optional `copy_function` argument is a callable that will be used
779
- to copy the source or it will be delegated to `copytree`.
780
- By default, copy2() is used, but any function that supports the same
781
- signature (like copy()) can be used.
782
-
783
- A lot more could be done here... A look at a mv.c shows a lot of
784
- the issues this implementation glosses over.
785
-
786
- """
787
- sys.audit("shutil.move", src, dst)
788
- real_dst = dst
789
- if os.path.isdir(dst):
790
- if _samefile(src, dst):
791
- # We might be on a case insensitive filesystem,
792
- # perform the rename anyway.
793
- os.rename(src, dst)
794
- return
795
-
796
- # Using _basename instead of os.path.basename is important, as we must
797
- # ignore any trailing slash to avoid the basename returning ''
798
- real_dst = os.path.join(dst, _basename(src))
799
-
800
- if os.path.exists(real_dst):
801
- raise Error("Destination path '%s' already exists" % real_dst)
802
- try:
803
- os.rename(src, real_dst)
804
- except OSError:
805
- if os.path.islink(src):
806
- linkto = os.readlink(src)
807
- os.symlink(linkto, real_dst)
808
- os.unlink(src)
809
- elif os.path.isdir(src):
810
- if _destinsrc(src, dst):
811
- raise Error("Cannot move a directory '%s' into itself"
812
- " '%s'." % (src, dst))
813
- copytree(src, real_dst, copy_function=copy_function,
814
- symlinks=True)
815
- rmtree(src)
816
- else:
817
- copy_function(src, real_dst)
818
- os.unlink(src)
819
- return real_dst
820
-
821
- def _destinsrc(src, dst):
822
- src = os.path.abspath(src)
823
- dst = os.path.abspath(dst)
824
- if not src.endswith(os.path.sep):
825
- src += os.path.sep
826
- if not dst.endswith(os.path.sep):
827
- dst += os.path.sep
828
- return dst.startswith(src)
829
-
830
- def _get_gid(name):
831
- """Returns a gid, given a group name."""
832
- if getgrnam is None or name is None:
833
- return None
834
- try:
835
- result = getgrnam(name)
836
- except KeyError:
837
- result = None
838
- if result is not None:
839
- return result[2]
840
- return None
841
-
842
- def _get_uid(name):
843
- """Returns an uid, given a user name."""
844
- if getpwnam is None or name is None:
845
- return None
846
- try:
847
- result = getpwnam(name)
848
- except KeyError:
849
- result = None
850
- if result is not None:
851
- return result[2]
852
- return None
853
-
854
- def _make_tarball(base_name, base_dir, compress="gzip", verbose=0, dry_run=0,
855
- owner=None, group=None, logger=None):
856
- """Create a (possibly compressed) tar file from all the files under
857
- 'base_dir'.
858
-
859
- 'compress' must be "gzip" (the default), "bzip2", "xz", or None.
860
-
861
- 'owner' and 'group' can be used to define an owner and a group for the
862
- archive that is being built. If not provided, the current owner and group
863
- will be used.
864
-
865
- The output tar file will be named 'base_name' + ".tar", possibly plus
866
- the appropriate compression extension (".gz", ".bz2", or ".xz").
867
-
868
- Returns the output filename.
869
- """
870
- if compress is None:
871
- tar_compression = ''
872
- elif _ZLIB_SUPPORTED and compress == 'gzip':
873
- tar_compression = 'gz'
874
- elif _BZ2_SUPPORTED and compress == 'bzip2':
875
- tar_compression = 'bz2'
876
- elif _LZMA_SUPPORTED and compress == 'xz':
877
- tar_compression = 'xz'
878
- else:
879
- raise ValueError("bad value for 'compress', or compression format not "
880
- "supported : {0}".format(compress))
881
-
882
- import tarfile # late import for breaking circular dependency
883
-
884
- compress_ext = '.' + tar_compression if compress else ''
885
- archive_name = base_name + '.tar' + compress_ext
886
- archive_dir = os.path.dirname(archive_name)
887
-
888
- if archive_dir and not os.path.exists(archive_dir):
889
- if logger is not None:
890
- logger.info("creating %s", archive_dir)
891
- if not dry_run:
892
- os.makedirs(archive_dir)
893
-
894
- # creating the tarball
895
- if logger is not None:
896
- logger.info('Creating tar archive')
897
-
898
- uid = _get_uid(owner)
899
- gid = _get_gid(group)
900
-
901
- def _set_uid_gid(tarinfo):
902
- if gid is not None:
903
- tarinfo.gid = gid
904
- tarinfo.gname = group
905
- if uid is not None:
906
- tarinfo.uid = uid
907
- tarinfo.uname = owner
908
- return tarinfo
909
-
910
- if not dry_run:
911
- tar = tarfile.open(archive_name, 'w|%s' % tar_compression)
912
- try:
913
- tar.add(base_dir, filter=_set_uid_gid)
914
- finally:
915
- tar.close()
916
-
917
- return archive_name
918
-
919
- def _make_zipfile(base_name, base_dir, verbose=0, dry_run=0, logger=None):
920
- """Create a zip file from all the files under 'base_dir'.
921
-
922
- The output zip file will be named 'base_name' + ".zip". Returns the
923
- name of the output zip file.
924
- """
925
- import zipfile # late import for breaking circular dependency
926
-
927
- zip_filename = base_name + ".zip"
928
- archive_dir = os.path.dirname(base_name)
929
-
930
- if archive_dir and not os.path.exists(archive_dir):
931
- if logger is not None:
932
- logger.info("creating %s", archive_dir)
933
- if not dry_run:
934
- os.makedirs(archive_dir)
935
-
936
- if logger is not None:
937
- logger.info("creating '%s' and adding '%s' to it",
938
- zip_filename, base_dir)
939
-
940
- if not dry_run:
941
- with zipfile.ZipFile(zip_filename, "w",
942
- compression=zipfile.ZIP_DEFLATED) as zf:
943
- path = os.path.normpath(base_dir)
944
- if path != os.curdir:
945
- zf.write(path, path)
946
- if logger is not None:
947
- logger.info("adding '%s'", path)
948
- for dirpath, dirnames, filenames in os.walk(base_dir):
949
- for name in sorted(dirnames):
950
- path = os.path.normpath(os.path.join(dirpath, name))
951
- zf.write(path, path)
952
- if logger is not None:
953
- logger.info("adding '%s'", path)
954
- for name in filenames:
955
- path = os.path.normpath(os.path.join(dirpath, name))
956
- if os.path.isfile(path):
957
- zf.write(path, path)
958
- if logger is not None:
959
- logger.info("adding '%s'", path)
960
-
961
- return zip_filename
962
-
963
- _ARCHIVE_FORMATS = {
964
- 'tar': (_make_tarball, [('compress', None)], "uncompressed tar file"),
965
- }
966
-
967
- if _ZLIB_SUPPORTED:
968
- _ARCHIVE_FORMATS['gztar'] = (_make_tarball, [('compress', 'gzip')],
969
- "gzip'ed tar-file")
970
- _ARCHIVE_FORMATS['zip'] = (_make_zipfile, [], "ZIP file")
971
-
972
- if _BZ2_SUPPORTED:
973
- _ARCHIVE_FORMATS['bztar'] = (_make_tarball, [('compress', 'bzip2')],
974
- "bzip2'ed tar-file")
975
-
976
- if _LZMA_SUPPORTED:
977
- _ARCHIVE_FORMATS['xztar'] = (_make_tarball, [('compress', 'xz')],
978
- "xz'ed tar-file")
979
-
980
- def get_archive_formats():
981
- """Returns a list of supported formats for archiving and unarchiving.
982
-
983
- Each element of the returned sequence is a tuple (name, description)
984
- """
985
- formats = [(name, registry[2]) for name, registry in
986
- _ARCHIVE_FORMATS.items()]
987
- formats.sort()
988
- return formats
989
-
990
- def register_archive_format(name, function, extra_args=None, description=''):
991
- """Registers an archive format.
992
-
993
- name is the name of the format. function is the callable that will be
994
- used to create archives. If provided, extra_args is a sequence of
995
- (name, value) tuples that will be passed as arguments to the callable.
996
- description can be provided to describe the format, and will be returned
997
- by the get_archive_formats() function.
998
- """
999
- if extra_args is None:
1000
- extra_args = []
1001
- if not callable(function):
1002
- raise TypeError('The %s object is not callable' % function)
1003
- if not isinstance(extra_args, (tuple, list)):
1004
- raise TypeError('extra_args needs to be a sequence')
1005
- for element in extra_args:
1006
- if not isinstance(element, (tuple, list)) or len(element) !=2:
1007
- raise TypeError('extra_args elements are : (arg_name, value)')
1008
-
1009
- _ARCHIVE_FORMATS[name] = (function, extra_args, description)
1010
-
1011
- def unregister_archive_format(name):
1012
- del _ARCHIVE_FORMATS[name]
1013
-
1014
- def make_archive(base_name, format, root_dir=None, base_dir=None, verbose=0,
1015
- dry_run=0, owner=None, group=None, logger=None):
1016
- """Create an archive file (eg. zip or tar).
1017
-
1018
- 'base_name' is the name of the file to create, minus any format-specific
1019
- extension; 'format' is the archive format: one of "zip", "tar", "gztar",
1020
- "bztar", or "xztar". Or any other registered format.
1021
-
1022
- 'root_dir' is a directory that will be the root directory of the
1023
- archive; ie. we typically chdir into 'root_dir' before creating the
1024
- archive. 'base_dir' is the directory where we start archiving from;
1025
- ie. 'base_dir' will be the common prefix of all files and
1026
- directories in the archive. 'root_dir' and 'base_dir' both default
1027
- to the current directory. Returns the name of the archive file.
1028
-
1029
- 'owner' and 'group' are used when creating a tar archive. By default,
1030
- uses the current owner and group.
1031
- """
1032
- sys.audit("shutil.make_archive", base_name, format, root_dir, base_dir)
1033
- save_cwd = os.getcwd()
1034
- if root_dir is not None:
1035
- if logger is not None:
1036
- logger.debug("changing into '%s'", root_dir)
1037
- base_name = os.path.abspath(base_name)
1038
- if not dry_run:
1039
- os.chdir(root_dir)
1040
-
1041
- if base_dir is None:
1042
- base_dir = os.curdir
1043
-
1044
- kwargs = {'dry_run': dry_run, 'logger': logger}
1045
-
1046
- try:
1047
- format_info = _ARCHIVE_FORMATS[format]
1048
- except KeyError:
1049
- raise ValueError("unknown archive format '%s'" % format) from None
1050
-
1051
- func = format_info[0]
1052
- for arg, val in format_info[1]:
1053
- kwargs[arg] = val
1054
-
1055
- if format != 'zip':
1056
- kwargs['owner'] = owner
1057
- kwargs['group'] = group
1058
-
1059
- try:
1060
- filename = func(base_name, base_dir, **kwargs)
1061
- finally:
1062
- if root_dir is not None:
1063
- if logger is not None:
1064
- logger.debug("changing back to '%s'", save_cwd)
1065
- os.chdir(save_cwd)
1066
-
1067
- return filename
1068
-
1069
-
1070
- def get_unpack_formats():
1071
- """Returns a list of supported formats for unpacking.
1072
-
1073
- Each element of the returned sequence is a tuple
1074
- (name, extensions, description)
1075
- """
1076
- formats = [(name, info[0], info[3]) for name, info in
1077
- _UNPACK_FORMATS.items()]
1078
- formats.sort()
1079
- return formats
1080
-
1081
- def _check_unpack_options(extensions, function, extra_args):
1082
- """Checks what gets registered as an unpacker."""
1083
- # first make sure no other unpacker is registered for this extension
1084
- existing_extensions = {}
1085
- for name, info in _UNPACK_FORMATS.items():
1086
- for ext in info[0]:
1087
- existing_extensions[ext] = name
1088
-
1089
- for extension in extensions:
1090
- if extension in existing_extensions:
1091
- msg = '%s is already registered for "%s"'
1092
- raise RegistryError(msg % (extension,
1093
- existing_extensions[extension]))
1094
-
1095
- if not callable(function):
1096
- raise TypeError('The registered function must be a callable')
1097
-
1098
-
1099
- def register_unpack_format(name, extensions, function, extra_args=None,
1100
- description=''):
1101
- """Registers an unpack format.
1102
-
1103
- `name` is the name of the format. `extensions` is a list of extensions
1104
- corresponding to the format.
1105
-
1106
- `function` is the callable that will be
1107
- used to unpack archives. The callable will receive archives to unpack.
1108
- If it's unable to handle an archive, it needs to raise a ReadError
1109
- exception.
1110
-
1111
- If provided, `extra_args` is a sequence of
1112
- (name, value) tuples that will be passed as arguments to the callable.
1113
- description can be provided to describe the format, and will be returned
1114
- by the get_unpack_formats() function.
1115
- """
1116
- if extra_args is None:
1117
- extra_args = []
1118
- _check_unpack_options(extensions, function, extra_args)
1119
- _UNPACK_FORMATS[name] = extensions, function, extra_args, description
1120
-
1121
- def unregister_unpack_format(name):
1122
- """Removes the pack format from the registry."""
1123
- del _UNPACK_FORMATS[name]
1124
-
1125
- def _ensure_directory(path):
1126
- """Ensure that the parent directory of `path` exists"""
1127
- dirname = os.path.dirname(path)
1128
- if not os.path.isdir(dirname):
1129
- os.makedirs(dirname)
1130
-
1131
- def _unpack_zipfile(filename, extract_dir):
1132
- """Unpack zip `filename` to `extract_dir`
1133
- """
1134
- import zipfile # late import for breaking circular dependency
1135
-
1136
- if not zipfile.is_zipfile(filename):
1137
- raise ReadError("%s is not a zip file" % filename)
1138
-
1139
- zip = zipfile.ZipFile(filename)
1140
- try:
1141
- for info in zip.infolist():
1142
- name = info.filename
1143
-
1144
- # don't extract absolute paths or ones with .. in them
1145
- if name.startswith('/') or '..' in name:
1146
- continue
1147
-
1148
- target = os.path.join(extract_dir, *name.split('/'))
1149
- if not target:
1150
- continue
1151
-
1152
- _ensure_directory(target)
1153
- if not name.endswith('/'):
1154
- # file
1155
- data = zip.read(info.filename)
1156
- f = open(target, 'wb')
1157
- try:
1158
- f.write(data)
1159
- finally:
1160
- f.close()
1161
- del data
1162
- finally:
1163
- zip.close()
1164
-
1165
- def _unpack_tarfile(filename, extract_dir):
1166
- """Unpack tar/tar.gz/tar.bz2/tar.xz `filename` to `extract_dir`
1167
- """
1168
- import tarfile # late import for breaking circular dependency
1169
- try:
1170
- tarobj = tarfile.open(filename)
1171
- except tarfile.TarError:
1172
- raise ReadError(
1173
- "%s is not a compressed or uncompressed tar file" % filename)
1174
- try:
1175
- tarobj.extractall(extract_dir)
1176
- finally:
1177
- tarobj.close()
1178
-
1179
- _UNPACK_FORMATS = {
1180
- 'tar': (['.tar'], _unpack_tarfile, [], "uncompressed tar file"),
1181
- 'zip': (['.zip'], _unpack_zipfile, [], "ZIP file"),
1182
- }
1183
-
1184
- if _ZLIB_SUPPORTED:
1185
- _UNPACK_FORMATS['gztar'] = (['.tar.gz', '.tgz'], _unpack_tarfile, [],
1186
- "gzip'ed tar-file")
1187
-
1188
- if _BZ2_SUPPORTED:
1189
- _UNPACK_FORMATS['bztar'] = (['.tar.bz2', '.tbz2'], _unpack_tarfile, [],
1190
- "bzip2'ed tar-file")
1191
-
1192
- if _LZMA_SUPPORTED:
1193
- _UNPACK_FORMATS['xztar'] = (['.tar.xz', '.txz'], _unpack_tarfile, [],
1194
- "xz'ed tar-file")
1195
-
1196
- def _find_unpack_format(filename):
1197
- for name, info in _UNPACK_FORMATS.items():
1198
- for extension in info[0]:
1199
- if filename.endswith(extension):
1200
- return name
1201
- return None
1202
-
1203
- def unpack_archive(filename, extract_dir=None, format=None):
1204
- """Unpack an archive.
1205
-
1206
- `filename` is the name of the archive.
1207
-
1208
- `extract_dir` is the name of the target directory, where the archive
1209
- is unpacked. If not provided, the current working directory is used.
1210
-
1211
- `format` is the archive format: one of "zip", "tar", "gztar", "bztar",
1212
- or "xztar". Or any other registered format. If not provided,
1213
- unpack_archive will use the filename extension and see if an unpacker
1214
- was registered for that extension.
1215
-
1216
- In case none is found, a ValueError is raised.
1217
- """
1218
- sys.audit("shutil.unpack_archive", filename, extract_dir, format)
1219
-
1220
- if extract_dir is None:
1221
- extract_dir = os.getcwd()
1222
-
1223
- extract_dir = os.fspath(extract_dir)
1224
- filename = os.fspath(filename)
1225
-
1226
- if format is not None:
1227
- try:
1228
- format_info = _UNPACK_FORMATS[format]
1229
- except KeyError:
1230
- raise ValueError("Unknown unpack format '{0}'".format(format)) from None
1231
-
1232
- func = format_info[1]
1233
- func(filename, extract_dir, **dict(format_info[2]))
1234
- else:
1235
- # we need to look at the registered unpackers supported extensions
1236
- format = _find_unpack_format(filename)
1237
- if format is None:
1238
- raise ReadError("Unknown archive format '{0}'".format(filename))
1239
-
1240
- func = _UNPACK_FORMATS[format][1]
1241
- kwargs = dict(_UNPACK_FORMATS[format][2])
1242
- func(filename, extract_dir, **kwargs)
1243
-
1244
-
1245
- if hasattr(os, 'statvfs'):
1246
-
1247
- __all__.append('disk_usage')
1248
- _ntuple_diskusage = collections.namedtuple('usage', 'total used free')
1249
- _ntuple_diskusage.total.__doc__ = 'Total space in bytes'
1250
- _ntuple_diskusage.used.__doc__ = 'Used space in bytes'
1251
- _ntuple_diskusage.free.__doc__ = 'Free space in bytes'
1252
-
1253
- def disk_usage(path):
1254
- """Return disk usage statistics about the given path.
1255
-
1256
- Returned value is a named tuple with attributes 'total', 'used' and
1257
- 'free', which are the amount of total, used and free space, in bytes.
1258
- """
1259
- st = os.statvfs(path)
1260
- free = st.f_bavail * st.f_frsize
1261
- total = st.f_blocks * st.f_frsize
1262
- used = (st.f_blocks - st.f_bfree) * st.f_frsize
1263
- return _ntuple_diskusage(total, used, free)
1264
-
1265
- elif _WINDOWS:
1266
-
1267
- __all__.append('disk_usage')
1268
- _ntuple_diskusage = collections.namedtuple('usage', 'total used free')
1269
-
1270
- def disk_usage(path):
1271
- """Return disk usage statistics about the given path.
1272
-
1273
- Returned values is a named tuple with attributes 'total', 'used' and
1274
- 'free', which are the amount of total, used and free space, in bytes.
1275
- """
1276
- total, free = nt._getdiskusage(path)
1277
- used = total - free
1278
- return _ntuple_diskusage(total, used, free)
1279
-
1280
-
1281
- def chown(path, user=None, group=None):
1282
- """Change owner user and group of the given path.
1283
-
1284
- user and group can be the uid/gid or the user/group names, and in that case,
1285
- they are converted to their respective uid/gid.
1286
- """
1287
- sys.audit('shutil.chown', path, user, group)
1288
-
1289
- if user is None and group is None:
1290
- raise ValueError("user and/or group must be set")
1291
-
1292
- _user = user
1293
- _group = group
1294
-
1295
- # -1 means don't change it
1296
- if user is None:
1297
- _user = -1
1298
- # user can either be an int (the uid) or a string (the system username)
1299
- elif isinstance(user, str):
1300
- _user = _get_uid(user)
1301
- if _user is None:
1302
- raise LookupError("no such user: {!r}".format(user))
1303
-
1304
- if group is None:
1305
- _group = -1
1306
- elif not isinstance(group, int):
1307
- _group = _get_gid(group)
1308
- if _group is None:
1309
- raise LookupError("no such group: {!r}".format(group))
1310
-
1311
- os.chown(path, _user, _group)
1312
-
1313
- def get_terminal_size(fallback=(80, 24)):
1314
- """Get the size of the terminal window.
1315
-
1316
- For each of the two dimensions, the environment variable, COLUMNS
1317
- and LINES respectively, is checked. If the variable is defined and
1318
- the value is a positive integer, it is used.
1319
-
1320
- When COLUMNS or LINES is not defined, which is the common case,
1321
- the terminal connected to sys.__stdout__ is queried
1322
- by invoking os.get_terminal_size.
1323
-
1324
- If the terminal size cannot be successfully queried, either because
1325
- the system doesn't support querying, or because we are not
1326
- connected to a terminal, the value given in fallback parameter
1327
- is used. Fallback defaults to (80, 24) which is the default
1328
- size used by many terminal emulators.
1329
-
1330
- The value returned is a named tuple of type os.terminal_size.
1331
- """
1332
- # columns, lines are the working values
1333
- try:
1334
- columns = int(os.environ['COLUMNS'])
1335
- except (KeyError, ValueError):
1336
- columns = 0
1337
-
1338
- try:
1339
- lines = int(os.environ['LINES'])
1340
- except (KeyError, ValueError):
1341
- lines = 0
1342
-
1343
- # only query if necessary
1344
- if columns <= 0 or lines <= 0:
1345
- try:
1346
- size = os.get_terminal_size(sys.__stdout__.fileno())
1347
- except (AttributeError, ValueError, OSError):
1348
- # stdout is None, closed, detached, or not a terminal, or
1349
- # os.get_terminal_size() is unsupported
1350
- size = os.terminal_size(fallback)
1351
- if columns <= 0:
1352
- columns = size.columns
1353
- if lines <= 0:
1354
- lines = size.lines
1355
-
1356
- return os.terminal_size((columns, lines))
1357
-
1358
-
1359
- # Check that a given file can be accessed with the correct mode.
1360
- # Additionally check that `file` is not a directory, as on Windows
1361
- # directories pass the os.access check.
1362
- def _access_check(fn, mode):
1363
- return (os.path.exists(fn) and os.access(fn, mode)
1364
- and not os.path.isdir(fn))
1365
-
1366
-
1367
- def which(cmd, mode=os.F_OK | os.X_OK, path=None):
1368
- """Given a command, mode, and a PATH string, return the path which
1369
- conforms to the given mode on the PATH, or None if there is no such
1370
- file.
1371
-
1372
- `mode` defaults to os.F_OK | os.X_OK. `path` defaults to the result
1373
- of os.environ.get("PATH"), or can be overridden with a custom search
1374
- path.
1375
-
1376
- """
1377
- # If we're given a path with a directory part, look it up directly rather
1378
- # than referring to PATH directories. This includes checking relative to the
1379
- # current directory, e.g. ./script
1380
- if os.path.dirname(cmd):
1381
- if _access_check(cmd, mode):
1382
- return cmd
1383
- return None
1384
-
1385
- use_bytes = isinstance(cmd, bytes)
1386
-
1387
- if path is None:
1388
- path = os.environ.get("PATH", None)
1389
- if path is None:
1390
- try:
1391
- path = os.confstr("CS_PATH")
1392
- except (AttributeError, ValueError):
1393
- # os.confstr() or CS_PATH is not available
1394
- path = os.defpath
1395
- # bpo-35755: Don't use os.defpath if the PATH environment variable is
1396
- # set to an empty string
1397
-
1398
- # PATH='' doesn't match, whereas PATH=':' looks in the current directory
1399
- if not path:
1400
- return None
1401
-
1402
- if use_bytes:
1403
- path = os.fsencode(path)
1404
- path = path.split(os.fsencode(os.pathsep))
1405
- else:
1406
- path = os.fsdecode(path)
1407
- path = path.split(os.pathsep)
1408
-
1409
- if sys.platform == "win32":
1410
- # The current directory takes precedence on Windows.
1411
- curdir = os.curdir
1412
- if use_bytes:
1413
- curdir = os.fsencode(curdir)
1414
- if curdir not in path:
1415
- path.insert(0, curdir)
1416
-
1417
- # PATHEXT is necessary to check on Windows.
1418
- pathext = os.environ.get("PATHEXT", "").split(os.pathsep)
1419
- if use_bytes:
1420
- pathext = [os.fsencode(ext) for ext in pathext]
1421
- # See if the given file matches any of the expected path extensions.
1422
- # This will allow us to short circuit when given "python.exe".
1423
- # If it does match, only test that one, otherwise we have to try
1424
- # others.
1425
- if any(cmd.lower().endswith(ext.lower()) for ext in pathext):
1426
- files = [cmd]
1427
- else:
1428
- files = [cmd + ext for ext in pathext]
1429
- else:
1430
- # On other platforms you don't have things like PATHEXT to tell you
1431
- # what file suffixes are executable, so just pass on cmd as-is.
1432
- files = [cmd]
1433
-
1434
- seen = set()
1435
- for dir in path:
1436
- normdir = os.path.normcase(dir)
1437
- if not normdir in seen:
1438
- seen.add(normdir)
1439
- for thefile in files:
1440
- name = os.path.join(dir, thefile)
1441
- if _access_check(name, mode):
1442
- return name
1443
- return None