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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (980) hide show
  1. package/LICENSE +28 -0
  2. package/README.md +21 -2
  3. package/adapter/codelldb +0 -0
  4. package/adapter/scripts/codelldb/__init__.py +7 -0
  5. package/adapter/scripts/codelldb/api.py +125 -0
  6. package/adapter/scripts/codelldb/commands/__init__.py +7 -0
  7. package/adapter/scripts/codelldb/commands/debug_info.py +63 -0
  8. package/adapter/scripts/codelldb/commands/nofail.py +8 -0
  9. package/adapter/scripts/codelldb/event.py +19 -0
  10. package/adapter/scripts/codelldb/interface.py +423 -0
  11. package/adapter/scripts/codelldb/value.py +364 -0
  12. package/adapter/scripts/codelldb/webview.py +57 -0
  13. package/adapter/scripts/console.py +23 -0
  14. package/adapter/scripts/debugger.py +1 -0
  15. package/lang_support/__init__.py +23 -0
  16. package/lang_support/rust.py +87 -0
  17. package/lldb/bin/lldb +0 -0
  18. package/lldb/bin/lldb-argdumper +0 -0
  19. package/lldb/bin/lldb-server +0 -0
  20. package/lldb/lib/liblldb.so +4 -0
  21. package/lldb/lib/libpython312.so +0 -0
  22. package/lldb/lib/lldb-python/lldb/__init__.py +19655 -0
  23. package/lldb/lib/lldb-python/lldb/embedded_interpreter.py +97 -0
  24. package/lldb/lib/lldb-python/lldb/formatters/Logger.py +133 -0
  25. package/lldb/lib/lldb-python/lldb/formatters/__init__.py +11 -0
  26. package/lldb/lib/lldb-python/lldb/formatters/attrib_fromdict.py +41 -0
  27. package/lldb/lib/lldb-python/lldb/formatters/cache.py +35 -0
  28. package/lldb/lib/lldb-python/lldb/formatters/cpp/__init__.py +11 -0
  29. package/lldb/lib/lldb-python/lldb/formatters/cpp/gnu_libstdcpp.py +939 -0
  30. package/lldb/lib/lldb-python/lldb/formatters/cpp/libcxx.py +987 -0
  31. package/lldb/lib/lldb-python/lldb/formatters/metrics.py +119 -0
  32. package/lldb/lib/lldb-python/lldb/formatters/synth.py +59 -0
  33. package/lldb/lib/lldb-python/lldb/lldb-argdumper +0 -0
  34. package/lldb/lib/lldb-python/lldb/native/__init__.py +11 -0
  35. package/lldb/lib/lldb-python/lldb/plugins/__init__.py +11 -0
  36. package/lldb/lib/lldb-python/lldb/plugins/operating_system.py +103 -0
  37. package/lldb/lib/lldb-python/lldb/plugins/parsed_cmd.py +463 -0
  38. package/lldb/lib/lldb-python/lldb/plugins/scripted_frame_provider.py +188 -0
  39. package/lldb/lib/lldb-python/lldb/plugins/scripted_platform.py +96 -0
  40. package/lldb/lib/lldb-python/lldb/plugins/scripted_process.py +1475 -0
  41. package/lldb/lib/lldb-python/lldb/plugins/scripted_thread_plan.py +70 -0
  42. package/lldb/lib/lldb-python/lldb/utils/__init__.py +11 -0
  43. package/lldb/lib/lldb-python/lldb/utils/in_call_stack.py +24 -0
  44. package/lldb/lib/lldb-python/lldb/utils/symbolication.py +810 -0
  45. package/lldb/lib/python3.12/__future__.py +147 -0
  46. package/lldb/lib/python3.12/__hello__.py +16 -0
  47. package/lldb/lib/python3.12/__phello__/__init__.py +7 -0
  48. package/lldb/lib/python3.12/__phello__/spam.py +7 -0
  49. package/lldb/lib/python3.12/_aix_support.py +108 -0
  50. package/lldb/lib/python3.12/_collections_abc.py +1173 -0
  51. package/lldb/lib/python3.12/_compat_pickle.py +252 -0
  52. package/lldb/lib/python3.12/_compression.py +162 -0
  53. package/lldb/lib/python3.12/_markupbase.py +396 -0
  54. package/lldb/lib/python3.12/_osx_support.py +579 -0
  55. package/lldb/lib/python3.12/_py_abc.py +147 -0
  56. package/lldb/lib/python3.12/_pydatetime.py +2645 -0
  57. package/lldb/lib/python3.12/_pydecimal.py +6339 -0
  58. package/lldb/lib/python3.12/_pyio.py +2698 -0
  59. package/lldb/lib/python3.12/_pylong.py +329 -0
  60. package/lldb/lib/python3.12/_sitebuiltins.py +103 -0
  61. package/lldb/lib/python3.12/_strptime.py +565 -0
  62. package/lldb/lib/python3.12/_sysconfigdata__linux_aarch64-linux-gnu.py +1230 -0
  63. package/lldb/lib/python3.12/_threading_local.py +242 -0
  64. package/lldb/lib/python3.12/_weakrefset.py +205 -0
  65. package/lldb/lib/python3.12/abc.py +188 -0
  66. package/lldb/lib/python3.12/aifc.py +984 -0
  67. package/lldb/lib/python3.12/antigravity.py +17 -0
  68. package/lldb/lib/python3.12/argparse.py +2672 -0
  69. package/lldb/lib/python3.12/ast.py +1835 -0
  70. package/lldb/lib/python3.12/asyncio/__init__.py +47 -0
  71. package/lldb/lib/python3.12/asyncio/__main__.py +126 -0
  72. package/lldb/lib/python3.12/asyncio/base_events.py +2011 -0
  73. package/lldb/lib/python3.12/asyncio/base_futures.py +67 -0
  74. package/lldb/lib/python3.12/asyncio/base_subprocess.py +285 -0
  75. package/lldb/lib/python3.12/asyncio/base_tasks.py +94 -0
  76. package/lldb/lib/python3.12/asyncio/constants.py +41 -0
  77. package/lldb/lib/python3.12/asyncio/coroutines.py +109 -0
  78. package/lldb/lib/python3.12/asyncio/events.py +868 -0
  79. package/lldb/lib/python3.12/asyncio/exceptions.py +62 -0
  80. package/lldb/lib/python3.12/asyncio/format_helpers.py +76 -0
  81. package/lldb/lib/python3.12/asyncio/futures.py +432 -0
  82. package/lldb/lib/python3.12/asyncio/locks.py +586 -0
  83. package/lldb/lib/python3.12/asyncio/log.py +7 -0
  84. package/lldb/lib/python3.12/asyncio/mixins.py +21 -0
  85. package/lldb/lib/python3.12/asyncio/proactor_events.py +897 -0
  86. package/lldb/lib/python3.12/asyncio/protocols.py +216 -0
  87. package/lldb/lib/python3.12/asyncio/queues.py +244 -0
  88. package/lldb/lib/python3.12/asyncio/runners.py +215 -0
  89. package/lldb/lib/python3.12/asyncio/selector_events.py +1321 -0
  90. package/lldb/lib/python3.12/asyncio/sslproto.py +926 -0
  91. package/lldb/lib/python3.12/asyncio/staggered.py +138 -0
  92. package/lldb/lib/python3.12/asyncio/streams.py +770 -0
  93. package/lldb/lib/python3.12/asyncio/subprocess.py +229 -0
  94. package/lldb/lib/python3.12/asyncio/taskgroups.py +240 -0
  95. package/lldb/lib/python3.12/asyncio/tasks.py +1065 -0
  96. package/lldb/lib/python3.12/asyncio/threads.py +25 -0
  97. package/lldb/lib/python3.12/asyncio/timeouts.py +168 -0
  98. package/lldb/lib/python3.12/asyncio/transports.py +335 -0
  99. package/lldb/lib/python3.12/asyncio/trsock.py +98 -0
  100. package/lldb/lib/python3.12/asyncio/unix_events.py +1500 -0
  101. package/lldb/lib/python3.12/asyncio/windows_events.py +901 -0
  102. package/lldb/lib/python3.12/asyncio/windows_utils.py +173 -0
  103. package/lldb/lib/python3.12/base64.py +586 -0
  104. package/lldb/lib/python3.12/bdb.py +899 -0
  105. package/lldb/lib/python3.12/bisect.py +118 -0
  106. package/lldb/lib/python3.12/bz2.py +344 -0
  107. package/lldb/lib/python3.12/cProfile.py +195 -0
  108. package/lldb/lib/python3.12/calendar.py +798 -0
  109. package/lldb/lib/python3.12/cgi.py +1013 -0
  110. package/lldb/lib/python3.12/cgitb.py +332 -0
  111. package/lldb/lib/python3.12/chunk.py +173 -0
  112. package/lldb/lib/python3.12/cmd.py +401 -0
  113. package/lldb/lib/python3.12/code.py +324 -0
  114. package/lldb/lib/python3.12/codecs.py +1129 -0
  115. package/lldb/lib/python3.12/codeop.py +161 -0
  116. package/lldb/lib/python3.12/collections/__init__.py +1592 -0
  117. package/lldb/lib/python3.12/collections/abc.py +3 -0
  118. package/lldb/lib/python3.12/colorsys.py +166 -0
  119. package/lldb/lib/python3.12/compileall.py +469 -0
  120. package/lldb/lib/python3.12/concurrent/__init__.py +1 -0
  121. package/lldb/lib/python3.12/concurrent/futures/__init__.py +54 -0
  122. package/lldb/lib/python3.12/concurrent/futures/_base.py +654 -0
  123. package/lldb/lib/python3.12/concurrent/futures/process.py +884 -0
  124. package/lldb/lib/python3.12/concurrent/futures/thread.py +239 -0
  125. package/lldb/lib/python3.12/configparser.py +1333 -0
  126. package/lldb/lib/python3.12/contextlib.py +800 -0
  127. package/lldb/lib/python3.12/contextvars.py +4 -0
  128. package/lldb/lib/python3.12/copy.py +292 -0
  129. package/lldb/lib/python3.12/copyreg.py +217 -0
  130. package/lldb/lib/python3.12/crypt.py +124 -0
  131. package/lldb/lib/python3.12/csv.py +451 -0
  132. package/lldb/lib/python3.12/ctypes/__init__.py +582 -0
  133. package/lldb/lib/python3.12/ctypes/_aix.py +327 -0
  134. package/lldb/lib/python3.12/ctypes/_endian.py +78 -0
  135. package/lldb/lib/python3.12/ctypes/macholib/__init__.py +9 -0
  136. package/lldb/lib/python3.12/ctypes/macholib/dyld.py +165 -0
  137. package/lldb/lib/python3.12/ctypes/macholib/dylib.py +42 -0
  138. package/lldb/lib/python3.12/ctypes/macholib/framework.py +42 -0
  139. package/lldb/lib/python3.12/ctypes/util.py +379 -0
  140. package/lldb/lib/python3.12/ctypes/wintypes.py +202 -0
  141. package/lldb/lib/python3.12/dataclasses.py +1588 -0
  142. package/lldb/lib/python3.12/datetime.py +9 -0
  143. package/lldb/lib/python3.12/dbm/__init__.py +190 -0
  144. package/lldb/lib/python3.12/dbm/dumb.py +317 -0
  145. package/lldb/lib/python3.12/dbm/gnu.py +3 -0
  146. package/lldb/lib/python3.12/dbm/ndbm.py +3 -0
  147. package/lldb/lib/python3.12/decimal.py +108 -0
  148. package/lldb/lib/python3.12/difflib.py +2056 -0
  149. package/lldb/lib/python3.12/dis.py +805 -0
  150. package/lldb/lib/python3.12/doctest.py +2845 -0
  151. package/lldb/lib/python3.12/email/__init__.py +61 -0
  152. package/lldb/lib/python3.12/email/_encoded_words.py +233 -0
  153. package/lldb/lib/python3.12/email/_header_value_parser.py +3078 -0
  154. package/lldb/lib/python3.12/email/_parseaddr.py +557 -0
  155. package/lldb/lib/python3.12/email/_policybase.py +382 -0
  156. package/lldb/lib/python3.12/email/base64mime.py +115 -0
  157. package/lldb/lib/python3.12/email/charset.py +398 -0
  158. package/lldb/lib/python3.12/email/contentmanager.py +251 -0
  159. package/lldb/lib/python3.12/email/encoders.py +65 -0
  160. package/lldb/lib/python3.12/email/errors.py +117 -0
  161. package/lldb/lib/python3.12/email/feedparser.py +534 -0
  162. package/lldb/lib/python3.12/email/generator.py +520 -0
  163. package/lldb/lib/python3.12/email/header.py +573 -0
  164. package/lldb/lib/python3.12/email/headerregistry.py +604 -0
  165. package/lldb/lib/python3.12/email/iterators.py +68 -0
  166. package/lldb/lib/python3.12/email/message.py +1205 -0
  167. package/lldb/lib/python3.12/email/mime/__init__.py +0 -0
  168. package/lldb/lib/python3.12/email/mime/application.py +37 -0
  169. package/lldb/lib/python3.12/email/mime/audio.py +100 -0
  170. package/lldb/lib/python3.12/email/mime/base.py +29 -0
  171. package/lldb/lib/python3.12/email/mime/image.py +152 -0
  172. package/lldb/lib/python3.12/email/mime/message.py +33 -0
  173. package/lldb/lib/python3.12/email/mime/multipart.py +47 -0
  174. package/lldb/lib/python3.12/email/mime/nonmultipart.py +21 -0
  175. package/lldb/lib/python3.12/email/mime/text.py +40 -0
  176. package/lldb/lib/python3.12/email/parser.py +127 -0
  177. package/lldb/lib/python3.12/email/policy.py +232 -0
  178. package/lldb/lib/python3.12/email/quoprimime.py +300 -0
  179. package/lldb/lib/python3.12/email/utils.py +486 -0
  180. package/lldb/lib/python3.12/encodings/__init__.py +174 -0
  181. package/lldb/lib/python3.12/encodings/aliases.py +551 -0
  182. package/lldb/lib/python3.12/encodings/ascii.py +50 -0
  183. package/lldb/lib/python3.12/encodings/base64_codec.py +55 -0
  184. package/lldb/lib/python3.12/encodings/big5.py +39 -0
  185. package/lldb/lib/python3.12/encodings/big5hkscs.py +39 -0
  186. package/lldb/lib/python3.12/encodings/bz2_codec.py +78 -0
  187. package/lldb/lib/python3.12/encodings/charmap.py +69 -0
  188. package/lldb/lib/python3.12/encodings/cp037.py +307 -0
  189. package/lldb/lib/python3.12/encodings/cp1006.py +307 -0
  190. package/lldb/lib/python3.12/encodings/cp1026.py +307 -0
  191. package/lldb/lib/python3.12/encodings/cp1125.py +698 -0
  192. package/lldb/lib/python3.12/encodings/cp1140.py +307 -0
  193. package/lldb/lib/python3.12/encodings/cp1250.py +307 -0
  194. package/lldb/lib/python3.12/encodings/cp1251.py +307 -0
  195. package/lldb/lib/python3.12/encodings/cp1252.py +307 -0
  196. package/lldb/lib/python3.12/encodings/cp1253.py +307 -0
  197. package/lldb/lib/python3.12/encodings/cp1254.py +307 -0
  198. package/lldb/lib/python3.12/encodings/cp1255.py +307 -0
  199. package/lldb/lib/python3.12/encodings/cp1256.py +307 -0
  200. package/lldb/lib/python3.12/encodings/cp1257.py +307 -0
  201. package/lldb/lib/python3.12/encodings/cp1258.py +307 -0
  202. package/lldb/lib/python3.12/encodings/cp273.py +307 -0
  203. package/lldb/lib/python3.12/encodings/cp424.py +307 -0
  204. package/lldb/lib/python3.12/encodings/cp437.py +698 -0
  205. package/lldb/lib/python3.12/encodings/cp500.py +307 -0
  206. package/lldb/lib/python3.12/encodings/cp720.py +309 -0
  207. package/lldb/lib/python3.12/encodings/cp737.py +698 -0
  208. package/lldb/lib/python3.12/encodings/cp775.py +697 -0
  209. package/lldb/lib/python3.12/encodings/cp850.py +698 -0
  210. package/lldb/lib/python3.12/encodings/cp852.py +698 -0
  211. package/lldb/lib/python3.12/encodings/cp855.py +698 -0
  212. package/lldb/lib/python3.12/encodings/cp856.py +307 -0
  213. package/lldb/lib/python3.12/encodings/cp857.py +694 -0
  214. package/lldb/lib/python3.12/encodings/cp858.py +698 -0
  215. package/lldb/lib/python3.12/encodings/cp860.py +698 -0
  216. package/lldb/lib/python3.12/encodings/cp861.py +698 -0
  217. package/lldb/lib/python3.12/encodings/cp862.py +698 -0
  218. package/lldb/lib/python3.12/encodings/cp863.py +698 -0
  219. package/lldb/lib/python3.12/encodings/cp864.py +690 -0
  220. package/lldb/lib/python3.12/encodings/cp865.py +698 -0
  221. package/lldb/lib/python3.12/encodings/cp866.py +698 -0
  222. package/lldb/lib/python3.12/encodings/cp869.py +689 -0
  223. package/lldb/lib/python3.12/encodings/cp874.py +307 -0
  224. package/lldb/lib/python3.12/encodings/cp875.py +307 -0
  225. package/lldb/lib/python3.12/encodings/cp932.py +39 -0
  226. package/lldb/lib/python3.12/encodings/cp949.py +39 -0
  227. package/lldb/lib/python3.12/encodings/cp950.py +39 -0
  228. package/lldb/lib/python3.12/encodings/euc_jis_2004.py +39 -0
  229. package/lldb/lib/python3.12/encodings/euc_jisx0213.py +39 -0
  230. package/lldb/lib/python3.12/encodings/euc_jp.py +39 -0
  231. package/lldb/lib/python3.12/encodings/euc_kr.py +39 -0
  232. package/lldb/lib/python3.12/encodings/gb18030.py +39 -0
  233. package/lldb/lib/python3.12/encodings/gb2312.py +39 -0
  234. package/lldb/lib/python3.12/encodings/gbk.py +39 -0
  235. package/lldb/lib/python3.12/encodings/hex_codec.py +55 -0
  236. package/lldb/lib/python3.12/encodings/hp_roman8.py +314 -0
  237. package/lldb/lib/python3.12/encodings/hz.py +39 -0
  238. package/lldb/lib/python3.12/encodings/idna.py +317 -0
  239. package/lldb/lib/python3.12/encodings/iso2022_jp.py +39 -0
  240. package/lldb/lib/python3.12/encodings/iso2022_jp_1.py +39 -0
  241. package/lldb/lib/python3.12/encodings/iso2022_jp_2.py +39 -0
  242. package/lldb/lib/python3.12/encodings/iso2022_jp_2004.py +39 -0
  243. package/lldb/lib/python3.12/encodings/iso2022_jp_3.py +39 -0
  244. package/lldb/lib/python3.12/encodings/iso2022_jp_ext.py +39 -0
  245. package/lldb/lib/python3.12/encodings/iso2022_kr.py +39 -0
  246. package/lldb/lib/python3.12/encodings/iso8859_1.py +307 -0
  247. package/lldb/lib/python3.12/encodings/iso8859_10.py +307 -0
  248. package/lldb/lib/python3.12/encodings/iso8859_11.py +307 -0
  249. package/lldb/lib/python3.12/encodings/iso8859_13.py +307 -0
  250. package/lldb/lib/python3.12/encodings/iso8859_14.py +307 -0
  251. package/lldb/lib/python3.12/encodings/iso8859_15.py +307 -0
  252. package/lldb/lib/python3.12/encodings/iso8859_16.py +307 -0
  253. package/lldb/lib/python3.12/encodings/iso8859_2.py +307 -0
  254. package/lldb/lib/python3.12/encodings/iso8859_3.py +307 -0
  255. package/lldb/lib/python3.12/encodings/iso8859_4.py +307 -0
  256. package/lldb/lib/python3.12/encodings/iso8859_5.py +307 -0
  257. package/lldb/lib/python3.12/encodings/iso8859_6.py +307 -0
  258. package/lldb/lib/python3.12/encodings/iso8859_7.py +307 -0
  259. package/lldb/lib/python3.12/encodings/iso8859_8.py +307 -0
  260. package/lldb/lib/python3.12/encodings/iso8859_9.py +307 -0
  261. package/lldb/lib/python3.12/encodings/johab.py +39 -0
  262. package/lldb/lib/python3.12/encodings/koi8_r.py +307 -0
  263. package/lldb/lib/python3.12/encodings/koi8_t.py +308 -0
  264. package/lldb/lib/python3.12/encodings/koi8_u.py +307 -0
  265. package/lldb/lib/python3.12/encodings/kz1048.py +307 -0
  266. package/lldb/lib/python3.12/encodings/latin_1.py +50 -0
  267. package/lldb/lib/python3.12/encodings/mac_arabic.py +698 -0
  268. package/lldb/lib/python3.12/encodings/mac_croatian.py +307 -0
  269. package/lldb/lib/python3.12/encodings/mac_cyrillic.py +307 -0
  270. package/lldb/lib/python3.12/encodings/mac_farsi.py +307 -0
  271. package/lldb/lib/python3.12/encodings/mac_greek.py +307 -0
  272. package/lldb/lib/python3.12/encodings/mac_iceland.py +307 -0
  273. package/lldb/lib/python3.12/encodings/mac_latin2.py +312 -0
  274. package/lldb/lib/python3.12/encodings/mac_roman.py +307 -0
  275. package/lldb/lib/python3.12/encodings/mac_romanian.py +307 -0
  276. package/lldb/lib/python3.12/encodings/mac_turkish.py +307 -0
  277. package/lldb/lib/python3.12/encodings/mbcs.py +47 -0
  278. package/lldb/lib/python3.12/encodings/oem.py +41 -0
  279. package/lldb/lib/python3.12/encodings/palmos.py +308 -0
  280. package/lldb/lib/python3.12/encodings/ptcp154.py +312 -0
  281. package/lldb/lib/python3.12/encodings/punycode.py +237 -0
  282. package/lldb/lib/python3.12/encodings/quopri_codec.py +56 -0
  283. package/lldb/lib/python3.12/encodings/raw_unicode_escape.py +46 -0
  284. package/lldb/lib/python3.12/encodings/rot_13.py +113 -0
  285. package/lldb/lib/python3.12/encodings/shift_jis.py +39 -0
  286. package/lldb/lib/python3.12/encodings/shift_jis_2004.py +39 -0
  287. package/lldb/lib/python3.12/encodings/shift_jisx0213.py +39 -0
  288. package/lldb/lib/python3.12/encodings/tis_620.py +307 -0
  289. package/lldb/lib/python3.12/encodings/undefined.py +49 -0
  290. package/lldb/lib/python3.12/encodings/unicode_escape.py +46 -0
  291. package/lldb/lib/python3.12/encodings/utf_16.py +155 -0
  292. package/lldb/lib/python3.12/encodings/utf_16_be.py +42 -0
  293. package/lldb/lib/python3.12/encodings/utf_16_le.py +42 -0
  294. package/lldb/lib/python3.12/encodings/utf_32.py +150 -0
  295. package/lldb/lib/python3.12/encodings/utf_32_be.py +37 -0
  296. package/lldb/lib/python3.12/encodings/utf_32_le.py +37 -0
  297. package/lldb/lib/python3.12/encodings/utf_7.py +38 -0
  298. package/lldb/lib/python3.12/encodings/utf_8.py +42 -0
  299. package/lldb/lib/python3.12/encodings/utf_8_sig.py +130 -0
  300. package/lldb/lib/python3.12/encodings/uu_codec.py +103 -0
  301. package/lldb/lib/python3.12/encodings/zlib_codec.py +77 -0
  302. package/lldb/lib/python3.12/ensurepip/__init__.py +291 -0
  303. package/lldb/lib/python3.12/ensurepip/__main__.py +5 -0
  304. package/lldb/lib/python3.12/ensurepip/_uninstall.py +31 -0
  305. package/lldb/lib/python3.12/enum.py +2109 -0
  306. package/lldb/lib/python3.12/filecmp.py +315 -0
  307. package/lldb/lib/python3.12/fileinput.py +442 -0
  308. package/lldb/lib/python3.12/fnmatch.py +185 -0
  309. package/lldb/lib/python3.12/fractions.py +990 -0
  310. package/lldb/lib/python3.12/ftplib.py +966 -0
  311. package/lldb/lib/python3.12/functools.py +1004 -0
  312. package/lldb/lib/python3.12/genericpath.py +167 -0
  313. package/lldb/lib/python3.12/getopt.py +215 -0
  314. package/lldb/lib/python3.12/getpass.py +185 -0
  315. package/lldb/lib/python3.12/gettext.py +646 -0
  316. package/lldb/lib/python3.12/glob.py +252 -0
  317. package/lldb/lib/python3.12/graphlib.py +250 -0
  318. package/lldb/lib/python3.12/gzip.py +694 -0
  319. package/lldb/lib/python3.12/hashlib.py +253 -0
  320. package/lldb/lib/python3.12/heapq.py +603 -0
  321. package/lldb/lib/python3.12/hmac.py +219 -0
  322. package/lldb/lib/python3.12/html/__init__.py +132 -0
  323. package/lldb/lib/python3.12/html/entities.py +2513 -0
  324. package/lldb/lib/python3.12/html/parser.py +456 -0
  325. package/lldb/lib/python3.12/http/__init__.py +200 -0
  326. package/lldb/lib/python3.12/http/client.py +1548 -0
  327. package/lldb/lib/python3.12/http/cookiejar.py +2121 -0
  328. package/lldb/lib/python3.12/http/cookies.py +594 -0
  329. package/lldb/lib/python3.12/http/server.py +1320 -0
  330. package/lldb/lib/python3.12/imaplib.py +1632 -0
  331. package/lldb/lib/python3.12/imghdr.py +180 -0
  332. package/lldb/lib/python3.12/importlib/__init__.py +138 -0
  333. package/lldb/lib/python3.12/importlib/_abc.py +39 -0
  334. package/lldb/lib/python3.12/importlib/_bootstrap.py +1551 -0
  335. package/lldb/lib/python3.12/importlib/_bootstrap_external.py +1745 -0
  336. package/lldb/lib/python3.12/importlib/abc.py +239 -0
  337. package/lldb/lib/python3.12/importlib/machinery.py +20 -0
  338. package/lldb/lib/python3.12/importlib/metadata/__init__.py +966 -0
  339. package/lldb/lib/python3.12/importlib/metadata/_adapters.py +89 -0
  340. package/lldb/lib/python3.12/importlib/metadata/_collections.py +30 -0
  341. package/lldb/lib/python3.12/importlib/metadata/_functools.py +104 -0
  342. package/lldb/lib/python3.12/importlib/metadata/_itertools.py +73 -0
  343. package/lldb/lib/python3.12/importlib/metadata/_meta.py +63 -0
  344. package/lldb/lib/python3.12/importlib/metadata/_text.py +99 -0
  345. package/lldb/lib/python3.12/importlib/readers.py +12 -0
  346. package/lldb/lib/python3.12/importlib/resources/__init__.py +36 -0
  347. package/lldb/lib/python3.12/importlib/resources/_adapters.py +168 -0
  348. package/lldb/lib/python3.12/importlib/resources/_common.py +207 -0
  349. package/lldb/lib/python3.12/importlib/resources/_itertools.py +38 -0
  350. package/lldb/lib/python3.12/importlib/resources/_legacy.py +120 -0
  351. package/lldb/lib/python3.12/importlib/resources/abc.py +173 -0
  352. package/lldb/lib/python3.12/importlib/resources/readers.py +146 -0
  353. package/lldb/lib/python3.12/importlib/resources/simple.py +106 -0
  354. package/lldb/lib/python3.12/importlib/simple.py +14 -0
  355. package/lldb/lib/python3.12/importlib/util.py +270 -0
  356. package/lldb/lib/python3.12/inspect.py +3426 -0
  357. package/lldb/lib/python3.12/io.py +99 -0
  358. package/lldb/lib/python3.12/ipaddress.py +2380 -0
  359. package/lldb/lib/python3.12/json/__init__.py +359 -0
  360. package/lldb/lib/python3.12/json/decoder.py +356 -0
  361. package/lldb/lib/python3.12/json/encoder.py +443 -0
  362. package/lldb/lib/python3.12/json/scanner.py +73 -0
  363. package/lldb/lib/python3.12/json/tool.py +85 -0
  364. package/lldb/lib/python3.12/keyword.py +64 -0
  365. package/lldb/lib/python3.12/linecache.py +182 -0
  366. package/lldb/lib/python3.12/locale.py +1779 -0
  367. package/lldb/lib/python3.12/logging/__init__.py +2345 -0
  368. package/lldb/lib/python3.12/logging/config.py +1078 -0
  369. package/lldb/lib/python3.12/logging/handlers.py +1608 -0
  370. package/lldb/lib/python3.12/lzma.py +356 -0
  371. package/lldb/lib/python3.12/mailbox.py +2153 -0
  372. package/lldb/lib/python3.12/mailcap.py +302 -0
  373. package/lldb/lib/python3.12/mimetypes.py +653 -0
  374. package/lldb/lib/python3.12/modulefinder.py +666 -0
  375. package/lldb/lib/python3.12/multiprocessing/__init__.py +37 -0
  376. package/lldb/lib/python3.12/multiprocessing/connection.py +1178 -0
  377. package/lldb/lib/python3.12/multiprocessing/context.py +377 -0
  378. package/lldb/lib/python3.12/multiprocessing/dummy/__init__.py +126 -0
  379. package/lldb/lib/python3.12/multiprocessing/dummy/connection.py +75 -0
  380. package/lldb/lib/python3.12/multiprocessing/forkserver.py +348 -0
  381. package/lldb/lib/python3.12/multiprocessing/heap.py +337 -0
  382. package/lldb/lib/python3.12/multiprocessing/managers.py +1380 -0
  383. package/lldb/lib/python3.12/multiprocessing/pool.py +957 -0
  384. package/lldb/lib/python3.12/multiprocessing/popen_fork.py +83 -0
  385. package/lldb/lib/python3.12/multiprocessing/popen_forkserver.py +74 -0
  386. package/lldb/lib/python3.12/multiprocessing/popen_spawn_posix.py +72 -0
  387. package/lldb/lib/python3.12/multiprocessing/popen_spawn_win32.py +145 -0
  388. package/lldb/lib/python3.12/multiprocessing/process.py +439 -0
  389. package/lldb/lib/python3.12/multiprocessing/queues.py +401 -0
  390. package/lldb/lib/python3.12/multiprocessing/reduction.py +281 -0
  391. package/lldb/lib/python3.12/multiprocessing/resource_sharer.py +154 -0
  392. package/lldb/lib/python3.12/multiprocessing/resource_tracker.py +269 -0
  393. package/lldb/lib/python3.12/multiprocessing/shared_memory.py +534 -0
  394. package/lldb/lib/python3.12/multiprocessing/sharedctypes.py +240 -0
  395. package/lldb/lib/python3.12/multiprocessing/spawn.py +307 -0
  396. package/lldb/lib/python3.12/multiprocessing/synchronize.py +404 -0
  397. package/lldb/lib/python3.12/multiprocessing/util.py +494 -0
  398. package/lldb/lib/python3.12/netrc.py +192 -0
  399. package/lldb/lib/python3.12/nntplib.py +1093 -0
  400. package/lldb/lib/python3.12/ntpath.py +889 -0
  401. package/lldb/lib/python3.12/nturl2path.py +81 -0
  402. package/lldb/lib/python3.12/numbers.py +418 -0
  403. package/lldb/lib/python3.12/opcode.py +493 -0
  404. package/lldb/lib/python3.12/operator.py +467 -0
  405. package/lldb/lib/python3.12/optparse.py +1681 -0
  406. package/lldb/lib/python3.12/os.py +1159 -0
  407. package/lldb/lib/python3.12/pathlib.py +1435 -0
  408. package/lldb/lib/python3.12/pdb.py +1987 -0
  409. package/lldb/lib/python3.12/pickle.py +1865 -0
  410. package/lldb/lib/python3.12/pickletools.py +2901 -0
  411. package/lldb/lib/python3.12/pipes.py +250 -0
  412. package/lldb/lib/python3.12/pkgutil.py +529 -0
  413. package/lldb/lib/python3.12/platform.py +1358 -0
  414. package/lldb/lib/python3.12/plistlib.py +911 -0
  415. package/lldb/lib/python3.12/poplib.py +467 -0
  416. package/lldb/lib/python3.12/posixpath.py +573 -0
  417. package/lldb/lib/python3.12/pprint.py +658 -0
  418. package/lldb/lib/python3.12/profile.py +615 -0
  419. package/lldb/lib/python3.12/pstats.py +778 -0
  420. package/lldb/lib/python3.12/pty.py +211 -0
  421. package/lldb/lib/python3.12/py_compile.py +212 -0
  422. package/lldb/lib/python3.12/pyclbr.py +314 -0
  423. package/lldb/lib/python3.12/pydoc.py +2941 -0
  424. package/lldb/lib/python3.12/pydoc_data/__init__.py +0 -0
  425. package/lldb/lib/python3.12/pydoc_data/topics.py +16777 -0
  426. package/lldb/lib/python3.12/queue.py +326 -0
  427. package/lldb/lib/python3.12/quopri.py +237 -0
  428. package/lldb/lib/python3.12/random.py +996 -0
  429. package/lldb/lib/python3.12/re/__init__.py +385 -0
  430. package/lldb/lib/python3.12/re/_casefix.py +106 -0
  431. package/lldb/lib/python3.12/re/_compiler.py +765 -0
  432. package/lldb/lib/python3.12/re/_constants.py +220 -0
  433. package/lldb/lib/python3.12/re/_parser.py +1080 -0
  434. package/lldb/lib/python3.12/reprlib.py +193 -0
  435. package/lldb/lib/python3.12/rlcompleter.py +219 -0
  436. package/lldb/lib/python3.12/runpy.py +319 -0
  437. package/lldb/lib/python3.12/sched.py +167 -0
  438. package/lldb/lib/python3.12/secrets.py +71 -0
  439. package/lldb/lib/python3.12/selectors.py +623 -0
  440. package/lldb/lib/python3.12/shelve.py +243 -0
  441. package/lldb/lib/python3.12/shlex.py +345 -0
  442. package/lldb/lib/python3.12/shutil.py +1566 -0
  443. package/lldb/lib/python3.12/signal.py +94 -0
  444. package/lldb/lib/python3.12/site-packages/pip/__init__.py +13 -0
  445. package/lldb/lib/python3.12/site-packages/pip/__main__.py +24 -0
  446. package/lldb/lib/python3.12/site-packages/pip/__pip-runner__.py +50 -0
  447. package/lldb/lib/python3.12/site-packages/pip/_internal/__init__.py +18 -0
  448. package/lldb/lib/python3.12/site-packages/pip/_internal/build_env.py +314 -0
  449. package/lldb/lib/python3.12/site-packages/pip/_internal/cache.py +290 -0
  450. package/lldb/lib/python3.12/site-packages/pip/_internal/cli/__init__.py +4 -0
  451. package/lldb/lib/python3.12/site-packages/pip/_internal/cli/autocompletion.py +176 -0
  452. package/lldb/lib/python3.12/site-packages/pip/_internal/cli/base_command.py +234 -0
  453. package/lldb/lib/python3.12/site-packages/pip/_internal/cli/cmdoptions.py +1074 -0
  454. package/lldb/lib/python3.12/site-packages/pip/_internal/cli/command_context.py +27 -0
  455. package/lldb/lib/python3.12/site-packages/pip/_internal/cli/index_command.py +172 -0
  456. package/lldb/lib/python3.12/site-packages/pip/_internal/cli/main.py +80 -0
  457. package/lldb/lib/python3.12/site-packages/pip/_internal/cli/main_parser.py +134 -0
  458. package/lldb/lib/python3.12/site-packages/pip/_internal/cli/parser.py +294 -0
  459. package/lldb/lib/python3.12/site-packages/pip/_internal/cli/progress_bars.py +94 -0
  460. package/lldb/lib/python3.12/site-packages/pip/_internal/cli/req_command.py +329 -0
  461. package/lldb/lib/python3.12/site-packages/pip/_internal/cli/spinners.py +159 -0
  462. package/lldb/lib/python3.12/site-packages/pip/_internal/cli/status_codes.py +6 -0
  463. package/lldb/lib/python3.12/site-packages/pip/_internal/commands/__init__.py +132 -0
  464. package/lldb/lib/python3.12/site-packages/pip/_internal/commands/cache.py +225 -0
  465. package/lldb/lib/python3.12/site-packages/pip/_internal/commands/check.py +52 -0
  466. package/lldb/lib/python3.12/site-packages/pip/_internal/commands/completion.py +130 -0
  467. package/lldb/lib/python3.12/site-packages/pip/_internal/commands/configuration.py +280 -0
  468. package/lldb/lib/python3.12/site-packages/pip/_internal/commands/debug.py +201 -0
  469. package/lldb/lib/python3.12/site-packages/pip/_internal/commands/download.py +146 -0
  470. package/lldb/lib/python3.12/site-packages/pip/_internal/commands/freeze.py +108 -0
  471. package/lldb/lib/python3.12/site-packages/pip/_internal/commands/hash.py +59 -0
  472. package/lldb/lib/python3.12/site-packages/pip/_internal/commands/help.py +41 -0
  473. package/lldb/lib/python3.12/site-packages/pip/_internal/commands/index.py +139 -0
  474. package/lldb/lib/python3.12/site-packages/pip/_internal/commands/inspect.py +92 -0
  475. package/lldb/lib/python3.12/site-packages/pip/_internal/commands/install.py +777 -0
  476. package/lldb/lib/python3.12/site-packages/pip/_internal/commands/list.py +375 -0
  477. package/lldb/lib/python3.12/site-packages/pip/_internal/commands/search.py +172 -0
  478. package/lldb/lib/python3.12/site-packages/pip/_internal/commands/show.py +217 -0
  479. package/lldb/lib/python3.12/site-packages/pip/_internal/commands/uninstall.py +114 -0
  480. package/lldb/lib/python3.12/site-packages/pip/_internal/commands/wheel.py +182 -0
  481. package/lldb/lib/python3.12/site-packages/pip/_internal/configuration.py +383 -0
  482. package/lldb/lib/python3.12/site-packages/pip/_internal/distributions/__init__.py +21 -0
  483. package/lldb/lib/python3.12/site-packages/pip/_internal/distributions/base.py +53 -0
  484. package/lldb/lib/python3.12/site-packages/pip/_internal/distributions/installed.py +29 -0
  485. package/lldb/lib/python3.12/site-packages/pip/_internal/distributions/sdist.py +158 -0
  486. package/lldb/lib/python3.12/site-packages/pip/_internal/distributions/wheel.py +42 -0
  487. package/lldb/lib/python3.12/site-packages/pip/_internal/exceptions.py +777 -0
  488. package/lldb/lib/python3.12/site-packages/pip/_internal/index/__init__.py +2 -0
  489. package/lldb/lib/python3.12/site-packages/pip/_internal/index/collector.py +494 -0
  490. package/lldb/lib/python3.12/site-packages/pip/_internal/index/package_finder.py +1021 -0
  491. package/lldb/lib/python3.12/site-packages/pip/_internal/index/sources.py +285 -0
  492. package/lldb/lib/python3.12/site-packages/pip/_internal/locations/__init__.py +456 -0
  493. package/lldb/lib/python3.12/site-packages/pip/_internal/locations/_distutils.py +172 -0
  494. package/lldb/lib/python3.12/site-packages/pip/_internal/locations/_sysconfig.py +214 -0
  495. package/lldb/lib/python3.12/site-packages/pip/_internal/locations/base.py +81 -0
  496. package/lldb/lib/python3.12/site-packages/pip/_internal/main.py +12 -0
  497. package/lldb/lib/python3.12/site-packages/pip/_internal/metadata/__init__.py +128 -0
  498. package/lldb/lib/python3.12/site-packages/pip/_internal/metadata/_json.py +84 -0
  499. package/lldb/lib/python3.12/site-packages/pip/_internal/metadata/base.py +688 -0
  500. package/lldb/lib/python3.12/site-packages/pip/_internal/metadata/importlib/__init__.py +6 -0
  501. package/lldb/lib/python3.12/site-packages/pip/_internal/metadata/importlib/_compat.py +55 -0
  502. package/lldb/lib/python3.12/site-packages/pip/_internal/metadata/importlib/_dists.py +228 -0
  503. package/lldb/lib/python3.12/site-packages/pip/_internal/metadata/importlib/_envs.py +189 -0
  504. package/lldb/lib/python3.12/site-packages/pip/_internal/metadata/pkg_resources.py +301 -0
  505. package/lldb/lib/python3.12/site-packages/pip/_internal/models/__init__.py +2 -0
  506. package/lldb/lib/python3.12/site-packages/pip/_internal/models/candidate.py +25 -0
  507. package/lldb/lib/python3.12/site-packages/pip/_internal/models/direct_url.py +224 -0
  508. package/lldb/lib/python3.12/site-packages/pip/_internal/models/format_control.py +78 -0
  509. package/lldb/lib/python3.12/site-packages/pip/_internal/models/index.py +28 -0
  510. package/lldb/lib/python3.12/site-packages/pip/_internal/models/installation_report.py +56 -0
  511. package/lldb/lib/python3.12/site-packages/pip/_internal/models/link.py +590 -0
  512. package/lldb/lib/python3.12/site-packages/pip/_internal/models/scheme.py +25 -0
  513. package/lldb/lib/python3.12/site-packages/pip/_internal/models/search_scope.py +127 -0
  514. package/lldb/lib/python3.12/site-packages/pip/_internal/models/selection_prefs.py +53 -0
  515. package/lldb/lib/python3.12/site-packages/pip/_internal/models/target_python.py +121 -0
  516. package/lldb/lib/python3.12/site-packages/pip/_internal/models/wheel.py +93 -0
  517. package/lldb/lib/python3.12/site-packages/pip/_internal/network/__init__.py +2 -0
  518. package/lldb/lib/python3.12/site-packages/pip/_internal/network/auth.py +562 -0
  519. package/lldb/lib/python3.12/site-packages/pip/_internal/network/cache.py +106 -0
  520. package/lldb/lib/python3.12/site-packages/pip/_internal/network/download.py +187 -0
  521. package/lldb/lib/python3.12/site-packages/pip/_internal/network/lazy_wheel.py +210 -0
  522. package/lldb/lib/python3.12/site-packages/pip/_internal/network/session.py +522 -0
  523. package/lldb/lib/python3.12/site-packages/pip/_internal/network/utils.py +96 -0
  524. package/lldb/lib/python3.12/site-packages/pip/_internal/network/xmlrpc.py +62 -0
  525. package/lldb/lib/python3.12/site-packages/pip/_internal/operations/__init__.py +0 -0
  526. package/lldb/lib/python3.12/site-packages/pip/_internal/operations/build/__init__.py +0 -0
  527. package/lldb/lib/python3.12/site-packages/pip/_internal/operations/build/build_tracker.py +138 -0
  528. package/lldb/lib/python3.12/site-packages/pip/_internal/operations/build/metadata.py +39 -0
  529. package/lldb/lib/python3.12/site-packages/pip/_internal/operations/build/metadata_editable.py +41 -0
  530. package/lldb/lib/python3.12/site-packages/pip/_internal/operations/build/metadata_legacy.py +74 -0
  531. package/lldb/lib/python3.12/site-packages/pip/_internal/operations/build/wheel.py +37 -0
  532. package/lldb/lib/python3.12/site-packages/pip/_internal/operations/build/wheel_editable.py +46 -0
  533. package/lldb/lib/python3.12/site-packages/pip/_internal/operations/build/wheel_legacy.py +102 -0
  534. package/lldb/lib/python3.12/site-packages/pip/_internal/operations/check.py +149 -0
  535. package/lldb/lib/python3.12/site-packages/pip/_internal/operations/freeze.py +258 -0
  536. package/lldb/lib/python3.12/site-packages/pip/_internal/operations/install/__init__.py +2 -0
  537. package/lldb/lib/python3.12/site-packages/pip/_internal/operations/install/editable_legacy.py +47 -0
  538. package/lldb/lib/python3.12/site-packages/pip/_internal/operations/install/wheel.py +735 -0
  539. package/lldb/lib/python3.12/site-packages/pip/_internal/operations/prepare.py +732 -0
  540. package/lldb/lib/python3.12/site-packages/pip/_internal/pyproject.py +179 -0
  541. package/lldb/lib/python3.12/site-packages/pip/_internal/req/__init__.py +90 -0
  542. package/lldb/lib/python3.12/site-packages/pip/_internal/req/constructors.py +560 -0
  543. package/lldb/lib/python3.12/site-packages/pip/_internal/req/req_file.py +551 -0
  544. package/lldb/lib/python3.12/site-packages/pip/_internal/req/req_install.py +918 -0
  545. package/lldb/lib/python3.12/site-packages/pip/_internal/req/req_set.py +82 -0
  546. package/lldb/lib/python3.12/site-packages/pip/_internal/req/req_uninstall.py +633 -0
  547. package/lldb/lib/python3.12/site-packages/pip/_internal/resolution/__init__.py +0 -0
  548. package/lldb/lib/python3.12/site-packages/pip/_internal/resolution/base.py +20 -0
  549. package/lldb/lib/python3.12/site-packages/pip/_internal/resolution/legacy/__init__.py +0 -0
  550. package/lldb/lib/python3.12/site-packages/pip/_internal/resolution/legacy/resolver.py +597 -0
  551. package/lldb/lib/python3.12/site-packages/pip/_internal/resolution/resolvelib/__init__.py +0 -0
  552. package/lldb/lib/python3.12/site-packages/pip/_internal/resolution/resolvelib/base.py +139 -0
  553. package/lldb/lib/python3.12/site-packages/pip/_internal/resolution/resolvelib/candidates.py +569 -0
  554. package/lldb/lib/python3.12/site-packages/pip/_internal/resolution/resolvelib/factory.py +816 -0
  555. package/lldb/lib/python3.12/site-packages/pip/_internal/resolution/resolvelib/found_candidates.py +174 -0
  556. package/lldb/lib/python3.12/site-packages/pip/_internal/resolution/resolvelib/provider.py +258 -0
  557. package/lldb/lib/python3.12/site-packages/pip/_internal/resolution/resolvelib/reporter.py +80 -0
  558. package/lldb/lib/python3.12/site-packages/pip/_internal/resolution/resolvelib/requirements.py +245 -0
  559. package/lldb/lib/python3.12/site-packages/pip/_internal/resolution/resolvelib/resolver.py +317 -0
  560. package/lldb/lib/python3.12/site-packages/pip/_internal/self_outdated_check.py +248 -0
  561. package/lldb/lib/python3.12/site-packages/pip/_internal/utils/__init__.py +0 -0
  562. package/lldb/lib/python3.12/site-packages/pip/_internal/utils/_jaraco_text.py +109 -0
  563. package/lldb/lib/python3.12/site-packages/pip/_internal/utils/_log.py +38 -0
  564. package/lldb/lib/python3.12/site-packages/pip/_internal/utils/appdirs.py +52 -0
  565. package/lldb/lib/python3.12/site-packages/pip/_internal/utils/compat.py +79 -0
  566. package/lldb/lib/python3.12/site-packages/pip/_internal/utils/compatibility_tags.py +165 -0
  567. package/lldb/lib/python3.12/site-packages/pip/_internal/utils/datetime.py +11 -0
  568. package/lldb/lib/python3.12/site-packages/pip/_internal/utils/deprecation.py +124 -0
  569. package/lldb/lib/python3.12/site-packages/pip/_internal/utils/direct_url_helpers.py +87 -0
  570. package/lldb/lib/python3.12/site-packages/pip/_internal/utils/egg_link.py +80 -0
  571. package/lldb/lib/python3.12/site-packages/pip/_internal/utils/encoding.py +36 -0
  572. package/lldb/lib/python3.12/site-packages/pip/_internal/utils/entrypoints.py +84 -0
  573. package/lldb/lib/python3.12/site-packages/pip/_internal/utils/filesystem.py +153 -0
  574. package/lldb/lib/python3.12/site-packages/pip/_internal/utils/filetypes.py +27 -0
  575. package/lldb/lib/python3.12/site-packages/pip/_internal/utils/glibc.py +91 -0
  576. package/lldb/lib/python3.12/site-packages/pip/_internal/utils/hashes.py +147 -0
  577. package/lldb/lib/python3.12/site-packages/pip/_internal/utils/logging.py +347 -0
  578. package/lldb/lib/python3.12/site-packages/pip/_internal/utils/misc.py +780 -0
  579. package/lldb/lib/python3.12/site-packages/pip/_internal/utils/packaging.py +57 -0
  580. package/lldb/lib/python3.12/site-packages/pip/_internal/utils/setuptools_build.py +146 -0
  581. package/lldb/lib/python3.12/site-packages/pip/_internal/utils/subprocess.py +245 -0
  582. package/lldb/lib/python3.12/site-packages/pip/_internal/utils/temp_dir.py +296 -0
  583. package/lldb/lib/python3.12/site-packages/pip/_internal/utils/unpacking.py +337 -0
  584. package/lldb/lib/python3.12/site-packages/pip/_internal/utils/urls.py +55 -0
  585. package/lldb/lib/python3.12/site-packages/pip/_internal/utils/virtualenv.py +104 -0
  586. package/lldb/lib/python3.12/site-packages/pip/_internal/utils/wheel.py +134 -0
  587. package/lldb/lib/python3.12/site-packages/pip/_internal/vcs/__init__.py +15 -0
  588. package/lldb/lib/python3.12/site-packages/pip/_internal/vcs/bazaar.py +112 -0
  589. package/lldb/lib/python3.12/site-packages/pip/_internal/vcs/git.py +527 -0
  590. package/lldb/lib/python3.12/site-packages/pip/_internal/vcs/mercurial.py +163 -0
  591. package/lldb/lib/python3.12/site-packages/pip/_internal/vcs/subversion.py +324 -0
  592. package/lldb/lib/python3.12/site-packages/pip/_internal/vcs/versioncontrol.py +688 -0
  593. package/lldb/lib/python3.12/site-packages/pip/_internal/wheel_builder.py +354 -0
  594. package/lldb/lib/python3.12/site-packages/pip/_vendor/__init__.py +116 -0
  595. package/lldb/lib/python3.12/site-packages/pip/_vendor/cachecontrol/__init__.py +28 -0
  596. package/lldb/lib/python3.12/site-packages/pip/_vendor/cachecontrol/_cmd.py +70 -0
  597. package/lldb/lib/python3.12/site-packages/pip/_vendor/cachecontrol/adapter.py +161 -0
  598. package/lldb/lib/python3.12/site-packages/pip/_vendor/cachecontrol/cache.py +74 -0
  599. package/lldb/lib/python3.12/site-packages/pip/_vendor/cachecontrol/caches/__init__.py +8 -0
  600. package/lldb/lib/python3.12/site-packages/pip/_vendor/cachecontrol/caches/file_cache.py +182 -0
  601. package/lldb/lib/python3.12/site-packages/pip/_vendor/cachecontrol/caches/redis_cache.py +48 -0
  602. package/lldb/lib/python3.12/site-packages/pip/_vendor/cachecontrol/controller.py +499 -0
  603. package/lldb/lib/python3.12/site-packages/pip/_vendor/cachecontrol/filewrapper.py +119 -0
  604. package/lldb/lib/python3.12/site-packages/pip/_vendor/cachecontrol/heuristics.py +154 -0
  605. package/lldb/lib/python3.12/site-packages/pip/_vendor/cachecontrol/serialize.py +146 -0
  606. package/lldb/lib/python3.12/site-packages/pip/_vendor/cachecontrol/wrapper.py +43 -0
  607. package/lldb/lib/python3.12/site-packages/pip/_vendor/certifi/__init__.py +4 -0
  608. package/lldb/lib/python3.12/site-packages/pip/_vendor/certifi/__main__.py +12 -0
  609. package/lldb/lib/python3.12/site-packages/pip/_vendor/certifi/cacert.pem +4814 -0
  610. package/lldb/lib/python3.12/site-packages/pip/_vendor/certifi/core.py +114 -0
  611. package/lldb/lib/python3.12/site-packages/pip/_vendor/distlib/__init__.py +33 -0
  612. package/lldb/lib/python3.12/site-packages/pip/_vendor/distlib/compat.py +1138 -0
  613. package/lldb/lib/python3.12/site-packages/pip/_vendor/distlib/database.py +1359 -0
  614. package/lldb/lib/python3.12/site-packages/pip/_vendor/distlib/index.py +508 -0
  615. package/lldb/lib/python3.12/site-packages/pip/_vendor/distlib/locators.py +1303 -0
  616. package/lldb/lib/python3.12/site-packages/pip/_vendor/distlib/manifest.py +384 -0
  617. package/lldb/lib/python3.12/site-packages/pip/_vendor/distlib/markers.py +167 -0
  618. package/lldb/lib/python3.12/site-packages/pip/_vendor/distlib/metadata.py +1068 -0
  619. package/lldb/lib/python3.12/site-packages/pip/_vendor/distlib/resources.py +358 -0
  620. package/lldb/lib/python3.12/site-packages/pip/_vendor/distlib/scripts.py +466 -0
  621. package/lldb/lib/python3.12/site-packages/pip/_vendor/distlib/t32.exe +0 -0
  622. package/lldb/lib/python3.12/site-packages/pip/_vendor/distlib/t64-arm.exe +0 -0
  623. package/lldb/lib/python3.12/site-packages/pip/_vendor/distlib/t64.exe +0 -0
  624. package/lldb/lib/python3.12/site-packages/pip/_vendor/distlib/util.py +2025 -0
  625. package/lldb/lib/python3.12/site-packages/pip/_vendor/distlib/version.py +751 -0
  626. package/lldb/lib/python3.12/site-packages/pip/_vendor/distlib/w32.exe +0 -0
  627. package/lldb/lib/python3.12/site-packages/pip/_vendor/distlib/w64-arm.exe +0 -0
  628. package/lldb/lib/python3.12/site-packages/pip/_vendor/distlib/w64.exe +0 -0
  629. package/lldb/lib/python3.12/site-packages/pip/_vendor/distlib/wheel.py +1099 -0
  630. package/lldb/lib/python3.12/site-packages/pip/_vendor/distro/__init__.py +54 -0
  631. package/lldb/lib/python3.12/site-packages/pip/_vendor/distro/__main__.py +4 -0
  632. package/lldb/lib/python3.12/site-packages/pip/_vendor/distro/distro.py +1403 -0
  633. package/lldb/lib/python3.12/site-packages/pip/_vendor/idna/__init__.py +44 -0
  634. package/lldb/lib/python3.12/site-packages/pip/_vendor/idna/codec.py +118 -0
  635. package/lldb/lib/python3.12/site-packages/pip/_vendor/idna/compat.py +13 -0
  636. package/lldb/lib/python3.12/site-packages/pip/_vendor/idna/core.py +395 -0
  637. package/lldb/lib/python3.12/site-packages/pip/_vendor/idna/idnadata.py +4245 -0
  638. package/lldb/lib/python3.12/site-packages/pip/_vendor/idna/intranges.py +54 -0
  639. package/lldb/lib/python3.12/site-packages/pip/_vendor/idna/package_data.py +2 -0
  640. package/lldb/lib/python3.12/site-packages/pip/_vendor/idna/uts46data.py +8598 -0
  641. package/lldb/lib/python3.12/site-packages/pip/_vendor/msgpack/__init__.py +55 -0
  642. package/lldb/lib/python3.12/site-packages/pip/_vendor/msgpack/exceptions.py +48 -0
  643. package/lldb/lib/python3.12/site-packages/pip/_vendor/msgpack/ext.py +168 -0
  644. package/lldb/lib/python3.12/site-packages/pip/_vendor/msgpack/fallback.py +951 -0
  645. package/lldb/lib/python3.12/site-packages/pip/_vendor/packaging/__init__.py +15 -0
  646. package/lldb/lib/python3.12/site-packages/pip/_vendor/packaging/_elffile.py +110 -0
  647. package/lldb/lib/python3.12/site-packages/pip/_vendor/packaging/_manylinux.py +262 -0
  648. package/lldb/lib/python3.12/site-packages/pip/_vendor/packaging/_musllinux.py +85 -0
  649. package/lldb/lib/python3.12/site-packages/pip/_vendor/packaging/_parser.py +354 -0
  650. package/lldb/lib/python3.12/site-packages/pip/_vendor/packaging/_structures.py +61 -0
  651. package/lldb/lib/python3.12/site-packages/pip/_vendor/packaging/_tokenizer.py +194 -0
  652. package/lldb/lib/python3.12/site-packages/pip/_vendor/packaging/markers.py +325 -0
  653. package/lldb/lib/python3.12/site-packages/pip/_vendor/packaging/metadata.py +804 -0
  654. package/lldb/lib/python3.12/site-packages/pip/_vendor/packaging/requirements.py +91 -0
  655. package/lldb/lib/python3.12/site-packages/pip/_vendor/packaging/specifiers.py +1009 -0
  656. package/lldb/lib/python3.12/site-packages/pip/_vendor/packaging/tags.py +568 -0
  657. package/lldb/lib/python3.12/site-packages/pip/_vendor/packaging/utils.py +174 -0
  658. package/lldb/lib/python3.12/site-packages/pip/_vendor/packaging/version.py +563 -0
  659. package/lldb/lib/python3.12/site-packages/pip/_vendor/pkg_resources/__init__.py +3325 -0
  660. package/lldb/lib/python3.12/site-packages/pip/_vendor/platformdirs/__init__.py +627 -0
  661. package/lldb/lib/python3.12/site-packages/pip/_vendor/platformdirs/__main__.py +55 -0
  662. package/lldb/lib/python3.12/site-packages/pip/_vendor/platformdirs/android.py +222 -0
  663. package/lldb/lib/python3.12/site-packages/pip/_vendor/platformdirs/api.py +292 -0
  664. package/lldb/lib/python3.12/site-packages/pip/_vendor/platformdirs/macos.py +130 -0
  665. package/lldb/lib/python3.12/site-packages/pip/_vendor/platformdirs/unix.py +275 -0
  666. package/lldb/lib/python3.12/site-packages/pip/_vendor/platformdirs/version.py +16 -0
  667. package/lldb/lib/python3.12/site-packages/pip/_vendor/platformdirs/windows.py +272 -0
  668. package/lldb/lib/python3.12/site-packages/pip/_vendor/pygments/__init__.py +82 -0
  669. package/lldb/lib/python3.12/site-packages/pip/_vendor/pygments/__main__.py +17 -0
  670. package/lldb/lib/python3.12/site-packages/pip/_vendor/pygments/cmdline.py +668 -0
  671. package/lldb/lib/python3.12/site-packages/pip/_vendor/pygments/console.py +70 -0
  672. package/lldb/lib/python3.12/site-packages/pip/_vendor/pygments/filter.py +71 -0
  673. package/lldb/lib/python3.12/site-packages/pip/_vendor/pygments/filters/__init__.py +940 -0
  674. package/lldb/lib/python3.12/site-packages/pip/_vendor/pygments/formatter.py +124 -0
  675. package/lldb/lib/python3.12/site-packages/pip/_vendor/pygments/formatters/__init__.py +158 -0
  676. package/lldb/lib/python3.12/site-packages/pip/_vendor/pygments/formatters/_mapping.py +23 -0
  677. package/lldb/lib/python3.12/site-packages/pip/_vendor/pygments/formatters/bbcode.py +108 -0
  678. package/lldb/lib/python3.12/site-packages/pip/_vendor/pygments/formatters/groff.py +170 -0
  679. package/lldb/lib/python3.12/site-packages/pip/_vendor/pygments/formatters/html.py +990 -0
  680. package/lldb/lib/python3.12/site-packages/pip/_vendor/pygments/formatters/img.py +684 -0
  681. package/lldb/lib/python3.12/site-packages/pip/_vendor/pygments/formatters/irc.py +154 -0
  682. package/lldb/lib/python3.12/site-packages/pip/_vendor/pygments/formatters/latex.py +521 -0
  683. package/lldb/lib/python3.12/site-packages/pip/_vendor/pygments/formatters/other.py +161 -0
  684. package/lldb/lib/python3.12/site-packages/pip/_vendor/pygments/formatters/pangomarkup.py +83 -0
  685. package/lldb/lib/python3.12/site-packages/pip/_vendor/pygments/formatters/rtf.py +146 -0
  686. package/lldb/lib/python3.12/site-packages/pip/_vendor/pygments/formatters/svg.py +188 -0
  687. package/lldb/lib/python3.12/site-packages/pip/_vendor/pygments/formatters/terminal.py +127 -0
  688. package/lldb/lib/python3.12/site-packages/pip/_vendor/pygments/formatters/terminal256.py +338 -0
  689. package/lldb/lib/python3.12/site-packages/pip/_vendor/pygments/lexer.py +961 -0
  690. package/lldb/lib/python3.12/site-packages/pip/_vendor/pygments/lexers/__init__.py +363 -0
  691. package/lldb/lib/python3.12/site-packages/pip/_vendor/pygments/lexers/_mapping.py +580 -0
  692. package/lldb/lib/python3.12/site-packages/pip/_vendor/pygments/lexers/python.py +1198 -0
  693. package/lldb/lib/python3.12/site-packages/pip/_vendor/pygments/modeline.py +43 -0
  694. package/lldb/lib/python3.12/site-packages/pip/_vendor/pygments/plugin.py +88 -0
  695. package/lldb/lib/python3.12/site-packages/pip/_vendor/pygments/regexopt.py +91 -0
  696. package/lldb/lib/python3.12/site-packages/pip/_vendor/pygments/scanner.py +104 -0
  697. package/lldb/lib/python3.12/site-packages/pip/_vendor/pygments/sphinxext.py +239 -0
  698. package/lldb/lib/python3.12/site-packages/pip/_vendor/pygments/style.py +203 -0
  699. package/lldb/lib/python3.12/site-packages/pip/_vendor/pygments/styles/__init__.py +61 -0
  700. package/lldb/lib/python3.12/site-packages/pip/_vendor/pygments/styles/_mapping.py +53 -0
  701. package/lldb/lib/python3.12/site-packages/pip/_vendor/pygments/token.py +214 -0
  702. package/lldb/lib/python3.12/site-packages/pip/_vendor/pygments/unistring.py +153 -0
  703. package/lldb/lib/python3.12/site-packages/pip/_vendor/pygments/util.py +330 -0
  704. package/lldb/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/__init__.py +23 -0
  705. package/lldb/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_compat.py +8 -0
  706. package/lldb/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_impl.py +330 -0
  707. package/lldb/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/__init__.py +18 -0
  708. package/lldb/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py +353 -0
  709. package/lldb/lib/python3.12/site-packages/pip/_vendor/requests/__init__.py +179 -0
  710. package/lldb/lib/python3.12/site-packages/pip/_vendor/requests/__version__.py +14 -0
  711. package/lldb/lib/python3.12/site-packages/pip/_vendor/requests/_internal_utils.py +50 -0
  712. package/lldb/lib/python3.12/site-packages/pip/_vendor/requests/adapters.py +719 -0
  713. package/lldb/lib/python3.12/site-packages/pip/_vendor/requests/api.py +157 -0
  714. package/lldb/lib/python3.12/site-packages/pip/_vendor/requests/auth.py +314 -0
  715. package/lldb/lib/python3.12/site-packages/pip/_vendor/requests/certs.py +24 -0
  716. package/lldb/lib/python3.12/site-packages/pip/_vendor/requests/compat.py +78 -0
  717. package/lldb/lib/python3.12/site-packages/pip/_vendor/requests/cookies.py +561 -0
  718. package/lldb/lib/python3.12/site-packages/pip/_vendor/requests/exceptions.py +151 -0
  719. package/lldb/lib/python3.12/site-packages/pip/_vendor/requests/help.py +127 -0
  720. package/lldb/lib/python3.12/site-packages/pip/_vendor/requests/hooks.py +33 -0
  721. package/lldb/lib/python3.12/site-packages/pip/_vendor/requests/models.py +1037 -0
  722. package/lldb/lib/python3.12/site-packages/pip/_vendor/requests/packages.py +25 -0
  723. package/lldb/lib/python3.12/site-packages/pip/_vendor/requests/sessions.py +831 -0
  724. package/lldb/lib/python3.12/site-packages/pip/_vendor/requests/status_codes.py +128 -0
  725. package/lldb/lib/python3.12/site-packages/pip/_vendor/requests/structures.py +99 -0
  726. package/lldb/lib/python3.12/site-packages/pip/_vendor/requests/utils.py +1096 -0
  727. package/lldb/lib/python3.12/site-packages/pip/_vendor/resolvelib/__init__.py +26 -0
  728. package/lldb/lib/python3.12/site-packages/pip/_vendor/resolvelib/compat/__init__.py +0 -0
  729. package/lldb/lib/python3.12/site-packages/pip/_vendor/resolvelib/compat/collections_abc.py +6 -0
  730. package/lldb/lib/python3.12/site-packages/pip/_vendor/resolvelib/providers.py +133 -0
  731. package/lldb/lib/python3.12/site-packages/pip/_vendor/resolvelib/reporters.py +43 -0
  732. package/lldb/lib/python3.12/site-packages/pip/_vendor/resolvelib/resolvers.py +547 -0
  733. package/lldb/lib/python3.12/site-packages/pip/_vendor/resolvelib/structs.py +170 -0
  734. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/__init__.py +177 -0
  735. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/__main__.py +273 -0
  736. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/_cell_widths.py +454 -0
  737. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/_emoji_codes.py +3610 -0
  738. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/_emoji_replace.py +32 -0
  739. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/_export_format.py +76 -0
  740. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/_extension.py +10 -0
  741. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/_fileno.py +24 -0
  742. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/_inspect.py +270 -0
  743. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/_log_render.py +94 -0
  744. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/_loop.py +43 -0
  745. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/_null_file.py +69 -0
  746. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/_palettes.py +309 -0
  747. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/_pick.py +17 -0
  748. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/_ratio.py +159 -0
  749. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/_spinners.py +482 -0
  750. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/_stack.py +16 -0
  751. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/_timer.py +19 -0
  752. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/_win32_console.py +662 -0
  753. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/_windows.py +71 -0
  754. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/_windows_renderer.py +56 -0
  755. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/_wrap.py +93 -0
  756. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/abc.py +33 -0
  757. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/align.py +311 -0
  758. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/ansi.py +240 -0
  759. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/bar.py +93 -0
  760. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/box.py +480 -0
  761. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/cells.py +167 -0
  762. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/color.py +621 -0
  763. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/color_triplet.py +38 -0
  764. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/columns.py +187 -0
  765. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/console.py +2633 -0
  766. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/constrain.py +37 -0
  767. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/containers.py +167 -0
  768. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/control.py +225 -0
  769. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/default_styles.py +190 -0
  770. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/diagnose.py +37 -0
  771. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/emoji.py +96 -0
  772. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/errors.py +34 -0
  773. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/file_proxy.py +57 -0
  774. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/filesize.py +89 -0
  775. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/highlighter.py +232 -0
  776. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/json.py +139 -0
  777. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/jupyter.py +101 -0
  778. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/layout.py +442 -0
  779. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/live.py +375 -0
  780. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/live_render.py +112 -0
  781. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/logging.py +289 -0
  782. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/markup.py +251 -0
  783. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/measure.py +151 -0
  784. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/padding.py +141 -0
  785. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/pager.py +34 -0
  786. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/palette.py +100 -0
  787. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/panel.py +312 -0
  788. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/pretty.py +995 -0
  789. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/progress.py +1699 -0
  790. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/progress_bar.py +223 -0
  791. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/prompt.py +375 -0
  792. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/protocol.py +42 -0
  793. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/region.py +10 -0
  794. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/repr.py +149 -0
  795. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/rule.py +130 -0
  796. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/scope.py +86 -0
  797. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/screen.py +54 -0
  798. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/segment.py +738 -0
  799. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/spinner.py +137 -0
  800. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/status.py +131 -0
  801. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/style.py +796 -0
  802. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/styled.py +42 -0
  803. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/syntax.py +958 -0
  804. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/table.py +1000 -0
  805. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/terminal_theme.py +153 -0
  806. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/text.py +1357 -0
  807. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/theme.py +115 -0
  808. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/themes.py +5 -0
  809. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/traceback.py +753 -0
  810. package/lldb/lib/python3.12/site-packages/pip/_vendor/rich/tree.py +249 -0
  811. package/lldb/lib/python3.12/site-packages/pip/_vendor/tenacity/__init__.py +608 -0
  812. package/lldb/lib/python3.12/site-packages/pip/_vendor/tenacity/_asyncio.py +94 -0
  813. package/lldb/lib/python3.12/site-packages/pip/_vendor/tenacity/_utils.py +76 -0
  814. package/lldb/lib/python3.12/site-packages/pip/_vendor/tenacity/after.py +51 -0
  815. package/lldb/lib/python3.12/site-packages/pip/_vendor/tenacity/before.py +46 -0
  816. package/lldb/lib/python3.12/site-packages/pip/_vendor/tenacity/before_sleep.py +71 -0
  817. package/lldb/lib/python3.12/site-packages/pip/_vendor/tenacity/nap.py +43 -0
  818. package/lldb/lib/python3.12/site-packages/pip/_vendor/tenacity/retry.py +272 -0
  819. package/lldb/lib/python3.12/site-packages/pip/_vendor/tenacity/stop.py +103 -0
  820. package/lldb/lib/python3.12/site-packages/pip/_vendor/tenacity/tornadoweb.py +59 -0
  821. package/lldb/lib/python3.12/site-packages/pip/_vendor/tenacity/wait.py +228 -0
  822. package/lldb/lib/python3.12/site-packages/pip/_vendor/tomli/__init__.py +11 -0
  823. package/lldb/lib/python3.12/site-packages/pip/_vendor/tomli/_parser.py +691 -0
  824. package/lldb/lib/python3.12/site-packages/pip/_vendor/tomli/_re.py +107 -0
  825. package/lldb/lib/python3.12/site-packages/pip/_vendor/tomli/_types.py +10 -0
  826. package/lldb/lib/python3.12/site-packages/pip/_vendor/truststore/__init__.py +13 -0
  827. package/lldb/lib/python3.12/site-packages/pip/_vendor/truststore/_api.py +313 -0
  828. package/lldb/lib/python3.12/site-packages/pip/_vendor/truststore/_macos.py +499 -0
  829. package/lldb/lib/python3.12/site-packages/pip/_vendor/truststore/_openssl.py +66 -0
  830. package/lldb/lib/python3.12/site-packages/pip/_vendor/truststore/_ssl_constants.py +31 -0
  831. package/lldb/lib/python3.12/site-packages/pip/_vendor/truststore/_windows.py +564 -0
  832. package/lldb/lib/python3.12/site-packages/pip/_vendor/typing_extensions.py +3332 -0
  833. package/lldb/lib/python3.12/site-packages/pip/_vendor/urllib3/__init__.py +102 -0
  834. package/lldb/lib/python3.12/site-packages/pip/_vendor/urllib3/_collections.py +355 -0
  835. package/lldb/lib/python3.12/site-packages/pip/_vendor/urllib3/_version.py +2 -0
  836. package/lldb/lib/python3.12/site-packages/pip/_vendor/urllib3/connection.py +572 -0
  837. package/lldb/lib/python3.12/site-packages/pip/_vendor/urllib3/connectionpool.py +1137 -0
  838. package/lldb/lib/python3.12/site-packages/pip/_vendor/urllib3/contrib/__init__.py +0 -0
  839. package/lldb/lib/python3.12/site-packages/pip/_vendor/urllib3/contrib/_appengine_environ.py +36 -0
  840. package/lldb/lib/python3.12/site-packages/pip/_vendor/urllib3/contrib/_securetransport/__init__.py +0 -0
  841. package/lldb/lib/python3.12/site-packages/pip/_vendor/urllib3/contrib/_securetransport/bindings.py +519 -0
  842. package/lldb/lib/python3.12/site-packages/pip/_vendor/urllib3/contrib/_securetransport/low_level.py +397 -0
  843. package/lldb/lib/python3.12/site-packages/pip/_vendor/urllib3/contrib/appengine.py +314 -0
  844. package/lldb/lib/python3.12/site-packages/pip/_vendor/urllib3/contrib/ntlmpool.py +130 -0
  845. package/lldb/lib/python3.12/site-packages/pip/_vendor/urllib3/contrib/pyopenssl.py +518 -0
  846. package/lldb/lib/python3.12/site-packages/pip/_vendor/urllib3/contrib/securetransport.py +920 -0
  847. package/lldb/lib/python3.12/site-packages/pip/_vendor/urllib3/contrib/socks.py +216 -0
  848. package/lldb/lib/python3.12/site-packages/pip/_vendor/urllib3/exceptions.py +323 -0
  849. package/lldb/lib/python3.12/site-packages/pip/_vendor/urllib3/fields.py +274 -0
  850. package/lldb/lib/python3.12/site-packages/pip/_vendor/urllib3/filepost.py +98 -0
  851. package/lldb/lib/python3.12/site-packages/pip/_vendor/urllib3/packages/__init__.py +0 -0
  852. package/lldb/lib/python3.12/site-packages/pip/_vendor/urllib3/packages/backports/__init__.py +0 -0
  853. package/lldb/lib/python3.12/site-packages/pip/_vendor/urllib3/packages/backports/makefile.py +51 -0
  854. package/lldb/lib/python3.12/site-packages/pip/_vendor/urllib3/packages/backports/weakref_finalize.py +155 -0
  855. package/lldb/lib/python3.12/site-packages/pip/_vendor/urllib3/packages/six.py +1076 -0
  856. package/lldb/lib/python3.12/site-packages/pip/_vendor/urllib3/poolmanager.py +540 -0
  857. package/lldb/lib/python3.12/site-packages/pip/_vendor/urllib3/request.py +191 -0
  858. package/lldb/lib/python3.12/site-packages/pip/_vendor/urllib3/response.py +879 -0
  859. package/lldb/lib/python3.12/site-packages/pip/_vendor/urllib3/util/__init__.py +49 -0
  860. package/lldb/lib/python3.12/site-packages/pip/_vendor/urllib3/util/connection.py +149 -0
  861. package/lldb/lib/python3.12/site-packages/pip/_vendor/urllib3/util/proxy.py +57 -0
  862. package/lldb/lib/python3.12/site-packages/pip/_vendor/urllib3/util/queue.py +22 -0
  863. package/lldb/lib/python3.12/site-packages/pip/_vendor/urllib3/util/request.py +137 -0
  864. package/lldb/lib/python3.12/site-packages/pip/_vendor/urllib3/util/response.py +107 -0
  865. package/lldb/lib/python3.12/site-packages/pip/_vendor/urllib3/util/retry.py +620 -0
  866. package/lldb/lib/python3.12/site-packages/pip/_vendor/urllib3/util/ssl_.py +495 -0
  867. package/lldb/lib/python3.12/site-packages/pip/_vendor/urllib3/util/ssl_match_hostname.py +159 -0
  868. package/lldb/lib/python3.12/site-packages/pip/_vendor/urllib3/util/ssltransport.py +221 -0
  869. package/lldb/lib/python3.12/site-packages/pip/_vendor/urllib3/util/timeout.py +271 -0
  870. package/lldb/lib/python3.12/site-packages/pip/_vendor/urllib3/util/url.py +435 -0
  871. package/lldb/lib/python3.12/site-packages/pip/_vendor/urllib3/util/wait.py +152 -0
  872. package/lldb/lib/python3.12/site.py +692 -0
  873. package/lldb/lib/python3.12/smtplib.py +1109 -0
  874. package/lldb/lib/python3.12/sndhdr.py +271 -0
  875. package/lldb/lib/python3.12/socket.py +981 -0
  876. package/lldb/lib/python3.12/socketserver.py +858 -0
  877. package/lldb/lib/python3.12/sre_compile.py +7 -0
  878. package/lldb/lib/python3.12/sre_constants.py +7 -0
  879. package/lldb/lib/python3.12/sre_parse.py +7 -0
  880. package/lldb/lib/python3.12/ssl.py +1476 -0
  881. package/lldb/lib/python3.12/stat.py +195 -0
  882. package/lldb/lib/python3.12/statistics.py +1454 -0
  883. package/lldb/lib/python3.12/string.py +309 -0
  884. package/lldb/lib/python3.12/stringprep.py +272 -0
  885. package/lldb/lib/python3.12/struct.py +15 -0
  886. package/lldb/lib/python3.12/subprocess.py +2216 -0
  887. package/lldb/lib/python3.12/sunau.py +533 -0
  888. package/lldb/lib/python3.12/symtable.py +362 -0
  889. package/lldb/lib/python3.12/sysconfig.py +876 -0
  890. package/lldb/lib/python3.12/tabnanny.py +340 -0
  891. package/lldb/lib/python3.12/tarfile.py +2933 -0
  892. package/lldb/lib/python3.12/telnetlib.py +680 -0
  893. package/lldb/lib/python3.12/tempfile.py +952 -0
  894. package/lldb/lib/python3.12/textwrap.py +491 -0
  895. package/lldb/lib/python3.12/this.py +28 -0
  896. package/lldb/lib/python3.12/threading.py +1708 -0
  897. package/lldb/lib/python3.12/timeit.py +381 -0
  898. package/lldb/lib/python3.12/token.py +142 -0
  899. package/lldb/lib/python3.12/tokenize.py +586 -0
  900. package/lldb/lib/python3.12/tomllib/__init__.py +10 -0
  901. package/lldb/lib/python3.12/tomllib/_parser.py +691 -0
  902. package/lldb/lib/python3.12/tomllib/_re.py +107 -0
  903. package/lldb/lib/python3.12/tomllib/_types.py +10 -0
  904. package/lldb/lib/python3.12/trace.py +748 -0
  905. package/lldb/lib/python3.12/traceback.py +1187 -0
  906. package/lldb/lib/python3.12/tracemalloc.py +560 -0
  907. package/lldb/lib/python3.12/tty.py +73 -0
  908. package/lldb/lib/python3.12/turtle.py +4207 -0
  909. package/lldb/lib/python3.12/types.py +333 -0
  910. package/lldb/lib/python3.12/typing.py +3489 -0
  911. package/lldb/lib/python3.12/unittest/__init__.py +85 -0
  912. package/lldb/lib/python3.12/unittest/__main__.py +18 -0
  913. package/lldb/lib/python3.12/unittest/_log.py +86 -0
  914. package/lldb/lib/python3.12/unittest/async_case.py +142 -0
  915. package/lldb/lib/python3.12/unittest/case.py +1456 -0
  916. package/lldb/lib/python3.12/unittest/loader.py +497 -0
  917. package/lldb/lib/python3.12/unittest/main.py +291 -0
  918. package/lldb/lib/python3.12/unittest/mock.py +3045 -0
  919. package/lldb/lib/python3.12/unittest/result.py +256 -0
  920. package/lldb/lib/python3.12/unittest/runner.py +292 -0
  921. package/lldb/lib/python3.12/unittest/signals.py +71 -0
  922. package/lldb/lib/python3.12/unittest/suite.py +379 -0
  923. package/lldb/lib/python3.12/unittest/util.py +170 -0
  924. package/lldb/lib/python3.12/urllib/__init__.py +0 -0
  925. package/lldb/lib/python3.12/urllib/error.py +74 -0
  926. package/lldb/lib/python3.12/urllib/parse.py +1246 -0
  927. package/lldb/lib/python3.12/urllib/request.py +2796 -0
  928. package/lldb/lib/python3.12/urllib/response.py +84 -0
  929. package/lldb/lib/python3.12/urllib/robotparser.py +273 -0
  930. package/lldb/lib/python3.12/uu.py +216 -0
  931. package/lldb/lib/python3.12/uuid.py +793 -0
  932. package/lldb/lib/python3.12/warnings.py +598 -0
  933. package/lldb/lib/python3.12/wave.py +653 -0
  934. package/lldb/lib/python3.12/weakref.py +674 -0
  935. package/lldb/lib/python3.12/webbrowser.py +689 -0
  936. package/lldb/lib/python3.12/wsgiref/__init__.py +25 -0
  937. package/lldb/lib/python3.12/wsgiref/handlers.py +573 -0
  938. package/lldb/lib/python3.12/wsgiref/headers.py +184 -0
  939. package/lldb/lib/python3.12/wsgiref/simple_server.py +165 -0
  940. package/lldb/lib/python3.12/wsgiref/types.py +54 -0
  941. package/lldb/lib/python3.12/wsgiref/util.py +159 -0
  942. package/lldb/lib/python3.12/wsgiref/validate.py +438 -0
  943. package/lldb/lib/python3.12/xdrlib.py +242 -0
  944. package/lldb/lib/python3.12/xml/__init__.py +20 -0
  945. package/lldb/lib/python3.12/xml/dom/NodeFilter.py +27 -0
  946. package/lldb/lib/python3.12/xml/dom/__init__.py +140 -0
  947. package/lldb/lib/python3.12/xml/dom/domreg.py +99 -0
  948. package/lldb/lib/python3.12/xml/dom/expatbuilder.py +962 -0
  949. package/lldb/lib/python3.12/xml/dom/minicompat.py +109 -0
  950. package/lldb/lib/python3.12/xml/dom/minidom.py +2013 -0
  951. package/lldb/lib/python3.12/xml/dom/pulldom.py +336 -0
  952. package/lldb/lib/python3.12/xml/dom/xmlbuilder.py +387 -0
  953. package/lldb/lib/python3.12/xml/etree/ElementInclude.py +186 -0
  954. package/lldb/lib/python3.12/xml/etree/ElementPath.py +423 -0
  955. package/lldb/lib/python3.12/xml/etree/ElementTree.py +2085 -0
  956. package/lldb/lib/python3.12/xml/etree/__init__.py +33 -0
  957. package/lldb/lib/python3.12/xml/etree/cElementTree.py +3 -0
  958. package/lldb/lib/python3.12/xml/parsers/__init__.py +8 -0
  959. package/lldb/lib/python3.12/xml/parsers/expat.py +8 -0
  960. package/lldb/lib/python3.12/xml/sax/__init__.py +94 -0
  961. package/lldb/lib/python3.12/xml/sax/_exceptions.py +127 -0
  962. package/lldb/lib/python3.12/xml/sax/expatreader.py +454 -0
  963. package/lldb/lib/python3.12/xml/sax/handler.py +387 -0
  964. package/lldb/lib/python3.12/xml/sax/saxutils.py +369 -0
  965. package/lldb/lib/python3.12/xml/sax/xmlreader.py +378 -0
  966. package/lldb/lib/python3.12/xmlrpc/__init__.py +1 -0
  967. package/lldb/lib/python3.12/xmlrpc/client.py +1529 -0
  968. package/lldb/lib/python3.12/xmlrpc/server.py +1002 -0
  969. package/lldb/lib/python3.12/zipapp.py +206 -0
  970. package/lldb/lib/python3.12/zipfile/__init__.py +2314 -0
  971. package/lldb/lib/python3.12/zipfile/__main__.py +4 -0
  972. package/lldb/lib/python3.12/zipfile/_path/__init__.py +412 -0
  973. package/lldb/lib/python3.12/zipfile/_path/glob.py +53 -0
  974. package/lldb/lib/python3.12/zipimport.py +712 -0
  975. package/lldb/lib/python3.12/zoneinfo/__init__.py +31 -0
  976. package/lldb/lib/python3.12/zoneinfo/_common.py +164 -0
  977. package/lldb/lib/python3.12/zoneinfo/_tzpath.py +181 -0
  978. package/lldb/lib/python3.12/zoneinfo/_zoneinfo.py +772 -0
  979. package/package.json +28 -4
  980. package/version.json +4 -0
@@ -0,0 +1,2672 @@
1
+ # Author: Steven J. Bethard <steven.bethard@gmail.com>.
2
+ # New maintainer as of 29 August 2019: Raymond Hettinger <raymond.hettinger@gmail.com>
3
+
4
+ """Command-line parsing library
5
+
6
+ This module is an optparse-inspired command-line parsing library that:
7
+
8
+ - handles both optional and positional arguments
9
+ - produces highly informative usage messages
10
+ - supports parsers that dispatch to sub-parsers
11
+
12
+ The following is a simple usage example that sums integers from the
13
+ command-line and writes the result to a file::
14
+
15
+ parser = argparse.ArgumentParser(
16
+ description='sum the integers at the command line')
17
+ parser.add_argument(
18
+ 'integers', metavar='int', nargs='+', type=int,
19
+ help='an integer to be summed')
20
+ parser.add_argument(
21
+ '--log', default=sys.stdout, type=argparse.FileType('w'),
22
+ help='the file where the sum should be written')
23
+ args = parser.parse_args()
24
+ args.log.write('%s' % sum(args.integers))
25
+ args.log.close()
26
+
27
+ The module contains the following public classes:
28
+
29
+ - ArgumentParser -- The main entry point for command-line parsing. As the
30
+ example above shows, the add_argument() method is used to populate
31
+ the parser with actions for optional and positional arguments. Then
32
+ the parse_args() method is invoked to convert the args at the
33
+ command-line into an object with attributes.
34
+
35
+ - ArgumentError -- The exception raised by ArgumentParser objects when
36
+ there are errors with the parser's actions. Errors raised while
37
+ parsing the command-line are caught by ArgumentParser and emitted
38
+ as command-line messages.
39
+
40
+ - FileType -- A factory for defining types of files to be created. As the
41
+ example above shows, instances of FileType are typically passed as
42
+ the type= argument of add_argument() calls.
43
+
44
+ - Action -- The base class for parser actions. Typically actions are
45
+ selected by passing strings like 'store_true' or 'append_const' to
46
+ the action= argument of add_argument(). However, for greater
47
+ customization of ArgumentParser actions, subclasses of Action may
48
+ be defined and passed as the action= argument.
49
+
50
+ - HelpFormatter, RawDescriptionHelpFormatter, RawTextHelpFormatter,
51
+ ArgumentDefaultsHelpFormatter -- Formatter classes which
52
+ may be passed as the formatter_class= argument to the
53
+ ArgumentParser constructor. HelpFormatter is the default,
54
+ RawDescriptionHelpFormatter and RawTextHelpFormatter tell the parser
55
+ not to change the formatting for help text, and
56
+ ArgumentDefaultsHelpFormatter adds information about argument defaults
57
+ to the help.
58
+
59
+ All other classes in this module are considered implementation details.
60
+ (Also note that HelpFormatter and RawDescriptionHelpFormatter are only
61
+ considered public as object names -- the API of the formatter objects is
62
+ still considered an implementation detail.)
63
+ """
64
+
65
+ __version__ = '1.1'
66
+ __all__ = [
67
+ 'ArgumentParser',
68
+ 'ArgumentError',
69
+ 'ArgumentTypeError',
70
+ 'BooleanOptionalAction',
71
+ 'FileType',
72
+ 'HelpFormatter',
73
+ 'ArgumentDefaultsHelpFormatter',
74
+ 'RawDescriptionHelpFormatter',
75
+ 'RawTextHelpFormatter',
76
+ 'MetavarTypeHelpFormatter',
77
+ 'Namespace',
78
+ 'Action',
79
+ 'ONE_OR_MORE',
80
+ 'OPTIONAL',
81
+ 'PARSER',
82
+ 'REMAINDER',
83
+ 'SUPPRESS',
84
+ 'ZERO_OR_MORE',
85
+ ]
86
+
87
+
88
+ import os as _os
89
+ import re as _re
90
+ import sys as _sys
91
+
92
+ import warnings
93
+
94
+ from gettext import gettext as _, ngettext
95
+
96
+ SUPPRESS = '==SUPPRESS=='
97
+
98
+ OPTIONAL = '?'
99
+ ZERO_OR_MORE = '*'
100
+ ONE_OR_MORE = '+'
101
+ PARSER = 'A...'
102
+ REMAINDER = '...'
103
+ _UNRECOGNIZED_ARGS_ATTR = '_unrecognized_args'
104
+
105
+ # =============================
106
+ # Utility functions and classes
107
+ # =============================
108
+
109
+ class _AttributeHolder(object):
110
+ """Abstract base class that provides __repr__.
111
+
112
+ The __repr__ method returns a string in the format::
113
+ ClassName(attr=name, attr=name, ...)
114
+ The attributes are determined either by a class-level attribute,
115
+ '_kwarg_names', or by inspecting the instance __dict__.
116
+ """
117
+
118
+ def __repr__(self):
119
+ type_name = type(self).__name__
120
+ arg_strings = []
121
+ star_args = {}
122
+ for arg in self._get_args():
123
+ arg_strings.append(repr(arg))
124
+ for name, value in self._get_kwargs():
125
+ if name.isidentifier():
126
+ arg_strings.append('%s=%r' % (name, value))
127
+ else:
128
+ star_args[name] = value
129
+ if star_args:
130
+ arg_strings.append('**%s' % repr(star_args))
131
+ return '%s(%s)' % (type_name, ', '.join(arg_strings))
132
+
133
+ def _get_kwargs(self):
134
+ return list(self.__dict__.items())
135
+
136
+ def _get_args(self):
137
+ return []
138
+
139
+
140
+ def _copy_items(items):
141
+ if items is None:
142
+ return []
143
+ # The copy module is used only in the 'append' and 'append_const'
144
+ # actions, and it is needed only when the default value isn't a list.
145
+ # Delay its import for speeding up the common case.
146
+ if type(items) is list:
147
+ return items[:]
148
+ import copy
149
+ return copy.copy(items)
150
+
151
+
152
+ # ===============
153
+ # Formatting Help
154
+ # ===============
155
+
156
+
157
+ class HelpFormatter(object):
158
+ """Formatter for generating usage messages and argument help strings.
159
+
160
+ Only the name of this class is considered a public API. All the methods
161
+ provided by the class are considered an implementation detail.
162
+ """
163
+
164
+ def __init__(self,
165
+ prog,
166
+ indent_increment=2,
167
+ max_help_position=24,
168
+ width=None):
169
+
170
+ # default setting for width
171
+ if width is None:
172
+ import shutil
173
+ width = shutil.get_terminal_size().columns
174
+ width -= 2
175
+
176
+ self._prog = prog
177
+ self._indent_increment = indent_increment
178
+ self._max_help_position = min(max_help_position,
179
+ max(width - 20, indent_increment * 2))
180
+ self._width = width
181
+
182
+ self._current_indent = 0
183
+ self._level = 0
184
+ self._action_max_length = 0
185
+
186
+ self._root_section = self._Section(self, None)
187
+ self._current_section = self._root_section
188
+
189
+ self._whitespace_matcher = _re.compile(r'\s+', _re.ASCII)
190
+ self._long_break_matcher = _re.compile(r'\n\n\n+')
191
+
192
+ # ===============================
193
+ # Section and indentation methods
194
+ # ===============================
195
+ def _indent(self):
196
+ self._current_indent += self._indent_increment
197
+ self._level += 1
198
+
199
+ def _dedent(self):
200
+ self._current_indent -= self._indent_increment
201
+ assert self._current_indent >= 0, 'Indent decreased below 0.'
202
+ self._level -= 1
203
+
204
+ class _Section(object):
205
+
206
+ def __init__(self, formatter, parent, heading=None):
207
+ self.formatter = formatter
208
+ self.parent = parent
209
+ self.heading = heading
210
+ self.items = []
211
+
212
+ def format_help(self):
213
+ # format the indented section
214
+ if self.parent is not None:
215
+ self.formatter._indent()
216
+ join = self.formatter._join_parts
217
+ item_help = join([func(*args) for func, args in self.items])
218
+ if self.parent is not None:
219
+ self.formatter._dedent()
220
+
221
+ # return nothing if the section was empty
222
+ if not item_help:
223
+ return ''
224
+
225
+ # add the heading if the section was non-empty
226
+ if self.heading is not SUPPRESS and self.heading is not None:
227
+ current_indent = self.formatter._current_indent
228
+ heading_text = _('%(heading)s:') % dict(heading=self.heading)
229
+ heading = '%*s%s\n' % (current_indent, '', heading_text)
230
+ else:
231
+ heading = ''
232
+
233
+ # join the section-initial newline, the heading and the help
234
+ return join(['\n', heading, item_help, '\n'])
235
+
236
+ def _add_item(self, func, args):
237
+ self._current_section.items.append((func, args))
238
+
239
+ # ========================
240
+ # Message building methods
241
+ # ========================
242
+ def start_section(self, heading):
243
+ self._indent()
244
+ section = self._Section(self, self._current_section, heading)
245
+ self._add_item(section.format_help, [])
246
+ self._current_section = section
247
+
248
+ def end_section(self):
249
+ self._current_section = self._current_section.parent
250
+ self._dedent()
251
+
252
+ def add_text(self, text):
253
+ if text is not SUPPRESS and text is not None:
254
+ self._add_item(self._format_text, [text])
255
+
256
+ def add_usage(self, usage, actions, groups, prefix=None):
257
+ if usage is not SUPPRESS:
258
+ args = usage, actions, groups, prefix
259
+ self._add_item(self._format_usage, args)
260
+
261
+ def add_argument(self, action):
262
+ if action.help is not SUPPRESS:
263
+
264
+ # find all invocations
265
+ get_invocation = self._format_action_invocation
266
+ invocation_lengths = [len(get_invocation(action)) + self._current_indent]
267
+ for subaction in self._iter_indented_subactions(action):
268
+ invocation_lengths.append(len(get_invocation(subaction)) + self._current_indent)
269
+
270
+ # update the maximum item length
271
+ action_length = max(invocation_lengths)
272
+ self._action_max_length = max(self._action_max_length,
273
+ action_length)
274
+
275
+ # add the item to the list
276
+ self._add_item(self._format_action, [action])
277
+
278
+ def add_arguments(self, actions):
279
+ for action in actions:
280
+ self.add_argument(action)
281
+
282
+ # =======================
283
+ # Help-formatting methods
284
+ # =======================
285
+ def format_help(self):
286
+ help = self._root_section.format_help()
287
+ if help:
288
+ help = self._long_break_matcher.sub('\n\n', help)
289
+ help = help.strip('\n') + '\n'
290
+ return help
291
+
292
+ def _join_parts(self, part_strings):
293
+ return ''.join([part
294
+ for part in part_strings
295
+ if part and part is not SUPPRESS])
296
+
297
+ def _format_usage(self, usage, actions, groups, prefix):
298
+ if prefix is None:
299
+ prefix = _('usage: ')
300
+
301
+ # if usage is specified, use that
302
+ if usage is not None:
303
+ usage = usage % dict(prog=self._prog)
304
+
305
+ # if no optionals or positionals are available, usage is just prog
306
+ elif usage is None and not actions:
307
+ usage = '%(prog)s' % dict(prog=self._prog)
308
+
309
+ # if optionals and positionals are available, calculate usage
310
+ elif usage is None:
311
+ prog = '%(prog)s' % dict(prog=self._prog)
312
+
313
+ # split optionals from positionals
314
+ optionals = []
315
+ positionals = []
316
+ for action in actions:
317
+ if action.option_strings:
318
+ optionals.append(action)
319
+ else:
320
+ positionals.append(action)
321
+
322
+ # build full usage string
323
+ format = self._format_actions_usage
324
+ action_usage = format(optionals + positionals, groups)
325
+ usage = ' '.join([s for s in [prog, action_usage] if s])
326
+
327
+ # wrap the usage parts if it's too long
328
+ text_width = self._width - self._current_indent
329
+ if len(prefix) + len(usage) > text_width:
330
+
331
+ # break usage into wrappable parts
332
+ part_regexp = (
333
+ r'\(.*?\)+(?=\s|$)|'
334
+ r'\[.*?\]+(?=\s|$)|'
335
+ r'\S+'
336
+ )
337
+ opt_usage = format(optionals, groups)
338
+ pos_usage = format(positionals, groups)
339
+ opt_parts = _re.findall(part_regexp, opt_usage)
340
+ pos_parts = _re.findall(part_regexp, pos_usage)
341
+ assert ' '.join(opt_parts) == opt_usage
342
+ assert ' '.join(pos_parts) == pos_usage
343
+
344
+ # helper for wrapping lines
345
+ def get_lines(parts, indent, prefix=None):
346
+ lines = []
347
+ line = []
348
+ indent_length = len(indent)
349
+ if prefix is not None:
350
+ line_len = len(prefix) - 1
351
+ else:
352
+ line_len = indent_length - 1
353
+ for part in parts:
354
+ if line_len + 1 + len(part) > text_width and line:
355
+ lines.append(indent + ' '.join(line))
356
+ line = []
357
+ line_len = indent_length - 1
358
+ line.append(part)
359
+ line_len += len(part) + 1
360
+ if line:
361
+ lines.append(indent + ' '.join(line))
362
+ if prefix is not None:
363
+ lines[0] = lines[0][indent_length:]
364
+ return lines
365
+
366
+ # if prog is short, follow it with optionals or positionals
367
+ if len(prefix) + len(prog) <= 0.75 * text_width:
368
+ indent = ' ' * (len(prefix) + len(prog) + 1)
369
+ if opt_parts:
370
+ lines = get_lines([prog] + opt_parts, indent, prefix)
371
+ lines.extend(get_lines(pos_parts, indent))
372
+ elif pos_parts:
373
+ lines = get_lines([prog] + pos_parts, indent, prefix)
374
+ else:
375
+ lines = [prog]
376
+
377
+ # if prog is long, put it on its own line
378
+ else:
379
+ indent = ' ' * len(prefix)
380
+ parts = opt_parts + pos_parts
381
+ lines = get_lines(parts, indent)
382
+ if len(lines) > 1:
383
+ lines = []
384
+ lines.extend(get_lines(opt_parts, indent))
385
+ lines.extend(get_lines(pos_parts, indent))
386
+ lines = [prog] + lines
387
+
388
+ # join lines into usage
389
+ usage = '\n'.join(lines)
390
+
391
+ # prefix with 'usage:'
392
+ return '%s%s\n\n' % (prefix, usage)
393
+
394
+ def _format_actions_usage(self, actions, groups):
395
+ # find group indices and identify actions in groups
396
+ group_actions = set()
397
+ inserts = {}
398
+ for group in groups:
399
+ if not group._group_actions:
400
+ raise ValueError(f'empty group {group}')
401
+
402
+ try:
403
+ start = actions.index(group._group_actions[0])
404
+ except ValueError:
405
+ continue
406
+ else:
407
+ group_action_count = len(group._group_actions)
408
+ end = start + group_action_count
409
+ if actions[start:end] == group._group_actions:
410
+
411
+ suppressed_actions_count = 0
412
+ for action in group._group_actions:
413
+ group_actions.add(action)
414
+ if action.help is SUPPRESS:
415
+ suppressed_actions_count += 1
416
+
417
+ exposed_actions_count = group_action_count - suppressed_actions_count
418
+ if not exposed_actions_count:
419
+ continue
420
+
421
+ if not group.required:
422
+ if start in inserts:
423
+ inserts[start] += ' ['
424
+ else:
425
+ inserts[start] = '['
426
+ if end in inserts:
427
+ inserts[end] += ']'
428
+ else:
429
+ inserts[end] = ']'
430
+ elif exposed_actions_count > 1:
431
+ if start in inserts:
432
+ inserts[start] += ' ('
433
+ else:
434
+ inserts[start] = '('
435
+ if end in inserts:
436
+ inserts[end] += ')'
437
+ else:
438
+ inserts[end] = ')'
439
+ for i in range(start + 1, end):
440
+ inserts[i] = '|'
441
+
442
+ # collect all actions format strings
443
+ parts = []
444
+ for i, action in enumerate(actions):
445
+
446
+ # suppressed arguments are marked with None
447
+ # remove | separators for suppressed arguments
448
+ if action.help is SUPPRESS:
449
+ parts.append(None)
450
+ if inserts.get(i) == '|':
451
+ inserts.pop(i)
452
+ elif inserts.get(i + 1) == '|':
453
+ inserts.pop(i + 1)
454
+
455
+ # produce all arg strings
456
+ elif not action.option_strings:
457
+ default = self._get_default_metavar_for_positional(action)
458
+ part = self._format_args(action, default)
459
+
460
+ # if it's in a group, strip the outer []
461
+ if action in group_actions:
462
+ if part[0] == '[' and part[-1] == ']':
463
+ part = part[1:-1]
464
+
465
+ # add the action string to the list
466
+ parts.append(part)
467
+
468
+ # produce the first way to invoke the option in brackets
469
+ else:
470
+ option_string = action.option_strings[0]
471
+
472
+ # if the Optional doesn't take a value, format is:
473
+ # -s or --long
474
+ if action.nargs == 0:
475
+ part = action.format_usage()
476
+
477
+ # if the Optional takes a value, format is:
478
+ # -s ARGS or --long ARGS
479
+ else:
480
+ default = self._get_default_metavar_for_optional(action)
481
+ args_string = self._format_args(action, default)
482
+ part = '%s %s' % (option_string, args_string)
483
+
484
+ # make it look optional if it's not required or in a group
485
+ if not action.required and action not in group_actions:
486
+ part = '[%s]' % part
487
+
488
+ # add the action string to the list
489
+ parts.append(part)
490
+
491
+ # insert things at the necessary indices
492
+ for i in sorted(inserts, reverse=True):
493
+ parts[i:i] = [inserts[i]]
494
+
495
+ # join all the action items with spaces
496
+ text = ' '.join([item for item in parts if item is not None])
497
+
498
+ # clean up separators for mutually exclusive groups
499
+ open = r'[\[(]'
500
+ close = r'[\])]'
501
+ text = _re.sub(r'(%s) ' % open, r'\1', text)
502
+ text = _re.sub(r' (%s)' % close, r'\1', text)
503
+ text = _re.sub(r'%s *%s' % (open, close), r'', text)
504
+ text = text.strip()
505
+
506
+ # return the text
507
+ return text
508
+
509
+ def _format_text(self, text):
510
+ if '%(prog)' in text:
511
+ text = text % dict(prog=self._prog)
512
+ text_width = max(self._width - self._current_indent, 11)
513
+ indent = ' ' * self._current_indent
514
+ return self._fill_text(text, text_width, indent) + '\n\n'
515
+
516
+ def _format_action(self, action):
517
+ # determine the required width and the entry label
518
+ help_position = min(self._action_max_length + 2,
519
+ self._max_help_position)
520
+ help_width = max(self._width - help_position, 11)
521
+ action_width = help_position - self._current_indent - 2
522
+ action_header = self._format_action_invocation(action)
523
+
524
+ # no help; start on same line and add a final newline
525
+ if not action.help:
526
+ tup = self._current_indent, '', action_header
527
+ action_header = '%*s%s\n' % tup
528
+
529
+ # short action name; start on the same line and pad two spaces
530
+ elif len(action_header) <= action_width:
531
+ tup = self._current_indent, '', action_width, action_header
532
+ action_header = '%*s%-*s ' % tup
533
+ indent_first = 0
534
+
535
+ # long action name; start on the next line
536
+ else:
537
+ tup = self._current_indent, '', action_header
538
+ action_header = '%*s%s\n' % tup
539
+ indent_first = help_position
540
+
541
+ # collect the pieces of the action help
542
+ parts = [action_header]
543
+
544
+ # if there was help for the action, add lines of help text
545
+ if action.help and action.help.strip():
546
+ help_text = self._expand_help(action)
547
+ if help_text:
548
+ help_lines = self._split_lines(help_text, help_width)
549
+ parts.append('%*s%s\n' % (indent_first, '', help_lines[0]))
550
+ for line in help_lines[1:]:
551
+ parts.append('%*s%s\n' % (help_position, '', line))
552
+
553
+ # or add a newline if the description doesn't end with one
554
+ elif not action_header.endswith('\n'):
555
+ parts.append('\n')
556
+
557
+ # if there are any sub-actions, add their help as well
558
+ for subaction in self._iter_indented_subactions(action):
559
+ parts.append(self._format_action(subaction))
560
+
561
+ # return a single string
562
+ return self._join_parts(parts)
563
+
564
+ def _format_action_invocation(self, action):
565
+ if not action.option_strings:
566
+ default = self._get_default_metavar_for_positional(action)
567
+ metavar, = self._metavar_formatter(action, default)(1)
568
+ return metavar
569
+
570
+ else:
571
+ parts = []
572
+
573
+ # if the Optional doesn't take a value, format is:
574
+ # -s, --long
575
+ if action.nargs == 0:
576
+ parts.extend(action.option_strings)
577
+
578
+ # if the Optional takes a value, format is:
579
+ # -s ARGS, --long ARGS
580
+ else:
581
+ default = self._get_default_metavar_for_optional(action)
582
+ args_string = self._format_args(action, default)
583
+ for option_string in action.option_strings:
584
+ parts.append('%s %s' % (option_string, args_string))
585
+
586
+ return ', '.join(parts)
587
+
588
+ def _metavar_formatter(self, action, default_metavar):
589
+ if action.metavar is not None:
590
+ result = action.metavar
591
+ elif action.choices is not None:
592
+ choice_strs = [str(choice) for choice in action.choices]
593
+ result = '{%s}' % ','.join(choice_strs)
594
+ else:
595
+ result = default_metavar
596
+
597
+ def format(tuple_size):
598
+ if isinstance(result, tuple):
599
+ return result
600
+ else:
601
+ return (result, ) * tuple_size
602
+ return format
603
+
604
+ def _format_args(self, action, default_metavar):
605
+ get_metavar = self._metavar_formatter(action, default_metavar)
606
+ if action.nargs is None:
607
+ result = '%s' % get_metavar(1)
608
+ elif action.nargs == OPTIONAL:
609
+ result = '[%s]' % get_metavar(1)
610
+ elif action.nargs == ZERO_OR_MORE:
611
+ metavar = get_metavar(1)
612
+ if len(metavar) == 2:
613
+ result = '[%s [%s ...]]' % metavar
614
+ else:
615
+ result = '[%s ...]' % metavar
616
+ elif action.nargs == ONE_OR_MORE:
617
+ result = '%s [%s ...]' % get_metavar(2)
618
+ elif action.nargs == REMAINDER:
619
+ result = '...'
620
+ elif action.nargs == PARSER:
621
+ result = '%s ...' % get_metavar(1)
622
+ elif action.nargs == SUPPRESS:
623
+ result = ''
624
+ else:
625
+ try:
626
+ formats = ['%s' for _ in range(action.nargs)]
627
+ except TypeError:
628
+ raise ValueError("invalid nargs value") from None
629
+ result = ' '.join(formats) % get_metavar(action.nargs)
630
+ return result
631
+
632
+ def _expand_help(self, action):
633
+ params = dict(vars(action), prog=self._prog)
634
+ for name in list(params):
635
+ if params[name] is SUPPRESS:
636
+ del params[name]
637
+ for name in list(params):
638
+ if hasattr(params[name], '__name__'):
639
+ params[name] = params[name].__name__
640
+ if params.get('choices') is not None:
641
+ choices_str = ', '.join([str(c) for c in params['choices']])
642
+ params['choices'] = choices_str
643
+ return self._get_help_string(action) % params
644
+
645
+ def _iter_indented_subactions(self, action):
646
+ try:
647
+ get_subactions = action._get_subactions
648
+ except AttributeError:
649
+ pass
650
+ else:
651
+ self._indent()
652
+ yield from get_subactions()
653
+ self._dedent()
654
+
655
+ def _split_lines(self, text, width):
656
+ text = self._whitespace_matcher.sub(' ', text).strip()
657
+ # The textwrap module is used only for formatting help.
658
+ # Delay its import for speeding up the common usage of argparse.
659
+ import textwrap
660
+ return textwrap.wrap(text, width)
661
+
662
+ def _fill_text(self, text, width, indent):
663
+ text = self._whitespace_matcher.sub(' ', text).strip()
664
+ import textwrap
665
+ return textwrap.fill(text, width,
666
+ initial_indent=indent,
667
+ subsequent_indent=indent)
668
+
669
+ def _get_help_string(self, action):
670
+ return action.help
671
+
672
+ def _get_default_metavar_for_optional(self, action):
673
+ return action.dest.upper()
674
+
675
+ def _get_default_metavar_for_positional(self, action):
676
+ return action.dest
677
+
678
+
679
+ class RawDescriptionHelpFormatter(HelpFormatter):
680
+ """Help message formatter which retains any formatting in descriptions.
681
+
682
+ Only the name of this class is considered a public API. All the methods
683
+ provided by the class are considered an implementation detail.
684
+ """
685
+
686
+ def _fill_text(self, text, width, indent):
687
+ return ''.join(indent + line for line in text.splitlines(keepends=True))
688
+
689
+
690
+ class RawTextHelpFormatter(RawDescriptionHelpFormatter):
691
+ """Help message formatter which retains formatting of all help text.
692
+
693
+ Only the name of this class is considered a public API. All the methods
694
+ provided by the class are considered an implementation detail.
695
+ """
696
+
697
+ def _split_lines(self, text, width):
698
+ return text.splitlines()
699
+
700
+
701
+ class ArgumentDefaultsHelpFormatter(HelpFormatter):
702
+ """Help message formatter which adds default values to argument help.
703
+
704
+ Only the name of this class is considered a public API. All the methods
705
+ provided by the class are considered an implementation detail.
706
+ """
707
+
708
+ def _get_help_string(self, action):
709
+ """
710
+ Add the default value to the option help message.
711
+
712
+ ArgumentDefaultsHelpFormatter and BooleanOptionalAction when it isn't
713
+ already present. This code will do that, detecting cornercases to
714
+ prevent duplicates or cases where it wouldn't make sense to the end
715
+ user.
716
+ """
717
+ help = action.help
718
+ if help is None:
719
+ help = ''
720
+
721
+ if '%(default)' not in help:
722
+ if action.default is not SUPPRESS:
723
+ defaulting_nargs = [OPTIONAL, ZERO_OR_MORE]
724
+ if action.option_strings or action.nargs in defaulting_nargs:
725
+ help += _(' (default: %(default)s)')
726
+ return help
727
+
728
+
729
+
730
+ class MetavarTypeHelpFormatter(HelpFormatter):
731
+ """Help message formatter which uses the argument 'type' as the default
732
+ metavar value (instead of the argument 'dest')
733
+
734
+ Only the name of this class is considered a public API. All the methods
735
+ provided by the class are considered an implementation detail.
736
+ """
737
+
738
+ def _get_default_metavar_for_optional(self, action):
739
+ return action.type.__name__
740
+
741
+ def _get_default_metavar_for_positional(self, action):
742
+ return action.type.__name__
743
+
744
+
745
+ # =====================
746
+ # Options and Arguments
747
+ # =====================
748
+
749
+ def _get_action_name(argument):
750
+ if argument is None:
751
+ return None
752
+ elif argument.option_strings:
753
+ return '/'.join(argument.option_strings)
754
+ elif argument.metavar not in (None, SUPPRESS):
755
+ return argument.metavar
756
+ elif argument.dest not in (None, SUPPRESS):
757
+ return argument.dest
758
+ elif argument.choices:
759
+ return '{' + ','.join(argument.choices) + '}'
760
+ else:
761
+ return None
762
+
763
+
764
+ class ArgumentError(Exception):
765
+ """An error from creating or using an argument (optional or positional).
766
+
767
+ The string value of this exception is the message, augmented with
768
+ information about the argument that caused it.
769
+ """
770
+
771
+ def __init__(self, argument, message):
772
+ self.argument_name = _get_action_name(argument)
773
+ self.message = message
774
+
775
+ def __str__(self):
776
+ if self.argument_name is None:
777
+ format = '%(message)s'
778
+ else:
779
+ format = _('argument %(argument_name)s: %(message)s')
780
+ return format % dict(message=self.message,
781
+ argument_name=self.argument_name)
782
+
783
+
784
+ class ArgumentTypeError(Exception):
785
+ """An error from trying to convert a command line string to a type."""
786
+ pass
787
+
788
+
789
+ # ==============
790
+ # Action classes
791
+ # ==============
792
+
793
+ class Action(_AttributeHolder):
794
+ """Information about how to convert command line strings to Python objects.
795
+
796
+ Action objects are used by an ArgumentParser to represent the information
797
+ needed to parse a single argument from one or more strings from the
798
+ command line. The keyword arguments to the Action constructor are also
799
+ all attributes of Action instances.
800
+
801
+ Keyword Arguments:
802
+
803
+ - option_strings -- A list of command-line option strings which
804
+ should be associated with this action.
805
+
806
+ - dest -- The name of the attribute to hold the created object(s)
807
+
808
+ - nargs -- The number of command-line arguments that should be
809
+ consumed. By default, one argument will be consumed and a single
810
+ value will be produced. Other values include:
811
+ - N (an integer) consumes N arguments (and produces a list)
812
+ - '?' consumes zero or one arguments
813
+ - '*' consumes zero or more arguments (and produces a list)
814
+ - '+' consumes one or more arguments (and produces a list)
815
+ Note that the difference between the default and nargs=1 is that
816
+ with the default, a single value will be produced, while with
817
+ nargs=1, a list containing a single value will be produced.
818
+
819
+ - const -- The value to be produced if the option is specified and the
820
+ option uses an action that takes no values.
821
+
822
+ - default -- The value to be produced if the option is not specified.
823
+
824
+ - type -- A callable that accepts a single string argument, and
825
+ returns the converted value. The standard Python types str, int,
826
+ float, and complex are useful examples of such callables. If None,
827
+ str is used.
828
+
829
+ - choices -- A container of values that should be allowed. If not None,
830
+ after a command-line argument has been converted to the appropriate
831
+ type, an exception will be raised if it is not a member of this
832
+ collection.
833
+
834
+ - required -- True if the action must always be specified at the
835
+ command line. This is only meaningful for optional command-line
836
+ arguments.
837
+
838
+ - help -- The help string describing the argument.
839
+
840
+ - metavar -- The name to be used for the option's argument with the
841
+ help string. If None, the 'dest' value will be used as the name.
842
+ """
843
+
844
+ def __init__(self,
845
+ option_strings,
846
+ dest,
847
+ nargs=None,
848
+ const=None,
849
+ default=None,
850
+ type=None,
851
+ choices=None,
852
+ required=False,
853
+ help=None,
854
+ metavar=None):
855
+ self.option_strings = option_strings
856
+ self.dest = dest
857
+ self.nargs = nargs
858
+ self.const = const
859
+ self.default = default
860
+ self.type = type
861
+ self.choices = choices
862
+ self.required = required
863
+ self.help = help
864
+ self.metavar = metavar
865
+
866
+ def _get_kwargs(self):
867
+ names = [
868
+ 'option_strings',
869
+ 'dest',
870
+ 'nargs',
871
+ 'const',
872
+ 'default',
873
+ 'type',
874
+ 'choices',
875
+ 'required',
876
+ 'help',
877
+ 'metavar',
878
+ ]
879
+ return [(name, getattr(self, name)) for name in names]
880
+
881
+ def format_usage(self):
882
+ return self.option_strings[0]
883
+
884
+ def __call__(self, parser, namespace, values, option_string=None):
885
+ raise NotImplementedError(_('.__call__() not defined'))
886
+
887
+
888
+ # FIXME: remove together with `BooleanOptionalAction` deprecated arguments.
889
+ _deprecated_default = object()
890
+
891
+ class BooleanOptionalAction(Action):
892
+ def __init__(self,
893
+ option_strings,
894
+ dest,
895
+ default=None,
896
+ type=_deprecated_default,
897
+ choices=_deprecated_default,
898
+ required=False,
899
+ help=None,
900
+ metavar=_deprecated_default):
901
+
902
+ _option_strings = []
903
+ for option_string in option_strings:
904
+ _option_strings.append(option_string)
905
+
906
+ if option_string.startswith('--'):
907
+ option_string = '--no-' + option_string[2:]
908
+ _option_strings.append(option_string)
909
+
910
+ # We need `_deprecated` special value to ban explicit arguments that
911
+ # match default value. Like:
912
+ # parser.add_argument('-f', action=BooleanOptionalAction, type=int)
913
+ for field_name in ('type', 'choices', 'metavar'):
914
+ if locals()[field_name] is not _deprecated_default:
915
+ warnings._deprecated(
916
+ field_name,
917
+ "{name!r} is deprecated as of Python 3.12 and will be "
918
+ "removed in Python {remove}.",
919
+ remove=(3, 14))
920
+
921
+ if type is _deprecated_default:
922
+ type = None
923
+ if choices is _deprecated_default:
924
+ choices = None
925
+ if metavar is _deprecated_default:
926
+ metavar = None
927
+
928
+ super().__init__(
929
+ option_strings=_option_strings,
930
+ dest=dest,
931
+ nargs=0,
932
+ default=default,
933
+ type=type,
934
+ choices=choices,
935
+ required=required,
936
+ help=help,
937
+ metavar=metavar)
938
+
939
+
940
+ def __call__(self, parser, namespace, values, option_string=None):
941
+ if option_string in self.option_strings:
942
+ setattr(namespace, self.dest, not option_string.startswith('--no-'))
943
+
944
+ def format_usage(self):
945
+ return ' | '.join(self.option_strings)
946
+
947
+
948
+ class _StoreAction(Action):
949
+
950
+ def __init__(self,
951
+ option_strings,
952
+ dest,
953
+ nargs=None,
954
+ const=None,
955
+ default=None,
956
+ type=None,
957
+ choices=None,
958
+ required=False,
959
+ help=None,
960
+ metavar=None):
961
+ if nargs == 0:
962
+ raise ValueError('nargs for store actions must be != 0; if you '
963
+ 'have nothing to store, actions such as store '
964
+ 'true or store const may be more appropriate')
965
+ if const is not None and nargs != OPTIONAL:
966
+ raise ValueError('nargs must be %r to supply const' % OPTIONAL)
967
+ super(_StoreAction, self).__init__(
968
+ option_strings=option_strings,
969
+ dest=dest,
970
+ nargs=nargs,
971
+ const=const,
972
+ default=default,
973
+ type=type,
974
+ choices=choices,
975
+ required=required,
976
+ help=help,
977
+ metavar=metavar)
978
+
979
+ def __call__(self, parser, namespace, values, option_string=None):
980
+ setattr(namespace, self.dest, values)
981
+
982
+
983
+ class _StoreConstAction(Action):
984
+
985
+ def __init__(self,
986
+ option_strings,
987
+ dest,
988
+ const=None,
989
+ default=None,
990
+ required=False,
991
+ help=None,
992
+ metavar=None):
993
+ super(_StoreConstAction, self).__init__(
994
+ option_strings=option_strings,
995
+ dest=dest,
996
+ nargs=0,
997
+ const=const,
998
+ default=default,
999
+ required=required,
1000
+ help=help)
1001
+
1002
+ def __call__(self, parser, namespace, values, option_string=None):
1003
+ setattr(namespace, self.dest, self.const)
1004
+
1005
+
1006
+ class _StoreTrueAction(_StoreConstAction):
1007
+
1008
+ def __init__(self,
1009
+ option_strings,
1010
+ dest,
1011
+ default=False,
1012
+ required=False,
1013
+ help=None):
1014
+ super(_StoreTrueAction, self).__init__(
1015
+ option_strings=option_strings,
1016
+ dest=dest,
1017
+ const=True,
1018
+ default=default,
1019
+ required=required,
1020
+ help=help)
1021
+
1022
+
1023
+ class _StoreFalseAction(_StoreConstAction):
1024
+
1025
+ def __init__(self,
1026
+ option_strings,
1027
+ dest,
1028
+ default=True,
1029
+ required=False,
1030
+ help=None):
1031
+ super(_StoreFalseAction, self).__init__(
1032
+ option_strings=option_strings,
1033
+ dest=dest,
1034
+ const=False,
1035
+ default=default,
1036
+ required=required,
1037
+ help=help)
1038
+
1039
+
1040
+ class _AppendAction(Action):
1041
+
1042
+ def __init__(self,
1043
+ option_strings,
1044
+ dest,
1045
+ nargs=None,
1046
+ const=None,
1047
+ default=None,
1048
+ type=None,
1049
+ choices=None,
1050
+ required=False,
1051
+ help=None,
1052
+ metavar=None):
1053
+ if nargs == 0:
1054
+ raise ValueError('nargs for append actions must be != 0; if arg '
1055
+ 'strings are not supplying the value to append, '
1056
+ 'the append const action may be more appropriate')
1057
+ if const is not None and nargs != OPTIONAL:
1058
+ raise ValueError('nargs must be %r to supply const' % OPTIONAL)
1059
+ super(_AppendAction, self).__init__(
1060
+ option_strings=option_strings,
1061
+ dest=dest,
1062
+ nargs=nargs,
1063
+ const=const,
1064
+ default=default,
1065
+ type=type,
1066
+ choices=choices,
1067
+ required=required,
1068
+ help=help,
1069
+ metavar=metavar)
1070
+
1071
+ def __call__(self, parser, namespace, values, option_string=None):
1072
+ items = getattr(namespace, self.dest, None)
1073
+ items = _copy_items(items)
1074
+ items.append(values)
1075
+ setattr(namespace, self.dest, items)
1076
+
1077
+
1078
+ class _AppendConstAction(Action):
1079
+
1080
+ def __init__(self,
1081
+ option_strings,
1082
+ dest,
1083
+ const=None,
1084
+ default=None,
1085
+ required=False,
1086
+ help=None,
1087
+ metavar=None):
1088
+ super(_AppendConstAction, self).__init__(
1089
+ option_strings=option_strings,
1090
+ dest=dest,
1091
+ nargs=0,
1092
+ const=const,
1093
+ default=default,
1094
+ required=required,
1095
+ help=help,
1096
+ metavar=metavar)
1097
+
1098
+ def __call__(self, parser, namespace, values, option_string=None):
1099
+ items = getattr(namespace, self.dest, None)
1100
+ items = _copy_items(items)
1101
+ items.append(self.const)
1102
+ setattr(namespace, self.dest, items)
1103
+
1104
+
1105
+ class _CountAction(Action):
1106
+
1107
+ def __init__(self,
1108
+ option_strings,
1109
+ dest,
1110
+ default=None,
1111
+ required=False,
1112
+ help=None):
1113
+ super(_CountAction, self).__init__(
1114
+ option_strings=option_strings,
1115
+ dest=dest,
1116
+ nargs=0,
1117
+ default=default,
1118
+ required=required,
1119
+ help=help)
1120
+
1121
+ def __call__(self, parser, namespace, values, option_string=None):
1122
+ count = getattr(namespace, self.dest, None)
1123
+ if count is None:
1124
+ count = 0
1125
+ setattr(namespace, self.dest, count + 1)
1126
+
1127
+
1128
+ class _HelpAction(Action):
1129
+
1130
+ def __init__(self,
1131
+ option_strings,
1132
+ dest=SUPPRESS,
1133
+ default=SUPPRESS,
1134
+ help=None):
1135
+ super(_HelpAction, self).__init__(
1136
+ option_strings=option_strings,
1137
+ dest=dest,
1138
+ default=default,
1139
+ nargs=0,
1140
+ help=help)
1141
+
1142
+ def __call__(self, parser, namespace, values, option_string=None):
1143
+ parser.print_help()
1144
+ parser.exit()
1145
+
1146
+
1147
+ class _VersionAction(Action):
1148
+
1149
+ def __init__(self,
1150
+ option_strings,
1151
+ version=None,
1152
+ dest=SUPPRESS,
1153
+ default=SUPPRESS,
1154
+ help=None):
1155
+ if help is None:
1156
+ help = _("show program's version number and exit")
1157
+ super(_VersionAction, self).__init__(
1158
+ option_strings=option_strings,
1159
+ dest=dest,
1160
+ default=default,
1161
+ nargs=0,
1162
+ help=help)
1163
+ self.version = version
1164
+
1165
+ def __call__(self, parser, namespace, values, option_string=None):
1166
+ version = self.version
1167
+ if version is None:
1168
+ version = parser.version
1169
+ formatter = parser._get_formatter()
1170
+ formatter.add_text(version)
1171
+ parser._print_message(formatter.format_help(), _sys.stdout)
1172
+ parser.exit()
1173
+
1174
+
1175
+ class _SubParsersAction(Action):
1176
+
1177
+ class _ChoicesPseudoAction(Action):
1178
+
1179
+ def __init__(self, name, aliases, help):
1180
+ metavar = dest = name
1181
+ if aliases:
1182
+ metavar += ' (%s)' % ', '.join(aliases)
1183
+ sup = super(_SubParsersAction._ChoicesPseudoAction, self)
1184
+ sup.__init__(option_strings=[], dest=dest, help=help,
1185
+ metavar=metavar)
1186
+
1187
+ def __init__(self,
1188
+ option_strings,
1189
+ prog,
1190
+ parser_class,
1191
+ dest=SUPPRESS,
1192
+ required=False,
1193
+ help=None,
1194
+ metavar=None):
1195
+
1196
+ self._prog_prefix = prog
1197
+ self._parser_class = parser_class
1198
+ self._name_parser_map = {}
1199
+ self._choices_actions = []
1200
+
1201
+ super(_SubParsersAction, self).__init__(
1202
+ option_strings=option_strings,
1203
+ dest=dest,
1204
+ nargs=PARSER,
1205
+ choices=self._name_parser_map,
1206
+ required=required,
1207
+ help=help,
1208
+ metavar=metavar)
1209
+
1210
+ def add_parser(self, name, **kwargs):
1211
+ # set prog from the existing prefix
1212
+ if kwargs.get('prog') is None:
1213
+ kwargs['prog'] = '%s %s' % (self._prog_prefix, name)
1214
+
1215
+ aliases = kwargs.pop('aliases', ())
1216
+
1217
+ if name in self._name_parser_map:
1218
+ raise ArgumentError(self, _('conflicting subparser: %s') % name)
1219
+ for alias in aliases:
1220
+ if alias in self._name_parser_map:
1221
+ raise ArgumentError(
1222
+ self, _('conflicting subparser alias: %s') % alias)
1223
+
1224
+ # create a pseudo-action to hold the choice help
1225
+ if 'help' in kwargs:
1226
+ help = kwargs.pop('help')
1227
+ choice_action = self._ChoicesPseudoAction(name, aliases, help)
1228
+ self._choices_actions.append(choice_action)
1229
+
1230
+ # create the parser and add it to the map
1231
+ parser = self._parser_class(**kwargs)
1232
+ self._name_parser_map[name] = parser
1233
+
1234
+ # make parser available under aliases also
1235
+ for alias in aliases:
1236
+ self._name_parser_map[alias] = parser
1237
+
1238
+ return parser
1239
+
1240
+ def _get_subactions(self):
1241
+ return self._choices_actions
1242
+
1243
+ def __call__(self, parser, namespace, values, option_string=None):
1244
+ parser_name = values[0]
1245
+ arg_strings = values[1:]
1246
+
1247
+ # set the parser name if requested
1248
+ if self.dest is not SUPPRESS:
1249
+ setattr(namespace, self.dest, parser_name)
1250
+
1251
+ # select the parser
1252
+ try:
1253
+ parser = self._name_parser_map[parser_name]
1254
+ except KeyError:
1255
+ args = {'parser_name': parser_name,
1256
+ 'choices': ', '.join(self._name_parser_map)}
1257
+ msg = _('unknown parser %(parser_name)r (choices: %(choices)s)') % args
1258
+ raise ArgumentError(self, msg)
1259
+
1260
+ # parse all the remaining options into the namespace
1261
+ # store any unrecognized options on the object, so that the top
1262
+ # level parser can decide what to do with them
1263
+
1264
+ # In case this subparser defines new defaults, we parse them
1265
+ # in a new namespace object and then update the original
1266
+ # namespace for the relevant parts.
1267
+ subnamespace, arg_strings = parser.parse_known_args(arg_strings, None)
1268
+ for key, value in vars(subnamespace).items():
1269
+ setattr(namespace, key, value)
1270
+
1271
+ if arg_strings:
1272
+ if not hasattr(namespace, _UNRECOGNIZED_ARGS_ATTR):
1273
+ setattr(namespace, _UNRECOGNIZED_ARGS_ATTR, [])
1274
+ getattr(namespace, _UNRECOGNIZED_ARGS_ATTR).extend(arg_strings)
1275
+
1276
+ class _ExtendAction(_AppendAction):
1277
+ def __call__(self, parser, namespace, values, option_string=None):
1278
+ items = getattr(namespace, self.dest, None)
1279
+ items = _copy_items(items)
1280
+ items.extend(values)
1281
+ setattr(namespace, self.dest, items)
1282
+
1283
+ # ==============
1284
+ # Type classes
1285
+ # ==============
1286
+
1287
+ class FileType(object):
1288
+ """Factory for creating file object types
1289
+
1290
+ Instances of FileType are typically passed as type= arguments to the
1291
+ ArgumentParser add_argument() method.
1292
+
1293
+ Keyword Arguments:
1294
+ - mode -- A string indicating how the file is to be opened. Accepts the
1295
+ same values as the builtin open() function.
1296
+ - bufsize -- The file's desired buffer size. Accepts the same values as
1297
+ the builtin open() function.
1298
+ - encoding -- The file's encoding. Accepts the same values as the
1299
+ builtin open() function.
1300
+ - errors -- A string indicating how encoding and decoding errors are to
1301
+ be handled. Accepts the same value as the builtin open() function.
1302
+ """
1303
+
1304
+ def __init__(self, mode='r', bufsize=-1, encoding=None, errors=None):
1305
+ self._mode = mode
1306
+ self._bufsize = bufsize
1307
+ self._encoding = encoding
1308
+ self._errors = errors
1309
+
1310
+ def __call__(self, string):
1311
+ # the special argument "-" means sys.std{in,out}
1312
+ if string == '-':
1313
+ if 'r' in self._mode:
1314
+ return _sys.stdin.buffer if 'b' in self._mode else _sys.stdin
1315
+ elif any(c in self._mode for c in 'wax'):
1316
+ return _sys.stdout.buffer if 'b' in self._mode else _sys.stdout
1317
+ else:
1318
+ msg = _('argument "-" with mode %r') % self._mode
1319
+ raise ValueError(msg)
1320
+
1321
+ # all other arguments are used as file names
1322
+ try:
1323
+ return open(string, self._mode, self._bufsize, self._encoding,
1324
+ self._errors)
1325
+ except OSError as e:
1326
+ args = {'filename': string, 'error': e}
1327
+ message = _("can't open '%(filename)s': %(error)s")
1328
+ raise ArgumentTypeError(message % args)
1329
+
1330
+ def __repr__(self):
1331
+ args = self._mode, self._bufsize
1332
+ kwargs = [('encoding', self._encoding), ('errors', self._errors)]
1333
+ args_str = ', '.join([repr(arg) for arg in args if arg != -1] +
1334
+ ['%s=%r' % (kw, arg) for kw, arg in kwargs
1335
+ if arg is not None])
1336
+ return '%s(%s)' % (type(self).__name__, args_str)
1337
+
1338
+ # ===========================
1339
+ # Optional and Positional Parsing
1340
+ # ===========================
1341
+
1342
+ class Namespace(_AttributeHolder):
1343
+ """Simple object for storing attributes.
1344
+
1345
+ Implements equality by attribute names and values, and provides a simple
1346
+ string representation.
1347
+ """
1348
+
1349
+ def __init__(self, **kwargs):
1350
+ for name in kwargs:
1351
+ setattr(self, name, kwargs[name])
1352
+
1353
+ def __eq__(self, other):
1354
+ if not isinstance(other, Namespace):
1355
+ return NotImplemented
1356
+ return vars(self) == vars(other)
1357
+
1358
+ def __contains__(self, key):
1359
+ return key in self.__dict__
1360
+
1361
+
1362
+ class _ActionsContainer(object):
1363
+
1364
+ def __init__(self,
1365
+ description,
1366
+ prefix_chars,
1367
+ argument_default,
1368
+ conflict_handler):
1369
+ super(_ActionsContainer, self).__init__()
1370
+
1371
+ self.description = description
1372
+ self.argument_default = argument_default
1373
+ self.prefix_chars = prefix_chars
1374
+ self.conflict_handler = conflict_handler
1375
+
1376
+ # set up registries
1377
+ self._registries = {}
1378
+
1379
+ # register actions
1380
+ self.register('action', None, _StoreAction)
1381
+ self.register('action', 'store', _StoreAction)
1382
+ self.register('action', 'store_const', _StoreConstAction)
1383
+ self.register('action', 'store_true', _StoreTrueAction)
1384
+ self.register('action', 'store_false', _StoreFalseAction)
1385
+ self.register('action', 'append', _AppendAction)
1386
+ self.register('action', 'append_const', _AppendConstAction)
1387
+ self.register('action', 'count', _CountAction)
1388
+ self.register('action', 'help', _HelpAction)
1389
+ self.register('action', 'version', _VersionAction)
1390
+ self.register('action', 'parsers', _SubParsersAction)
1391
+ self.register('action', 'extend', _ExtendAction)
1392
+
1393
+ # raise an exception if the conflict handler is invalid
1394
+ self._get_handler()
1395
+
1396
+ # action storage
1397
+ self._actions = []
1398
+ self._option_string_actions = {}
1399
+
1400
+ # groups
1401
+ self._action_groups = []
1402
+ self._mutually_exclusive_groups = []
1403
+
1404
+ # defaults storage
1405
+ self._defaults = {}
1406
+
1407
+ # determines whether an "option" looks like a negative number
1408
+ self._negative_number_matcher = _re.compile(r'^-\d+$|^-\d*\.\d+$')
1409
+
1410
+ # whether or not there are any optionals that look like negative
1411
+ # numbers -- uses a list so it can be shared and edited
1412
+ self._has_negative_number_optionals = []
1413
+
1414
+ # ====================
1415
+ # Registration methods
1416
+ # ====================
1417
+ def register(self, registry_name, value, object):
1418
+ registry = self._registries.setdefault(registry_name, {})
1419
+ registry[value] = object
1420
+
1421
+ def _registry_get(self, registry_name, value, default=None):
1422
+ return self._registries[registry_name].get(value, default)
1423
+
1424
+ # ==================================
1425
+ # Namespace default accessor methods
1426
+ # ==================================
1427
+ def set_defaults(self, **kwargs):
1428
+ self._defaults.update(kwargs)
1429
+
1430
+ # if these defaults match any existing arguments, replace
1431
+ # the previous default on the object with the new one
1432
+ for action in self._actions:
1433
+ if action.dest in kwargs:
1434
+ action.default = kwargs[action.dest]
1435
+
1436
+ def get_default(self, dest):
1437
+ for action in self._actions:
1438
+ if action.dest == dest and action.default is not None:
1439
+ return action.default
1440
+ return self._defaults.get(dest, None)
1441
+
1442
+
1443
+ # =======================
1444
+ # Adding argument actions
1445
+ # =======================
1446
+ def add_argument(self, *args, **kwargs):
1447
+ """
1448
+ add_argument(dest, ..., name=value, ...)
1449
+ add_argument(option_string, option_string, ..., name=value, ...)
1450
+ """
1451
+
1452
+ # if no positional args are supplied or only one is supplied and
1453
+ # it doesn't look like an option string, parse a positional
1454
+ # argument
1455
+ chars = self.prefix_chars
1456
+ if not args or len(args) == 1 and args[0][0] not in chars:
1457
+ if args and 'dest' in kwargs:
1458
+ raise ValueError('dest supplied twice for positional argument')
1459
+ kwargs = self._get_positional_kwargs(*args, **kwargs)
1460
+
1461
+ # otherwise, we're adding an optional argument
1462
+ else:
1463
+ kwargs = self._get_optional_kwargs(*args, **kwargs)
1464
+
1465
+ # if no default was supplied, use the parser-level default
1466
+ if 'default' not in kwargs:
1467
+ dest = kwargs['dest']
1468
+ if dest in self._defaults:
1469
+ kwargs['default'] = self._defaults[dest]
1470
+ elif self.argument_default is not None:
1471
+ kwargs['default'] = self.argument_default
1472
+
1473
+ # create the action object, and add it to the parser
1474
+ action_class = self._pop_action_class(kwargs)
1475
+ if not callable(action_class):
1476
+ raise ValueError('unknown action "%s"' % (action_class,))
1477
+ action = action_class(**kwargs)
1478
+
1479
+ # raise an error if the action type is not callable
1480
+ type_func = self._registry_get('type', action.type, action.type)
1481
+ if not callable(type_func):
1482
+ raise ValueError('%r is not callable' % (type_func,))
1483
+
1484
+ if type_func is FileType:
1485
+ raise ValueError('%r is a FileType class object, instance of it'
1486
+ ' must be passed' % (type_func,))
1487
+
1488
+ # raise an error if the metavar does not match the type
1489
+ if hasattr(self, "_get_formatter"):
1490
+ try:
1491
+ self._get_formatter()._format_args(action, None)
1492
+ except TypeError:
1493
+ raise ValueError("length of metavar tuple does not match nargs")
1494
+
1495
+ return self._add_action(action)
1496
+
1497
+ def add_argument_group(self, *args, **kwargs):
1498
+ group = _ArgumentGroup(self, *args, **kwargs)
1499
+ self._action_groups.append(group)
1500
+ return group
1501
+
1502
+ def add_mutually_exclusive_group(self, **kwargs):
1503
+ group = _MutuallyExclusiveGroup(self, **kwargs)
1504
+ self._mutually_exclusive_groups.append(group)
1505
+ return group
1506
+
1507
+ def _add_action(self, action):
1508
+ # resolve any conflicts
1509
+ self._check_conflict(action)
1510
+
1511
+ # add to actions list
1512
+ self._actions.append(action)
1513
+ action.container = self
1514
+
1515
+ # index the action by any option strings it has
1516
+ for option_string in action.option_strings:
1517
+ self._option_string_actions[option_string] = action
1518
+
1519
+ # set the flag if any option strings look like negative numbers
1520
+ for option_string in action.option_strings:
1521
+ if self._negative_number_matcher.match(option_string):
1522
+ if not self._has_negative_number_optionals:
1523
+ self._has_negative_number_optionals.append(True)
1524
+
1525
+ # return the created action
1526
+ return action
1527
+
1528
+ def _remove_action(self, action):
1529
+ self._actions.remove(action)
1530
+
1531
+ def _add_container_actions(self, container):
1532
+ # collect groups by titles
1533
+ title_group_map = {}
1534
+ for group in self._action_groups:
1535
+ if group.title in title_group_map:
1536
+ msg = _('cannot merge actions - two groups are named %r')
1537
+ raise ValueError(msg % (group.title))
1538
+ title_group_map[group.title] = group
1539
+
1540
+ # map each action to its group
1541
+ group_map = {}
1542
+ for group in container._action_groups:
1543
+
1544
+ # if a group with the title exists, use that, otherwise
1545
+ # create a new group matching the container's group
1546
+ if group.title not in title_group_map:
1547
+ title_group_map[group.title] = self.add_argument_group(
1548
+ title=group.title,
1549
+ description=group.description,
1550
+ conflict_handler=group.conflict_handler)
1551
+
1552
+ # map the actions to their new group
1553
+ for action in group._group_actions:
1554
+ group_map[action] = title_group_map[group.title]
1555
+
1556
+ # add container's mutually exclusive groups
1557
+ # NOTE: if add_mutually_exclusive_group ever gains title= and
1558
+ # description= then this code will need to be expanded as above
1559
+ for group in container._mutually_exclusive_groups:
1560
+ mutex_group = self.add_mutually_exclusive_group(
1561
+ required=group.required)
1562
+
1563
+ # map the actions to their new mutex group
1564
+ for action in group._group_actions:
1565
+ group_map[action] = mutex_group
1566
+
1567
+ # add all actions to this container or their group
1568
+ for action in container._actions:
1569
+ group_map.get(action, self)._add_action(action)
1570
+
1571
+ def _get_positional_kwargs(self, dest, **kwargs):
1572
+ # make sure required is not specified
1573
+ if 'required' in kwargs:
1574
+ msg = _("'required' is an invalid argument for positionals")
1575
+ raise TypeError(msg)
1576
+
1577
+ # mark positional arguments as required if at least one is
1578
+ # always required
1579
+ nargs = kwargs.get('nargs')
1580
+ if nargs not in [OPTIONAL, ZERO_OR_MORE, REMAINDER, SUPPRESS, 0]:
1581
+ kwargs['required'] = True
1582
+
1583
+ # return the keyword arguments with no option strings
1584
+ return dict(kwargs, dest=dest, option_strings=[])
1585
+
1586
+ def _get_optional_kwargs(self, *args, **kwargs):
1587
+ # determine short and long option strings
1588
+ option_strings = []
1589
+ long_option_strings = []
1590
+ for option_string in args:
1591
+ # error on strings that don't start with an appropriate prefix
1592
+ if not option_string[0] in self.prefix_chars:
1593
+ args = {'option': option_string,
1594
+ 'prefix_chars': self.prefix_chars}
1595
+ msg = _('invalid option string %(option)r: '
1596
+ 'must start with a character %(prefix_chars)r')
1597
+ raise ValueError(msg % args)
1598
+
1599
+ # strings starting with two prefix characters are long options
1600
+ option_strings.append(option_string)
1601
+ if len(option_string) > 1 and option_string[1] in self.prefix_chars:
1602
+ long_option_strings.append(option_string)
1603
+
1604
+ # infer destination, '--foo-bar' -> 'foo_bar' and '-x' -> 'x'
1605
+ dest = kwargs.pop('dest', None)
1606
+ if dest is None:
1607
+ if long_option_strings:
1608
+ dest_option_string = long_option_strings[0]
1609
+ else:
1610
+ dest_option_string = option_strings[0]
1611
+ dest = dest_option_string.lstrip(self.prefix_chars)
1612
+ if not dest:
1613
+ msg = _('dest= is required for options like %r')
1614
+ raise ValueError(msg % option_string)
1615
+ dest = dest.replace('-', '_')
1616
+
1617
+ # return the updated keyword arguments
1618
+ return dict(kwargs, dest=dest, option_strings=option_strings)
1619
+
1620
+ def _pop_action_class(self, kwargs, default=None):
1621
+ action = kwargs.pop('action', default)
1622
+ return self._registry_get('action', action, action)
1623
+
1624
+ def _get_handler(self):
1625
+ # determine function from conflict handler string
1626
+ handler_func_name = '_handle_conflict_%s' % self.conflict_handler
1627
+ try:
1628
+ return getattr(self, handler_func_name)
1629
+ except AttributeError:
1630
+ msg = _('invalid conflict_resolution value: %r')
1631
+ raise ValueError(msg % self.conflict_handler)
1632
+
1633
+ def _check_conflict(self, action):
1634
+
1635
+ # find all options that conflict with this option
1636
+ confl_optionals = []
1637
+ for option_string in action.option_strings:
1638
+ if option_string in self._option_string_actions:
1639
+ confl_optional = self._option_string_actions[option_string]
1640
+ confl_optionals.append((option_string, confl_optional))
1641
+
1642
+ # resolve any conflicts
1643
+ if confl_optionals:
1644
+ conflict_handler = self._get_handler()
1645
+ conflict_handler(action, confl_optionals)
1646
+
1647
+ def _handle_conflict_error(self, action, conflicting_actions):
1648
+ message = ngettext('conflicting option string: %s',
1649
+ 'conflicting option strings: %s',
1650
+ len(conflicting_actions))
1651
+ conflict_string = ', '.join([option_string
1652
+ for option_string, action
1653
+ in conflicting_actions])
1654
+ raise ArgumentError(action, message % conflict_string)
1655
+
1656
+ def _handle_conflict_resolve(self, action, conflicting_actions):
1657
+
1658
+ # remove all conflicting options
1659
+ for option_string, action in conflicting_actions:
1660
+
1661
+ # remove the conflicting option
1662
+ action.option_strings.remove(option_string)
1663
+ self._option_string_actions.pop(option_string, None)
1664
+
1665
+ # if the option now has no option string, remove it from the
1666
+ # container holding it
1667
+ if not action.option_strings:
1668
+ action.container._remove_action(action)
1669
+
1670
+
1671
+ class _ArgumentGroup(_ActionsContainer):
1672
+
1673
+ def __init__(self, container, title=None, description=None, **kwargs):
1674
+ # add any missing keyword arguments by checking the container
1675
+ update = kwargs.setdefault
1676
+ update('conflict_handler', container.conflict_handler)
1677
+ update('prefix_chars', container.prefix_chars)
1678
+ update('argument_default', container.argument_default)
1679
+ super_init = super(_ArgumentGroup, self).__init__
1680
+ super_init(description=description, **kwargs)
1681
+
1682
+ # group attributes
1683
+ self.title = title
1684
+ self._group_actions = []
1685
+
1686
+ # share most attributes with the container
1687
+ self._registries = container._registries
1688
+ self._actions = container._actions
1689
+ self._option_string_actions = container._option_string_actions
1690
+ self._defaults = container._defaults
1691
+ self._has_negative_number_optionals = \
1692
+ container._has_negative_number_optionals
1693
+ self._mutually_exclusive_groups = container._mutually_exclusive_groups
1694
+
1695
+ def _add_action(self, action):
1696
+ action = super(_ArgumentGroup, self)._add_action(action)
1697
+ self._group_actions.append(action)
1698
+ return action
1699
+
1700
+ def _remove_action(self, action):
1701
+ super(_ArgumentGroup, self)._remove_action(action)
1702
+ self._group_actions.remove(action)
1703
+
1704
+ def add_argument_group(self, *args, **kwargs):
1705
+ warnings.warn(
1706
+ "Nesting argument groups is deprecated.",
1707
+ category=DeprecationWarning,
1708
+ stacklevel=2
1709
+ )
1710
+ return super().add_argument_group(*args, **kwargs)
1711
+
1712
+
1713
+ class _MutuallyExclusiveGroup(_ArgumentGroup):
1714
+
1715
+ def __init__(self, container, required=False):
1716
+ super(_MutuallyExclusiveGroup, self).__init__(container)
1717
+ self.required = required
1718
+ self._container = container
1719
+
1720
+ def _add_action(self, action):
1721
+ if action.required:
1722
+ msg = _('mutually exclusive arguments must be optional')
1723
+ raise ValueError(msg)
1724
+ action = self._container._add_action(action)
1725
+ self._group_actions.append(action)
1726
+ return action
1727
+
1728
+ def _remove_action(self, action):
1729
+ self._container._remove_action(action)
1730
+ self._group_actions.remove(action)
1731
+
1732
+ def add_mutually_exclusive_group(self, *args, **kwargs):
1733
+ warnings.warn(
1734
+ "Nesting mutually exclusive groups is deprecated.",
1735
+ category=DeprecationWarning,
1736
+ stacklevel=2
1737
+ )
1738
+ return super().add_mutually_exclusive_group(*args, **kwargs)
1739
+
1740
+
1741
+ class ArgumentParser(_AttributeHolder, _ActionsContainer):
1742
+ """Object for parsing command line strings into Python objects.
1743
+
1744
+ Keyword Arguments:
1745
+ - prog -- The name of the program (default:
1746
+ ``os.path.basename(sys.argv[0])``)
1747
+ - usage -- A usage message (default: auto-generated from arguments)
1748
+ - description -- A description of what the program does
1749
+ - epilog -- Text following the argument descriptions
1750
+ - parents -- Parsers whose arguments should be copied into this one
1751
+ - formatter_class -- HelpFormatter class for printing help messages
1752
+ - prefix_chars -- Characters that prefix optional arguments
1753
+ - fromfile_prefix_chars -- Characters that prefix files containing
1754
+ additional arguments
1755
+ - argument_default -- The default value for all arguments
1756
+ - conflict_handler -- String indicating how to handle conflicts
1757
+ - add_help -- Add a -h/-help option
1758
+ - allow_abbrev -- Allow long options to be abbreviated unambiguously
1759
+ - exit_on_error -- Determines whether or not ArgumentParser exits with
1760
+ error info when an error occurs
1761
+ """
1762
+
1763
+ def __init__(self,
1764
+ prog=None,
1765
+ usage=None,
1766
+ description=None,
1767
+ epilog=None,
1768
+ parents=[],
1769
+ formatter_class=HelpFormatter,
1770
+ prefix_chars='-',
1771
+ fromfile_prefix_chars=None,
1772
+ argument_default=None,
1773
+ conflict_handler='error',
1774
+ add_help=True,
1775
+ allow_abbrev=True,
1776
+ exit_on_error=True):
1777
+
1778
+ superinit = super(ArgumentParser, self).__init__
1779
+ superinit(description=description,
1780
+ prefix_chars=prefix_chars,
1781
+ argument_default=argument_default,
1782
+ conflict_handler=conflict_handler)
1783
+
1784
+ # default setting for prog
1785
+ if prog is None:
1786
+ prog = _os.path.basename(_sys.argv[0])
1787
+
1788
+ self.prog = prog
1789
+ self.usage = usage
1790
+ self.epilog = epilog
1791
+ self.formatter_class = formatter_class
1792
+ self.fromfile_prefix_chars = fromfile_prefix_chars
1793
+ self.add_help = add_help
1794
+ self.allow_abbrev = allow_abbrev
1795
+ self.exit_on_error = exit_on_error
1796
+
1797
+ add_group = self.add_argument_group
1798
+ self._positionals = add_group(_('positional arguments'))
1799
+ self._optionals = add_group(_('options'))
1800
+ self._subparsers = None
1801
+
1802
+ # register types
1803
+ def identity(string):
1804
+ return string
1805
+ self.register('type', None, identity)
1806
+
1807
+ # add help argument if necessary
1808
+ # (using explicit default to override global argument_default)
1809
+ default_prefix = '-' if '-' in prefix_chars else prefix_chars[0]
1810
+ if self.add_help:
1811
+ self.add_argument(
1812
+ default_prefix+'h', default_prefix*2+'help',
1813
+ action='help', default=SUPPRESS,
1814
+ help=_('show this help message and exit'))
1815
+
1816
+ # add parent arguments and defaults
1817
+ for parent in parents:
1818
+ self._add_container_actions(parent)
1819
+ try:
1820
+ defaults = parent._defaults
1821
+ except AttributeError:
1822
+ pass
1823
+ else:
1824
+ self._defaults.update(defaults)
1825
+
1826
+ # =======================
1827
+ # Pretty __repr__ methods
1828
+ # =======================
1829
+ def _get_kwargs(self):
1830
+ names = [
1831
+ 'prog',
1832
+ 'usage',
1833
+ 'description',
1834
+ 'formatter_class',
1835
+ 'conflict_handler',
1836
+ 'add_help',
1837
+ ]
1838
+ return [(name, getattr(self, name)) for name in names]
1839
+
1840
+ # ==================================
1841
+ # Optional/Positional adding methods
1842
+ # ==================================
1843
+ def add_subparsers(self, **kwargs):
1844
+ if self._subparsers is not None:
1845
+ raise ArgumentError(None, _('cannot have multiple subparser arguments'))
1846
+
1847
+ # add the parser class to the arguments if it's not present
1848
+ kwargs.setdefault('parser_class', type(self))
1849
+
1850
+ if 'title' in kwargs or 'description' in kwargs:
1851
+ title = kwargs.pop('title', _('subcommands'))
1852
+ description = kwargs.pop('description', None)
1853
+ self._subparsers = self.add_argument_group(title, description)
1854
+ else:
1855
+ self._subparsers = self._positionals
1856
+
1857
+ # prog defaults to the usage message of this parser, skipping
1858
+ # optional arguments and with no "usage:" prefix
1859
+ if kwargs.get('prog') is None:
1860
+ formatter = self._get_formatter()
1861
+ positionals = self._get_positional_actions()
1862
+ groups = self._mutually_exclusive_groups
1863
+ formatter.add_usage(self.usage, positionals, groups, '')
1864
+ kwargs['prog'] = formatter.format_help().strip()
1865
+
1866
+ # create the parsers action and add it to the positionals list
1867
+ parsers_class = self._pop_action_class(kwargs, 'parsers')
1868
+ action = parsers_class(option_strings=[], **kwargs)
1869
+ self._subparsers._add_action(action)
1870
+
1871
+ # return the created parsers action
1872
+ return action
1873
+
1874
+ def _add_action(self, action):
1875
+ if action.option_strings:
1876
+ self._optionals._add_action(action)
1877
+ else:
1878
+ self._positionals._add_action(action)
1879
+ return action
1880
+
1881
+ def _get_optional_actions(self):
1882
+ return [action
1883
+ for action in self._actions
1884
+ if action.option_strings]
1885
+
1886
+ def _get_positional_actions(self):
1887
+ return [action
1888
+ for action in self._actions
1889
+ if not action.option_strings]
1890
+
1891
+ # =====================================
1892
+ # Command line argument parsing methods
1893
+ # =====================================
1894
+ def parse_args(self, args=None, namespace=None):
1895
+ args, argv = self.parse_known_args(args, namespace)
1896
+ if argv:
1897
+ msg = _('unrecognized arguments: %s') % ' '.join(argv)
1898
+ if self.exit_on_error:
1899
+ self.error(msg)
1900
+ else:
1901
+ raise ArgumentError(None, msg)
1902
+ return args
1903
+
1904
+ def parse_known_args(self, args=None, namespace=None):
1905
+ if args is None:
1906
+ # args default to the system args
1907
+ args = _sys.argv[1:]
1908
+ else:
1909
+ # make sure that args are mutable
1910
+ args = list(args)
1911
+
1912
+ # default Namespace built from parser defaults
1913
+ if namespace is None:
1914
+ namespace = Namespace()
1915
+
1916
+ # add any action defaults that aren't present
1917
+ for action in self._actions:
1918
+ if action.dest is not SUPPRESS:
1919
+ if not hasattr(namespace, action.dest):
1920
+ if action.default is not SUPPRESS:
1921
+ setattr(namespace, action.dest, action.default)
1922
+
1923
+ # add any parser defaults that aren't present
1924
+ for dest in self._defaults:
1925
+ if not hasattr(namespace, dest):
1926
+ setattr(namespace, dest, self._defaults[dest])
1927
+
1928
+ # parse the arguments and exit if there are any errors
1929
+ if self.exit_on_error:
1930
+ try:
1931
+ namespace, args = self._parse_known_args(args, namespace)
1932
+ except ArgumentError as err:
1933
+ self.error(str(err))
1934
+ else:
1935
+ namespace, args = self._parse_known_args(args, namespace)
1936
+
1937
+ if hasattr(namespace, _UNRECOGNIZED_ARGS_ATTR):
1938
+ args.extend(getattr(namespace, _UNRECOGNIZED_ARGS_ATTR))
1939
+ delattr(namespace, _UNRECOGNIZED_ARGS_ATTR)
1940
+ return namespace, args
1941
+
1942
+ def _parse_known_args(self, arg_strings, namespace):
1943
+ # replace arg strings that are file references
1944
+ if self.fromfile_prefix_chars is not None:
1945
+ arg_strings = self._read_args_from_files(arg_strings)
1946
+
1947
+ # map all mutually exclusive arguments to the other arguments
1948
+ # they can't occur with
1949
+ action_conflicts = {}
1950
+ for mutex_group in self._mutually_exclusive_groups:
1951
+ group_actions = mutex_group._group_actions
1952
+ for i, mutex_action in enumerate(mutex_group._group_actions):
1953
+ conflicts = action_conflicts.setdefault(mutex_action, [])
1954
+ conflicts.extend(group_actions[:i])
1955
+ conflicts.extend(group_actions[i + 1:])
1956
+
1957
+ # find all option indices, and determine the arg_string_pattern
1958
+ # which has an 'O' if there is an option at an index,
1959
+ # an 'A' if there is an argument, or a '-' if there is a '--'
1960
+ option_string_indices = {}
1961
+ arg_string_pattern_parts = []
1962
+ arg_strings_iter = iter(arg_strings)
1963
+ for i, arg_string in enumerate(arg_strings_iter):
1964
+
1965
+ # all args after -- are non-options
1966
+ if arg_string == '--':
1967
+ arg_string_pattern_parts.append('-')
1968
+ for arg_string in arg_strings_iter:
1969
+ arg_string_pattern_parts.append('A')
1970
+
1971
+ # otherwise, add the arg to the arg strings
1972
+ # and note the index if it was an option
1973
+ else:
1974
+ option_tuples = self._parse_optional(arg_string)
1975
+ if option_tuples is None:
1976
+ pattern = 'A'
1977
+ else:
1978
+ option_string_indices[i] = option_tuples
1979
+ pattern = 'O'
1980
+ arg_string_pattern_parts.append(pattern)
1981
+
1982
+ # join the pieces together to form the pattern
1983
+ arg_strings_pattern = ''.join(arg_string_pattern_parts)
1984
+
1985
+ # converts arg strings to the appropriate and then takes the action
1986
+ seen_actions = set()
1987
+ seen_non_default_actions = set()
1988
+
1989
+ def take_action(action, argument_strings, option_string=None):
1990
+ seen_actions.add(action)
1991
+ argument_values = self._get_values(action, argument_strings)
1992
+
1993
+ # error if this argument is not allowed with other previously
1994
+ # seen arguments
1995
+ if action.option_strings or argument_strings:
1996
+ seen_non_default_actions.add(action)
1997
+ for conflict_action in action_conflicts.get(action, []):
1998
+ if conflict_action in seen_non_default_actions:
1999
+ msg = _('not allowed with argument %s')
2000
+ action_name = _get_action_name(conflict_action)
2001
+ raise ArgumentError(action, msg % action_name)
2002
+
2003
+ # take the action if we didn't receive a SUPPRESS value
2004
+ # (e.g. from a default)
2005
+ if argument_values is not SUPPRESS:
2006
+ action(self, namespace, argument_values, option_string)
2007
+
2008
+ # function to convert arg_strings into an optional action
2009
+ def consume_optional(start_index):
2010
+
2011
+ # get the optional identified at this index
2012
+ option_tuples = option_string_indices[start_index]
2013
+ # if multiple actions match, the option string was ambiguous
2014
+ if len(option_tuples) > 1:
2015
+ options = ', '.join([option_string
2016
+ for action, option_string, sep, explicit_arg in option_tuples])
2017
+ args = {'option': arg_string, 'matches': options}
2018
+ msg = _('ambiguous option: %(option)s could match %(matches)s')
2019
+ raise ArgumentError(None, msg % args)
2020
+
2021
+ action, option_string, sep, explicit_arg = option_tuples[0]
2022
+
2023
+ # identify additional optionals in the same arg string
2024
+ # (e.g. -xyz is the same as -x -y -z if no args are required)
2025
+ match_argument = self._match_argument
2026
+ action_tuples = []
2027
+ while True:
2028
+
2029
+ # if we found no optional action, skip it
2030
+ if action is None:
2031
+ extras.append(arg_strings[start_index])
2032
+ return start_index + 1
2033
+
2034
+ # if there is an explicit argument, try to match the
2035
+ # optional's string arguments to only this
2036
+ if explicit_arg is not None:
2037
+ arg_count = match_argument(action, 'A')
2038
+
2039
+ # if the action is a single-dash option and takes no
2040
+ # arguments, try to parse more single-dash options out
2041
+ # of the tail of the option string
2042
+ chars = self.prefix_chars
2043
+ if (
2044
+ arg_count == 0
2045
+ and option_string[1] not in chars
2046
+ and explicit_arg != ''
2047
+ ):
2048
+ if sep or explicit_arg[0] in chars:
2049
+ msg = _('ignored explicit argument %r')
2050
+ raise ArgumentError(action, msg % explicit_arg)
2051
+ action_tuples.append((action, [], option_string))
2052
+ char = option_string[0]
2053
+ option_string = char + explicit_arg[0]
2054
+ optionals_map = self._option_string_actions
2055
+ if option_string in optionals_map:
2056
+ action = optionals_map[option_string]
2057
+ explicit_arg = explicit_arg[1:]
2058
+ if not explicit_arg:
2059
+ sep = explicit_arg = None
2060
+ elif explicit_arg[0] == '=':
2061
+ sep = '='
2062
+ explicit_arg = explicit_arg[1:]
2063
+ else:
2064
+ sep = ''
2065
+ else:
2066
+ extras.append(char + explicit_arg)
2067
+ stop = start_index + 1
2068
+ break
2069
+ # if the action expect exactly one argument, we've
2070
+ # successfully matched the option; exit the loop
2071
+ elif arg_count == 1:
2072
+ stop = start_index + 1
2073
+ args = [explicit_arg]
2074
+ action_tuples.append((action, args, option_string))
2075
+ break
2076
+
2077
+ # error if a double-dash option did not use the
2078
+ # explicit argument
2079
+ else:
2080
+ msg = _('ignored explicit argument %r')
2081
+ raise ArgumentError(action, msg % explicit_arg)
2082
+
2083
+ # if there is no explicit argument, try to match the
2084
+ # optional's string arguments with the following strings
2085
+ # if successful, exit the loop
2086
+ else:
2087
+ start = start_index + 1
2088
+ selected_patterns = arg_strings_pattern[start:]
2089
+ arg_count = match_argument(action, selected_patterns)
2090
+ stop = start + arg_count
2091
+ args = arg_strings[start:stop]
2092
+ action_tuples.append((action, args, option_string))
2093
+ break
2094
+
2095
+ # add the Optional to the list and return the index at which
2096
+ # the Optional's string args stopped
2097
+ assert action_tuples
2098
+ for action, args, option_string in action_tuples:
2099
+ take_action(action, args, option_string)
2100
+ return stop
2101
+
2102
+ # the list of Positionals left to be parsed; this is modified
2103
+ # by consume_positionals()
2104
+ positionals = self._get_positional_actions()
2105
+
2106
+ # function to convert arg_strings into positional actions
2107
+ def consume_positionals(start_index):
2108
+ # match as many Positionals as possible
2109
+ match_partial = self._match_arguments_partial
2110
+ selected_pattern = arg_strings_pattern[start_index:]
2111
+ arg_counts = match_partial(positionals, selected_pattern)
2112
+
2113
+ # slice off the appropriate arg strings for each Positional
2114
+ # and add the Positional and its args to the list
2115
+ for action, arg_count in zip(positionals, arg_counts):
2116
+ args = arg_strings[start_index: start_index + arg_count]
2117
+ # Strip out the first '--' if it is not in REMAINDER arg.
2118
+ if action.nargs == PARSER:
2119
+ if arg_strings_pattern[start_index] == '-':
2120
+ assert args[0] == '--'
2121
+ args.remove('--')
2122
+ elif action.nargs != REMAINDER:
2123
+ if (arg_strings_pattern.find('-', start_index,
2124
+ start_index + arg_count) >= 0):
2125
+ args.remove('--')
2126
+ start_index += arg_count
2127
+ take_action(action, args)
2128
+
2129
+ # slice off the Positionals that we just parsed and return the
2130
+ # index at which the Positionals' string args stopped
2131
+ positionals[:] = positionals[len(arg_counts):]
2132
+ return start_index
2133
+
2134
+ # consume Positionals and Optionals alternately, until we have
2135
+ # passed the last option string
2136
+ extras = []
2137
+ start_index = 0
2138
+ if option_string_indices:
2139
+ max_option_string_index = max(option_string_indices)
2140
+ else:
2141
+ max_option_string_index = -1
2142
+ while start_index <= max_option_string_index:
2143
+
2144
+ # consume any Positionals preceding the next option
2145
+ next_option_string_index = min([
2146
+ index
2147
+ for index in option_string_indices
2148
+ if index >= start_index])
2149
+ if start_index != next_option_string_index:
2150
+ positionals_end_index = consume_positionals(start_index)
2151
+
2152
+ # only try to parse the next optional if we didn't consume
2153
+ # the option string during the positionals parsing
2154
+ if positionals_end_index > start_index:
2155
+ start_index = positionals_end_index
2156
+ continue
2157
+ else:
2158
+ start_index = positionals_end_index
2159
+
2160
+ # if we consumed all the positionals we could and we're not
2161
+ # at the index of an option string, there were extra arguments
2162
+ if start_index not in option_string_indices:
2163
+ strings = arg_strings[start_index:next_option_string_index]
2164
+ extras.extend(strings)
2165
+ start_index = next_option_string_index
2166
+
2167
+ # consume the next optional and any arguments for it
2168
+ start_index = consume_optional(start_index)
2169
+
2170
+ # consume any positionals following the last Optional
2171
+ stop_index = consume_positionals(start_index)
2172
+
2173
+ # if we didn't consume all the argument strings, there were extras
2174
+ extras.extend(arg_strings[stop_index:])
2175
+
2176
+ # make sure all required actions were present and also convert
2177
+ # action defaults which were not given as arguments
2178
+ required_actions = []
2179
+ for action in self._actions:
2180
+ if action not in seen_actions:
2181
+ if action.required:
2182
+ required_actions.append(_get_action_name(action))
2183
+ else:
2184
+ # Convert action default now instead of doing it before
2185
+ # parsing arguments to avoid calling convert functions
2186
+ # twice (which may fail) if the argument was given, but
2187
+ # only if it was defined already in the namespace
2188
+ if (action.default is not None and
2189
+ isinstance(action.default, str) and
2190
+ hasattr(namespace, action.dest) and
2191
+ action.default is getattr(namespace, action.dest)):
2192
+ setattr(namespace, action.dest,
2193
+ self._get_value(action, action.default))
2194
+
2195
+ if required_actions:
2196
+ raise ArgumentError(None, _('the following arguments are required: %s') %
2197
+ ', '.join(required_actions))
2198
+
2199
+ # make sure all required groups had one option present
2200
+ for group in self._mutually_exclusive_groups:
2201
+ if group.required:
2202
+ for action in group._group_actions:
2203
+ if action in seen_non_default_actions:
2204
+ break
2205
+
2206
+ # if no actions were used, report the error
2207
+ else:
2208
+ names = [_get_action_name(action)
2209
+ for action in group._group_actions
2210
+ if action.help is not SUPPRESS]
2211
+ msg = _('one of the arguments %s is required')
2212
+ raise ArgumentError(None, msg % ' '.join(names))
2213
+
2214
+ # return the updated namespace and the extra arguments
2215
+ return namespace, extras
2216
+
2217
+ def _read_args_from_files(self, arg_strings):
2218
+ # expand arguments referencing files
2219
+ new_arg_strings = []
2220
+ for arg_string in arg_strings:
2221
+
2222
+ # for regular arguments, just add them back into the list
2223
+ if not arg_string or arg_string[0] not in self.fromfile_prefix_chars:
2224
+ new_arg_strings.append(arg_string)
2225
+
2226
+ # replace arguments referencing files with the file content
2227
+ else:
2228
+ try:
2229
+ with open(arg_string[1:],
2230
+ encoding=_sys.getfilesystemencoding(),
2231
+ errors=_sys.getfilesystemencodeerrors()) as args_file:
2232
+ arg_strings = []
2233
+ for arg_line in args_file.read().splitlines():
2234
+ for arg in self.convert_arg_line_to_args(arg_line):
2235
+ arg_strings.append(arg)
2236
+ arg_strings = self._read_args_from_files(arg_strings)
2237
+ new_arg_strings.extend(arg_strings)
2238
+ except OSError as err:
2239
+ raise ArgumentError(None, str(err))
2240
+
2241
+ # return the modified argument list
2242
+ return new_arg_strings
2243
+
2244
+ def convert_arg_line_to_args(self, arg_line):
2245
+ return [arg_line]
2246
+
2247
+ def _match_argument(self, action, arg_strings_pattern):
2248
+ # match the pattern for this action to the arg strings
2249
+ nargs_pattern = self._get_nargs_pattern(action)
2250
+ match = _re.match(nargs_pattern, arg_strings_pattern)
2251
+
2252
+ # raise an exception if we weren't able to find a match
2253
+ if match is None:
2254
+ nargs_errors = {
2255
+ None: _('expected one argument'),
2256
+ OPTIONAL: _('expected at most one argument'),
2257
+ ONE_OR_MORE: _('expected at least one argument'),
2258
+ }
2259
+ msg = nargs_errors.get(action.nargs)
2260
+ if msg is None:
2261
+ msg = ngettext('expected %s argument',
2262
+ 'expected %s arguments',
2263
+ action.nargs) % action.nargs
2264
+ raise ArgumentError(action, msg)
2265
+
2266
+ # return the number of arguments matched
2267
+ return len(match.group(1))
2268
+
2269
+ def _match_arguments_partial(self, actions, arg_strings_pattern):
2270
+ # progressively shorten the actions list by slicing off the
2271
+ # final actions until we find a match
2272
+ for i in range(len(actions), 0, -1):
2273
+ actions_slice = actions[:i]
2274
+ pattern = ''.join([self._get_nargs_pattern(action)
2275
+ for action in actions_slice])
2276
+ match = _re.match(pattern, arg_strings_pattern)
2277
+ if match is not None:
2278
+ result = [len(string) for string in match.groups()]
2279
+ if (match.end() < len(arg_strings_pattern)
2280
+ and arg_strings_pattern[match.end()] == 'O'):
2281
+ while result and not result[-1]:
2282
+ del result[-1]
2283
+ return result
2284
+ return []
2285
+
2286
+ def _parse_optional(self, arg_string):
2287
+ # if it's an empty string, it was meant to be a positional
2288
+ if not arg_string:
2289
+ return None
2290
+
2291
+ # if it doesn't start with a prefix, it was meant to be positional
2292
+ if not arg_string[0] in self.prefix_chars:
2293
+ return None
2294
+
2295
+ # if the option string is present in the parser, return the action
2296
+ if arg_string in self._option_string_actions:
2297
+ action = self._option_string_actions[arg_string]
2298
+ return [(action, arg_string, None, None)]
2299
+
2300
+ # if it's just a single character, it was meant to be positional
2301
+ if len(arg_string) == 1:
2302
+ return None
2303
+
2304
+ # if the option string before the "=" is present, return the action
2305
+ option_string, sep, explicit_arg = arg_string.partition('=')
2306
+ if sep and option_string in self._option_string_actions:
2307
+ action = self._option_string_actions[option_string]
2308
+ return [(action, option_string, sep, explicit_arg)]
2309
+
2310
+ # search through all possible prefixes of the option string
2311
+ # and all actions in the parser for possible interpretations
2312
+ option_tuples = self._get_option_tuples(arg_string)
2313
+
2314
+ if option_tuples:
2315
+ return option_tuples
2316
+
2317
+ # if it was not found as an option, but it looks like a negative
2318
+ # number, it was meant to be positional
2319
+ # unless there are negative-number-like options
2320
+ if self._negative_number_matcher.match(arg_string):
2321
+ if not self._has_negative_number_optionals:
2322
+ return None
2323
+
2324
+ # if it contains a space, it was meant to be a positional
2325
+ if ' ' in arg_string:
2326
+ return None
2327
+
2328
+ # it was meant to be an optional but there is no such option
2329
+ # in this parser (though it might be a valid option in a subparser)
2330
+ return [(None, arg_string, None, None)]
2331
+
2332
+ def _get_option_tuples(self, option_string):
2333
+ result = []
2334
+
2335
+ # option strings starting with two prefix characters are only
2336
+ # split at the '='
2337
+ chars = self.prefix_chars
2338
+ if option_string[0] in chars and option_string[1] in chars:
2339
+ if self.allow_abbrev:
2340
+ option_prefix, sep, explicit_arg = option_string.partition('=')
2341
+ if not sep:
2342
+ sep = explicit_arg = None
2343
+ for option_string in self._option_string_actions:
2344
+ if option_string.startswith(option_prefix):
2345
+ action = self._option_string_actions[option_string]
2346
+ tup = action, option_string, sep, explicit_arg
2347
+ result.append(tup)
2348
+
2349
+ # single character options can be concatenated with their arguments
2350
+ # but multiple character options always have to have their argument
2351
+ # separate
2352
+ elif option_string[0] in chars and option_string[1] not in chars:
2353
+ option_prefix, sep, explicit_arg = option_string.partition('=')
2354
+ if not sep:
2355
+ sep = explicit_arg = None
2356
+ short_option_prefix = option_string[:2]
2357
+ short_explicit_arg = option_string[2:]
2358
+
2359
+ for option_string in self._option_string_actions:
2360
+ if option_string == short_option_prefix:
2361
+ action = self._option_string_actions[option_string]
2362
+ tup = action, option_string, '', short_explicit_arg
2363
+ result.append(tup)
2364
+ elif self.allow_abbrev and option_string.startswith(option_prefix):
2365
+ action = self._option_string_actions[option_string]
2366
+ tup = action, option_string, sep, explicit_arg
2367
+ result.append(tup)
2368
+
2369
+ # shouldn't ever get here
2370
+ else:
2371
+ raise ArgumentError(None, _('unexpected option string: %s') % option_string)
2372
+
2373
+ # return the collected option tuples
2374
+ return result
2375
+
2376
+ def _get_nargs_pattern(self, action):
2377
+ # in all examples below, we have to allow for '--' args
2378
+ # which are represented as '-' in the pattern
2379
+ nargs = action.nargs
2380
+ # if this is an optional action, -- is not allowed
2381
+ option = action.option_strings
2382
+
2383
+ # the default (None) is assumed to be a single argument
2384
+ if nargs is None:
2385
+ nargs_pattern = '([A])' if option else '(-*A-*)'
2386
+
2387
+ # allow zero or one arguments
2388
+ elif nargs == OPTIONAL:
2389
+ nargs_pattern = '(A?)' if option else '(-*A?-*)'
2390
+
2391
+ # allow zero or more arguments
2392
+ elif nargs == ZERO_OR_MORE:
2393
+ nargs_pattern = '(A*)' if option else '(-*[A-]*)'
2394
+
2395
+ # allow one or more arguments
2396
+ elif nargs == ONE_OR_MORE:
2397
+ nargs_pattern = '(A+)' if option else '(-*A[A-]*)'
2398
+
2399
+ # allow any number of options or arguments
2400
+ elif nargs == REMAINDER:
2401
+ nargs_pattern = '([AO]*)' if option else '(.*)'
2402
+
2403
+ # allow one argument followed by any number of options or arguments
2404
+ elif nargs == PARSER:
2405
+ nargs_pattern = '(A[AO]*)' if option else '(-*A[-AO]*)'
2406
+
2407
+ # suppress action, like nargs=0
2408
+ elif nargs == SUPPRESS:
2409
+ nargs_pattern = '()' if option else '(-*)'
2410
+
2411
+ # all others should be integers
2412
+ else:
2413
+ nargs_pattern = '([AO]{%d})' % nargs if option else '((?:-*A){%d}-*)' % nargs
2414
+
2415
+ # return the pattern
2416
+ return nargs_pattern
2417
+
2418
+ # ========================
2419
+ # Alt command line argument parsing, allowing free intermix
2420
+ # ========================
2421
+
2422
+ def parse_intermixed_args(self, args=None, namespace=None):
2423
+ args, argv = self.parse_known_intermixed_args(args, namespace)
2424
+ if argv:
2425
+ msg = _('unrecognized arguments: %s') % ' '.join(argv)
2426
+ if self.exit_on_error:
2427
+ self.error(msg)
2428
+ else:
2429
+ raise ArgumentError(None, msg)
2430
+ return args
2431
+
2432
+ def parse_known_intermixed_args(self, args=None, namespace=None):
2433
+ # returns a namespace and list of extras
2434
+ #
2435
+ # positional can be freely intermixed with optionals. optionals are
2436
+ # first parsed with all positional arguments deactivated. The 'extras'
2437
+ # are then parsed. If the parser definition is incompatible with the
2438
+ # intermixed assumptions (e.g. use of REMAINDER, subparsers) a
2439
+ # TypeError is raised.
2440
+ #
2441
+ # positionals are 'deactivated' by setting nargs and default to
2442
+ # SUPPRESS. This blocks the addition of that positional to the
2443
+ # namespace
2444
+
2445
+ positionals = self._get_positional_actions()
2446
+ a = [action for action in positionals
2447
+ if action.nargs in [PARSER, REMAINDER]]
2448
+ if a:
2449
+ raise TypeError('parse_intermixed_args: positional arg'
2450
+ ' with nargs=%s'%a[0].nargs)
2451
+
2452
+ if [action.dest for group in self._mutually_exclusive_groups
2453
+ for action in group._group_actions if action in positionals]:
2454
+ raise TypeError('parse_intermixed_args: positional in'
2455
+ ' mutuallyExclusiveGroup')
2456
+
2457
+ try:
2458
+ save_usage = self.usage
2459
+ try:
2460
+ if self.usage is None:
2461
+ # capture the full usage for use in error messages
2462
+ self.usage = self.format_usage()[7:]
2463
+ for action in positionals:
2464
+ # deactivate positionals
2465
+ action.save_nargs = action.nargs
2466
+ # action.nargs = 0
2467
+ action.nargs = SUPPRESS
2468
+ action.save_default = action.default
2469
+ action.default = SUPPRESS
2470
+ namespace, remaining_args = self.parse_known_args(args,
2471
+ namespace)
2472
+ for action in positionals:
2473
+ # remove the empty positional values from namespace
2474
+ if (hasattr(namespace, action.dest)
2475
+ and getattr(namespace, action.dest)==[]):
2476
+ from warnings import warn
2477
+ warn('Do not expect %s in %s' % (action.dest, namespace))
2478
+ delattr(namespace, action.dest)
2479
+ finally:
2480
+ # restore nargs and usage before exiting
2481
+ for action in positionals:
2482
+ action.nargs = action.save_nargs
2483
+ action.default = action.save_default
2484
+ optionals = self._get_optional_actions()
2485
+ try:
2486
+ # parse positionals. optionals aren't normally required, but
2487
+ # they could be, so make sure they aren't.
2488
+ for action in optionals:
2489
+ action.save_required = action.required
2490
+ action.required = False
2491
+ for group in self._mutually_exclusive_groups:
2492
+ group.save_required = group.required
2493
+ group.required = False
2494
+ namespace, extras = self.parse_known_args(remaining_args,
2495
+ namespace)
2496
+ finally:
2497
+ # restore parser values before exiting
2498
+ for action in optionals:
2499
+ action.required = action.save_required
2500
+ for group in self._mutually_exclusive_groups:
2501
+ group.required = group.save_required
2502
+ finally:
2503
+ self.usage = save_usage
2504
+ return namespace, extras
2505
+
2506
+ # ========================
2507
+ # Value conversion methods
2508
+ # ========================
2509
+ def _get_values(self, action, arg_strings):
2510
+ # optional argument produces a default when not present
2511
+ if not arg_strings and action.nargs == OPTIONAL:
2512
+ if action.option_strings:
2513
+ value = action.const
2514
+ else:
2515
+ value = action.default
2516
+ if isinstance(value, str) and value is not SUPPRESS:
2517
+ value = self._get_value(action, value)
2518
+ self._check_value(action, value)
2519
+
2520
+ # when nargs='*' on a positional, if there were no command-line
2521
+ # args, use the default if it is anything other than None
2522
+ elif (not arg_strings and action.nargs == ZERO_OR_MORE and
2523
+ not action.option_strings):
2524
+ if action.default is not None:
2525
+ value = action.default
2526
+ self._check_value(action, value)
2527
+ else:
2528
+ # since arg_strings is always [] at this point
2529
+ # there is no need to use self._check_value(action, value)
2530
+ value = arg_strings
2531
+
2532
+ # single argument or optional argument produces a single value
2533
+ elif len(arg_strings) == 1 and action.nargs in [None, OPTIONAL]:
2534
+ arg_string, = arg_strings
2535
+ value = self._get_value(action, arg_string)
2536
+ self._check_value(action, value)
2537
+
2538
+ # REMAINDER arguments convert all values, checking none
2539
+ elif action.nargs == REMAINDER:
2540
+ value = [self._get_value(action, v) for v in arg_strings]
2541
+
2542
+ # PARSER arguments convert all values, but check only the first
2543
+ elif action.nargs == PARSER:
2544
+ value = [self._get_value(action, v) for v in arg_strings]
2545
+ self._check_value(action, value[0])
2546
+
2547
+ # SUPPRESS argument does not put anything in the namespace
2548
+ elif action.nargs == SUPPRESS:
2549
+ value = SUPPRESS
2550
+
2551
+ # all other types of nargs produce a list
2552
+ else:
2553
+ value = [self._get_value(action, v) for v in arg_strings]
2554
+ for v in value:
2555
+ self._check_value(action, v)
2556
+
2557
+ # return the converted value
2558
+ return value
2559
+
2560
+ def _get_value(self, action, arg_string):
2561
+ type_func = self._registry_get('type', action.type, action.type)
2562
+ if not callable(type_func):
2563
+ msg = _('%r is not callable')
2564
+ raise ArgumentError(action, msg % type_func)
2565
+
2566
+ # convert the value to the appropriate type
2567
+ try:
2568
+ result = type_func(arg_string)
2569
+
2570
+ # ArgumentTypeErrors indicate errors
2571
+ except ArgumentTypeError as err:
2572
+ msg = str(err)
2573
+ raise ArgumentError(action, msg)
2574
+
2575
+ # TypeErrors or ValueErrors also indicate errors
2576
+ except (TypeError, ValueError):
2577
+ name = getattr(action.type, '__name__', repr(action.type))
2578
+ args = {'type': name, 'value': arg_string}
2579
+ msg = _('invalid %(type)s value: %(value)r')
2580
+ raise ArgumentError(action, msg % args)
2581
+
2582
+ # return the converted value
2583
+ return result
2584
+
2585
+ def _check_value(self, action, value):
2586
+ # converted value must be one of the choices (if specified)
2587
+ choices = action.choices
2588
+ if choices is not None:
2589
+ if isinstance(choices, str):
2590
+ choices = iter(choices)
2591
+ if value not in choices:
2592
+ args = {'value': value,
2593
+ 'choices': ', '.join(map(repr, action.choices))}
2594
+ msg = _('invalid choice: %(value)r (choose from %(choices)s)')
2595
+ raise ArgumentError(action, msg % args)
2596
+
2597
+ # =======================
2598
+ # Help-formatting methods
2599
+ # =======================
2600
+ def format_usage(self):
2601
+ formatter = self._get_formatter()
2602
+ formatter.add_usage(self.usage, self._actions,
2603
+ self._mutually_exclusive_groups)
2604
+ return formatter.format_help()
2605
+
2606
+ def format_help(self):
2607
+ formatter = self._get_formatter()
2608
+
2609
+ # usage
2610
+ formatter.add_usage(self.usage, self._actions,
2611
+ self._mutually_exclusive_groups)
2612
+
2613
+ # description
2614
+ formatter.add_text(self.description)
2615
+
2616
+ # positionals, optionals and user-defined groups
2617
+ for action_group in self._action_groups:
2618
+ formatter.start_section(action_group.title)
2619
+ formatter.add_text(action_group.description)
2620
+ formatter.add_arguments(action_group._group_actions)
2621
+ formatter.end_section()
2622
+
2623
+ # epilog
2624
+ formatter.add_text(self.epilog)
2625
+
2626
+ # determine help from format above
2627
+ return formatter.format_help()
2628
+
2629
+ def _get_formatter(self):
2630
+ return self.formatter_class(prog=self.prog)
2631
+
2632
+ # =====================
2633
+ # Help-printing methods
2634
+ # =====================
2635
+ def print_usage(self, file=None):
2636
+ if file is None:
2637
+ file = _sys.stdout
2638
+ self._print_message(self.format_usage(), file)
2639
+
2640
+ def print_help(self, file=None):
2641
+ if file is None:
2642
+ file = _sys.stdout
2643
+ self._print_message(self.format_help(), file)
2644
+
2645
+ def _print_message(self, message, file=None):
2646
+ if message:
2647
+ file = file or _sys.stderr
2648
+ try:
2649
+ file.write(message)
2650
+ except (AttributeError, OSError):
2651
+ pass
2652
+
2653
+ # ===============
2654
+ # Exiting methods
2655
+ # ===============
2656
+ def exit(self, status=0, message=None):
2657
+ if message:
2658
+ self._print_message(message, _sys.stderr)
2659
+ _sys.exit(status)
2660
+
2661
+ def error(self, message):
2662
+ """error(message: string)
2663
+
2664
+ Prints a usage message incorporating the message to stderr and
2665
+ exits.
2666
+
2667
+ If you override this in a subclass, it should not return -- it
2668
+ should either exit or raise an exception.
2669
+ """
2670
+ self.print_usage(_sys.stderr)
2671
+ args = {'prog': self.prog, 'message': message}
2672
+ self.exit(2, _('%(prog)s: error: %(message)s\n') % args)