@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,2941 @@
1
+ #!/usr/bin/env python3
2
+ """Generate Python documentation in HTML or text for interactive use.
3
+
4
+ At the Python interactive prompt, calling help(thing) on a Python object
5
+ documents the object, and calling help() starts up an interactive
6
+ help session.
7
+
8
+ Or, at the shell command line outside of Python:
9
+
10
+ Run "pydoc <name>" to show documentation on something. <name> may be
11
+ the name of a function, module, package, or a dotted reference to a
12
+ class or function within a module or module in a package. If the
13
+ argument contains a path segment delimiter (e.g. slash on Unix,
14
+ backslash on Windows) it is treated as the path to a Python source file.
15
+
16
+ Run "pydoc -k <keyword>" to search for a keyword in the synopsis lines
17
+ of all available modules.
18
+
19
+ Run "pydoc -n <hostname>" to start an HTTP server with the given
20
+ hostname (default: localhost) on the local machine.
21
+
22
+ Run "pydoc -p <port>" to start an HTTP server on the given port on the
23
+ local machine. Port number 0 can be used to get an arbitrary unused port.
24
+
25
+ Run "pydoc -b" to start an HTTP server on an arbitrary unused port and
26
+ open a web browser to interactively browse documentation. Combine with
27
+ the -n and -p options to control the hostname and port used.
28
+
29
+ Run "pydoc -w <name>" to write out the HTML documentation for a module
30
+ to a file named "<name>.html".
31
+
32
+ Module docs for core modules are assumed to be in
33
+
34
+ https://docs.python.org/X.Y/library/
35
+
36
+ This can be overridden by setting the PYTHONDOCS environment variable
37
+ to a different URL or to a local directory containing the Library
38
+ Reference Manual pages.
39
+ """
40
+ __all__ = ['help']
41
+ __author__ = "Ka-Ping Yee <ping@lfw.org>"
42
+ __date__ = "26 February 2001"
43
+
44
+ __credits__ = """Guido van Rossum, for an excellent programming language.
45
+ Tommy Burnette, the original creator of manpy.
46
+ Paul Prescod, for all his work on onlinehelp.
47
+ Richard Chamberlain, for the first implementation of textdoc.
48
+ """
49
+
50
+ # Known bugs that can't be fixed here:
51
+ # - synopsis() cannot be prevented from clobbering existing
52
+ # loaded modules.
53
+ # - If the __file__ attribute on a module is a relative path and
54
+ # the current directory is changed with os.chdir(), an incorrect
55
+ # path will be displayed.
56
+
57
+ import __future__
58
+ import builtins
59
+ import importlib._bootstrap
60
+ import importlib._bootstrap_external
61
+ import importlib.machinery
62
+ import importlib.util
63
+ import inspect
64
+ import io
65
+ import os
66
+ import pkgutil
67
+ import platform
68
+ import re
69
+ import sys
70
+ import sysconfig
71
+ import time
72
+ import tokenize
73
+ import urllib.parse
74
+ import warnings
75
+ from collections import deque
76
+ from reprlib import Repr
77
+ from traceback import format_exception_only
78
+
79
+
80
+ # --------------------------------------------------------- common routines
81
+
82
+ def pathdirs():
83
+ """Convert sys.path into a list of absolute, existing, unique paths."""
84
+ dirs = []
85
+ normdirs = []
86
+ for dir in sys.path:
87
+ dir = os.path.abspath(dir or '.')
88
+ normdir = os.path.normcase(dir)
89
+ if normdir not in normdirs and os.path.isdir(dir):
90
+ dirs.append(dir)
91
+ normdirs.append(normdir)
92
+ return dirs
93
+
94
+ def _findclass(func):
95
+ cls = sys.modules.get(func.__module__)
96
+ if cls is None:
97
+ return None
98
+ for name in func.__qualname__.split('.')[:-1]:
99
+ cls = getattr(cls, name)
100
+ if not inspect.isclass(cls):
101
+ return None
102
+ return cls
103
+
104
+ def _finddoc(obj):
105
+ if inspect.ismethod(obj):
106
+ name = obj.__func__.__name__
107
+ self = obj.__self__
108
+ if (inspect.isclass(self) and
109
+ getattr(getattr(self, name, None), '__func__') is obj.__func__):
110
+ # classmethod
111
+ cls = self
112
+ else:
113
+ cls = self.__class__
114
+ elif inspect.isfunction(obj):
115
+ name = obj.__name__
116
+ cls = _findclass(obj)
117
+ if cls is None or getattr(cls, name) is not obj:
118
+ return None
119
+ elif inspect.isbuiltin(obj):
120
+ name = obj.__name__
121
+ self = obj.__self__
122
+ if (inspect.isclass(self) and
123
+ self.__qualname__ + '.' + name == obj.__qualname__):
124
+ # classmethod
125
+ cls = self
126
+ else:
127
+ cls = self.__class__
128
+ # Should be tested before isdatadescriptor().
129
+ elif isinstance(obj, property):
130
+ func = obj.fget
131
+ name = func.__name__
132
+ cls = _findclass(func)
133
+ if cls is None or getattr(cls, name) is not obj:
134
+ return None
135
+ elif inspect.ismethoddescriptor(obj) or inspect.isdatadescriptor(obj):
136
+ name = obj.__name__
137
+ cls = obj.__objclass__
138
+ if getattr(cls, name) is not obj:
139
+ return None
140
+ if inspect.ismemberdescriptor(obj):
141
+ slots = getattr(cls, '__slots__', None)
142
+ if isinstance(slots, dict) and name in slots:
143
+ return slots[name]
144
+ else:
145
+ return None
146
+ for base in cls.__mro__:
147
+ try:
148
+ doc = _getowndoc(getattr(base, name))
149
+ except AttributeError:
150
+ continue
151
+ if doc is not None:
152
+ return doc
153
+ return None
154
+
155
+ def _getowndoc(obj):
156
+ """Get the documentation string for an object if it is not
157
+ inherited from its class."""
158
+ try:
159
+ doc = object.__getattribute__(obj, '__doc__')
160
+ if doc is None:
161
+ return None
162
+ if obj is not type:
163
+ typedoc = type(obj).__doc__
164
+ if isinstance(typedoc, str) and typedoc == doc:
165
+ return None
166
+ return doc
167
+ except AttributeError:
168
+ return None
169
+
170
+ def _getdoc(object):
171
+ """Get the documentation string for an object.
172
+
173
+ All tabs are expanded to spaces. To clean up docstrings that are
174
+ indented to line up with blocks of code, any whitespace than can be
175
+ uniformly removed from the second line onwards is removed."""
176
+ doc = _getowndoc(object)
177
+ if doc is None:
178
+ try:
179
+ doc = _finddoc(object)
180
+ except (AttributeError, TypeError):
181
+ return None
182
+ if not isinstance(doc, str):
183
+ return None
184
+ return inspect.cleandoc(doc)
185
+
186
+ def getdoc(object):
187
+ """Get the doc string or comments for an object."""
188
+ result = _getdoc(object) or inspect.getcomments(object)
189
+ return result and re.sub('^ *\n', '', result.rstrip()) or ''
190
+
191
+ def splitdoc(doc):
192
+ """Split a doc string into a synopsis line (if any) and the rest."""
193
+ lines = doc.strip().split('\n')
194
+ if len(lines) == 1:
195
+ return lines[0], ''
196
+ elif len(lines) >= 2 and not lines[1].rstrip():
197
+ return lines[0], '\n'.join(lines[2:])
198
+ return '', '\n'.join(lines)
199
+
200
+ def classname(object, modname):
201
+ """Get a class name and qualify it with a module name if necessary."""
202
+ name = object.__name__
203
+ if object.__module__ != modname:
204
+ name = object.__module__ + '.' + name
205
+ return name
206
+
207
+ def parentname(object, modname):
208
+ """Get a name of the enclosing class (qualified it with a module name
209
+ if necessary) or module."""
210
+ if '.' in object.__qualname__:
211
+ name = object.__qualname__.rpartition('.')[0]
212
+ if object.__module__ != modname:
213
+ return object.__module__ + '.' + name
214
+ else:
215
+ return name
216
+ else:
217
+ if object.__module__ != modname:
218
+ return object.__module__
219
+
220
+ def isdata(object):
221
+ """Check if an object is of a type that probably means it's data."""
222
+ return not (inspect.ismodule(object) or inspect.isclass(object) or
223
+ inspect.isroutine(object) or inspect.isframe(object) or
224
+ inspect.istraceback(object) or inspect.iscode(object))
225
+
226
+ def replace(text, *pairs):
227
+ """Do a series of global replacements on a string."""
228
+ while pairs:
229
+ text = pairs[1].join(text.split(pairs[0]))
230
+ pairs = pairs[2:]
231
+ return text
232
+
233
+ def cram(text, maxlen):
234
+ """Omit part of a string if needed to make it fit in a maximum length."""
235
+ if len(text) > maxlen:
236
+ pre = max(0, (maxlen-3)//2)
237
+ post = max(0, maxlen-3-pre)
238
+ return text[:pre] + '...' + text[len(text)-post:]
239
+ return text
240
+
241
+ _re_stripid = re.compile(r' at 0x[0-9a-f]{6,16}(>+)$', re.IGNORECASE)
242
+ def stripid(text):
243
+ """Remove the hexadecimal id from a Python object representation."""
244
+ # The behaviour of %p is implementation-dependent in terms of case.
245
+ return _re_stripid.sub(r'\1', text)
246
+
247
+ def _is_bound_method(fn):
248
+ """
249
+ Returns True if fn is a bound method, regardless of whether
250
+ fn was implemented in Python or in C.
251
+ """
252
+ if inspect.ismethod(fn):
253
+ return True
254
+ if inspect.isbuiltin(fn):
255
+ self = getattr(fn, '__self__', None)
256
+ return not (inspect.ismodule(self) or (self is None))
257
+ return False
258
+
259
+
260
+ def allmethods(cl):
261
+ methods = {}
262
+ for key, value in inspect.getmembers(cl, inspect.isroutine):
263
+ methods[key] = 1
264
+ for base in cl.__bases__:
265
+ methods.update(allmethods(base)) # all your base are belong to us
266
+ for key in methods.keys():
267
+ methods[key] = getattr(cl, key)
268
+ return methods
269
+
270
+ def _split_list(s, predicate):
271
+ """Split sequence s via predicate, and return pair ([true], [false]).
272
+
273
+ The return value is a 2-tuple of lists,
274
+ ([x for x in s if predicate(x)],
275
+ [x for x in s if not predicate(x)])
276
+ """
277
+
278
+ yes = []
279
+ no = []
280
+ for x in s:
281
+ if predicate(x):
282
+ yes.append(x)
283
+ else:
284
+ no.append(x)
285
+ return yes, no
286
+
287
+ _future_feature_names = set(__future__.all_feature_names)
288
+
289
+ def visiblename(name, all=None, obj=None):
290
+ """Decide whether to show documentation on a variable."""
291
+ # Certain special names are redundant or internal.
292
+ # XXX Remove __initializing__?
293
+ if name in {'__author__', '__builtins__', '__cached__', '__credits__',
294
+ '__date__', '__doc__', '__file__', '__spec__',
295
+ '__loader__', '__module__', '__name__', '__package__',
296
+ '__path__', '__qualname__', '__slots__', '__version__'}:
297
+ return 0
298
+ # Private names are hidden, but special names are displayed.
299
+ if name.startswith('__') and name.endswith('__'): return 1
300
+ # Namedtuples have public fields and methods with a single leading underscore
301
+ if name.startswith('_') and hasattr(obj, '_fields'):
302
+ return True
303
+ # Ignore __future__ imports.
304
+ if obj is not __future__ and name in _future_feature_names:
305
+ if isinstance(getattr(obj, name, None), __future__._Feature):
306
+ return False
307
+ if all is not None:
308
+ # only document that which the programmer exported in __all__
309
+ return name in all
310
+ else:
311
+ return not name.startswith('_')
312
+
313
+ def classify_class_attrs(object):
314
+ """Wrap inspect.classify_class_attrs, with fixup for data descriptors and bound methods."""
315
+ results = []
316
+ for (name, kind, cls, value) in inspect.classify_class_attrs(object):
317
+ if inspect.isdatadescriptor(value):
318
+ kind = 'data descriptor'
319
+ if isinstance(value, property) and value.fset is None:
320
+ kind = 'readonly property'
321
+ elif kind == 'method' and _is_bound_method(value):
322
+ kind = 'static method'
323
+ results.append((name, kind, cls, value))
324
+ return results
325
+
326
+ def sort_attributes(attrs, object):
327
+ 'Sort the attrs list in-place by _fields and then alphabetically by name'
328
+ # This allows data descriptors to be ordered according
329
+ # to a _fields attribute if present.
330
+ fields = getattr(object, '_fields', [])
331
+ try:
332
+ field_order = {name : i-len(fields) for (i, name) in enumerate(fields)}
333
+ except TypeError:
334
+ field_order = {}
335
+ keyfunc = lambda attr: (field_order.get(attr[0], 0), attr[0])
336
+ attrs.sort(key=keyfunc)
337
+
338
+ # ----------------------------------------------------- module manipulation
339
+
340
+ def ispackage(path):
341
+ """Guess whether a path refers to a package directory."""
342
+ if os.path.isdir(path):
343
+ for ext in ('.py', '.pyc'):
344
+ if os.path.isfile(os.path.join(path, '__init__' + ext)):
345
+ return True
346
+ return False
347
+
348
+ def source_synopsis(file):
349
+ line = file.readline()
350
+ while line[:1] == '#' or not line.strip():
351
+ line = file.readline()
352
+ if not line: break
353
+ line = line.strip()
354
+ if line[:4] == 'r"""': line = line[1:]
355
+ if line[:3] == '"""':
356
+ line = line[3:]
357
+ if line[-1:] == '\\': line = line[:-1]
358
+ while not line.strip():
359
+ line = file.readline()
360
+ if not line: break
361
+ result = line.split('"""')[0].strip()
362
+ else: result = None
363
+ return result
364
+
365
+ def synopsis(filename, cache={}):
366
+ """Get the one-line summary out of a module file."""
367
+ mtime = os.stat(filename).st_mtime
368
+ lastupdate, result = cache.get(filename, (None, None))
369
+ if lastupdate is None or lastupdate < mtime:
370
+ # Look for binary suffixes first, falling back to source.
371
+ if filename.endswith(tuple(importlib.machinery.BYTECODE_SUFFIXES)):
372
+ loader_cls = importlib.machinery.SourcelessFileLoader
373
+ elif filename.endswith(tuple(importlib.machinery.EXTENSION_SUFFIXES)):
374
+ loader_cls = importlib.machinery.ExtensionFileLoader
375
+ else:
376
+ loader_cls = None
377
+ # Now handle the choice.
378
+ if loader_cls is None:
379
+ # Must be a source file.
380
+ try:
381
+ file = tokenize.open(filename)
382
+ except OSError:
383
+ # module can't be opened, so skip it
384
+ return None
385
+ # text modules can be directly examined
386
+ with file:
387
+ result = source_synopsis(file)
388
+ else:
389
+ # Must be a binary module, which has to be imported.
390
+ loader = loader_cls('__temp__', filename)
391
+ # XXX We probably don't need to pass in the loader here.
392
+ spec = importlib.util.spec_from_file_location('__temp__', filename,
393
+ loader=loader)
394
+ try:
395
+ module = importlib._bootstrap._load(spec)
396
+ except:
397
+ return None
398
+ del sys.modules['__temp__']
399
+ result = module.__doc__.splitlines()[0] if module.__doc__ else None
400
+ # Cache the result.
401
+ cache[filename] = (mtime, result)
402
+ return result
403
+
404
+ class ErrorDuringImport(Exception):
405
+ """Errors that occurred while trying to import something to document it."""
406
+ def __init__(self, filename, exc_info):
407
+ if not isinstance(exc_info, tuple):
408
+ assert isinstance(exc_info, BaseException)
409
+ self.exc = type(exc_info)
410
+ self.value = exc_info
411
+ self.tb = exc_info.__traceback__
412
+ else:
413
+ warnings.warn("A tuple value for exc_info is deprecated, use an exception instance",
414
+ DeprecationWarning)
415
+
416
+ self.exc, self.value, self.tb = exc_info
417
+ self.filename = filename
418
+
419
+ def __str__(self):
420
+ exc = self.exc.__name__
421
+ return 'problem in %s - %s: %s' % (self.filename, exc, self.value)
422
+
423
+ def importfile(path):
424
+ """Import a Python source file or compiled file given its path."""
425
+ magic = importlib.util.MAGIC_NUMBER
426
+ with open(path, 'rb') as file:
427
+ is_bytecode = magic == file.read(len(magic))
428
+ filename = os.path.basename(path)
429
+ name, ext = os.path.splitext(filename)
430
+ if is_bytecode:
431
+ loader = importlib._bootstrap_external.SourcelessFileLoader(name, path)
432
+ else:
433
+ loader = importlib._bootstrap_external.SourceFileLoader(name, path)
434
+ # XXX We probably don't need to pass in the loader here.
435
+ spec = importlib.util.spec_from_file_location(name, path, loader=loader)
436
+ try:
437
+ return importlib._bootstrap._load(spec)
438
+ except BaseException as err:
439
+ raise ErrorDuringImport(path, err)
440
+
441
+ def safeimport(path, forceload=0, cache={}):
442
+ """Import a module; handle errors; return None if the module isn't found.
443
+
444
+ If the module *is* found but an exception occurs, it's wrapped in an
445
+ ErrorDuringImport exception and reraised. Unlike __import__, if a
446
+ package path is specified, the module at the end of the path is returned,
447
+ not the package at the beginning. If the optional 'forceload' argument
448
+ is 1, we reload the module from disk (unless it's a dynamic extension)."""
449
+ try:
450
+ # If forceload is 1 and the module has been previously loaded from
451
+ # disk, we always have to reload the module. Checking the file's
452
+ # mtime isn't good enough (e.g. the module could contain a class
453
+ # that inherits from another module that has changed).
454
+ if forceload and path in sys.modules:
455
+ if path not in sys.builtin_module_names:
456
+ # Remove the module from sys.modules and re-import to try
457
+ # and avoid problems with partially loaded modules.
458
+ # Also remove any submodules because they won't appear
459
+ # in the newly loaded module's namespace if they're already
460
+ # in sys.modules.
461
+ subs = [m for m in sys.modules if m.startswith(path + '.')]
462
+ for key in [path] + subs:
463
+ # Prevent garbage collection.
464
+ cache[key] = sys.modules[key]
465
+ del sys.modules[key]
466
+ module = importlib.import_module(path)
467
+ except BaseException as err:
468
+ # Did the error occur before or after the module was found?
469
+ if path in sys.modules:
470
+ # An error occurred while executing the imported module.
471
+ raise ErrorDuringImport(sys.modules[path].__file__, err)
472
+ elif type(err) is SyntaxError:
473
+ # A SyntaxError occurred before we could execute the module.
474
+ raise ErrorDuringImport(err.filename, err)
475
+ elif isinstance(err, ImportError) and err.name == path:
476
+ # No such module in the path.
477
+ return None
478
+ else:
479
+ # Some other error occurred during the importing process.
480
+ raise ErrorDuringImport(path, err)
481
+ return module
482
+
483
+ # ---------------------------------------------------- formatter base class
484
+
485
+ class Doc:
486
+
487
+ PYTHONDOCS = os.environ.get("PYTHONDOCS",
488
+ "https://docs.python.org/%d.%d/library"
489
+ % sys.version_info[:2])
490
+
491
+ def document(self, object, name=None, *args):
492
+ """Generate documentation for an object."""
493
+ args = (object, name) + args
494
+ # 'try' clause is to attempt to handle the possibility that inspect
495
+ # identifies something in a way that pydoc itself has issues handling;
496
+ # think 'super' and how it is a descriptor (which raises the exception
497
+ # by lacking a __name__ attribute) and an instance.
498
+ try:
499
+ if inspect.ismodule(object): return self.docmodule(*args)
500
+ if inspect.isclass(object): return self.docclass(*args)
501
+ if inspect.isroutine(object): return self.docroutine(*args)
502
+ except AttributeError:
503
+ pass
504
+ if inspect.isdatadescriptor(object): return self.docdata(*args)
505
+ return self.docother(*args)
506
+
507
+ def fail(self, object, name=None, *args):
508
+ """Raise an exception for unimplemented types."""
509
+ message = "don't know how to document object%s of type %s" % (
510
+ name and ' ' + repr(name), type(object).__name__)
511
+ raise TypeError(message)
512
+
513
+ docmodule = docclass = docroutine = docother = docproperty = docdata = fail
514
+
515
+ def getdocloc(self, object, basedir=sysconfig.get_path('stdlib')):
516
+ """Return the location of module docs or None"""
517
+
518
+ try:
519
+ file = inspect.getabsfile(object)
520
+ except TypeError:
521
+ file = '(built-in)'
522
+
523
+ docloc = os.environ.get("PYTHONDOCS", self.PYTHONDOCS)
524
+
525
+ basedir = os.path.normcase(basedir)
526
+ if (isinstance(object, type(os)) and
527
+ (object.__name__ in ('errno', 'exceptions', 'gc',
528
+ 'marshal', 'posix', 'signal', 'sys',
529
+ '_thread', 'zipimport') or
530
+ (file.startswith(basedir) and
531
+ not file.startswith(os.path.join(basedir, 'site-packages')))) and
532
+ object.__name__ not in ('xml.etree', 'test.test_pydoc.pydoc_mod')):
533
+ if docloc.startswith(("http://", "https://")):
534
+ docloc = "{}/{}.html".format(docloc.rstrip("/"), object.__name__.lower())
535
+ else:
536
+ docloc = os.path.join(docloc, object.__name__.lower() + ".html")
537
+ else:
538
+ docloc = None
539
+ return docloc
540
+
541
+ # -------------------------------------------- HTML documentation generator
542
+
543
+ class HTMLRepr(Repr):
544
+ """Class for safely making an HTML representation of a Python object."""
545
+ def __init__(self):
546
+ Repr.__init__(self)
547
+ self.maxlist = self.maxtuple = 20
548
+ self.maxdict = 10
549
+ self.maxstring = self.maxother = 100
550
+
551
+ def escape(self, text):
552
+ return replace(text, '&', '&amp;', '<', '&lt;', '>', '&gt;')
553
+
554
+ def repr(self, object):
555
+ return Repr.repr(self, object)
556
+
557
+ def repr1(self, x, level):
558
+ if hasattr(type(x), '__name__'):
559
+ methodname = 'repr_' + '_'.join(type(x).__name__.split())
560
+ if hasattr(self, methodname):
561
+ return getattr(self, methodname)(x, level)
562
+ return self.escape(cram(stripid(repr(x)), self.maxother))
563
+
564
+ def repr_string(self, x, level):
565
+ test = cram(x, self.maxstring)
566
+ testrepr = repr(test)
567
+ if '\\' in test and '\\' not in replace(testrepr, r'\\', ''):
568
+ # Backslashes are only literal in the string and are never
569
+ # needed to make any special characters, so show a raw string.
570
+ return 'r' + testrepr[0] + self.escape(test) + testrepr[0]
571
+ return re.sub(r'((\\[\\abfnrtv\'"]|\\[0-9]..|\\x..|\\u....)+)',
572
+ r'<span class="repr">\1</span>',
573
+ self.escape(testrepr))
574
+
575
+ repr_str = repr_string
576
+
577
+ def repr_instance(self, x, level):
578
+ try:
579
+ return self.escape(cram(stripid(repr(x)), self.maxstring))
580
+ except:
581
+ return self.escape('<%s instance>' % x.__class__.__name__)
582
+
583
+ repr_unicode = repr_string
584
+
585
+ class HTMLDoc(Doc):
586
+ """Formatter class for HTML documentation."""
587
+
588
+ # ------------------------------------------- HTML formatting utilities
589
+
590
+ _repr_instance = HTMLRepr()
591
+ repr = _repr_instance.repr
592
+ escape = _repr_instance.escape
593
+
594
+ def page(self, title, contents):
595
+ """Format an HTML page."""
596
+ return '''\
597
+ <!DOCTYPE html>
598
+ <html lang="en">
599
+ <head>
600
+ <meta charset="utf-8">
601
+ <title>Python: %s</title>
602
+ </head><body>
603
+ %s
604
+ </body></html>''' % (title, contents)
605
+
606
+ def heading(self, title, extras=''):
607
+ """Format a page heading."""
608
+ return '''
609
+ <table class="heading">
610
+ <tr class="heading-text decor">
611
+ <td class="title">&nbsp;<br>%s</td>
612
+ <td class="extra">%s</td></tr></table>
613
+ ''' % (title, extras or '&nbsp;')
614
+
615
+ def section(self, title, cls, contents, width=6,
616
+ prelude='', marginalia=None, gap='&nbsp;'):
617
+ """Format a section with a heading."""
618
+ if marginalia is None:
619
+ marginalia = '<span class="code">' + '&nbsp;' * width + '</span>'
620
+ result = '''<p>
621
+ <table class="section">
622
+ <tr class="decor %s-decor heading-text">
623
+ <td class="section-title" colspan=3>&nbsp;<br>%s</td></tr>
624
+ ''' % (cls, title)
625
+ if prelude:
626
+ result = result + '''
627
+ <tr><td class="decor %s-decor" rowspan=2>%s</td>
628
+ <td class="decor %s-decor" colspan=2>%s</td></tr>
629
+ <tr><td>%s</td>''' % (cls, marginalia, cls, prelude, gap)
630
+ else:
631
+ result = result + '''
632
+ <tr><td class="decor %s-decor">%s</td><td>%s</td>''' % (cls, marginalia, gap)
633
+
634
+ return result + '\n<td class="singlecolumn">%s</td></tr></table>' % contents
635
+
636
+ def bigsection(self, title, *args):
637
+ """Format a section with a big heading."""
638
+ title = '<strong class="bigsection">%s</strong>' % title
639
+ return self.section(title, *args)
640
+
641
+ def preformat(self, text):
642
+ """Format literal preformatted text."""
643
+ text = self.escape(text.expandtabs())
644
+ return replace(text, '\n\n', '\n \n', '\n\n', '\n \n',
645
+ ' ', '&nbsp;', '\n', '<br>\n')
646
+
647
+ def multicolumn(self, list, format):
648
+ """Format a list of items into a multi-column list."""
649
+ result = ''
650
+ rows = (len(list) + 3) // 4
651
+ for col in range(4):
652
+ result = result + '<td class="multicolumn">'
653
+ for i in range(rows*col, rows*col+rows):
654
+ if i < len(list):
655
+ result = result + format(list[i]) + '<br>\n'
656
+ result = result + '</td>'
657
+ return '<table><tr>%s</tr></table>' % result
658
+
659
+ def grey(self, text): return '<span class="grey">%s</span>' % text
660
+
661
+ def namelink(self, name, *dicts):
662
+ """Make a link for an identifier, given name-to-URL mappings."""
663
+ for dict in dicts:
664
+ if name in dict:
665
+ return '<a href="%s">%s</a>' % (dict[name], name)
666
+ return name
667
+
668
+ def classlink(self, object, modname):
669
+ """Make a link for a class."""
670
+ name, module = object.__name__, sys.modules.get(object.__module__)
671
+ if hasattr(module, name) and getattr(module, name) is object:
672
+ return '<a href="%s.html#%s">%s</a>' % (
673
+ module.__name__, name, classname(object, modname))
674
+ return classname(object, modname)
675
+
676
+ def parentlink(self, object, modname):
677
+ """Make a link for the enclosing class or module."""
678
+ link = None
679
+ name, module = object.__name__, sys.modules.get(object.__module__)
680
+ if hasattr(module, name) and getattr(module, name) is object:
681
+ if '.' in object.__qualname__:
682
+ name = object.__qualname__.rpartition('.')[0]
683
+ if object.__module__ != modname:
684
+ link = '%s.html#%s' % (module.__name__, name)
685
+ else:
686
+ link = '#%s' % name
687
+ else:
688
+ if object.__module__ != modname:
689
+ link = '%s.html' % module.__name__
690
+ if link:
691
+ return '<a href="%s">%s</a>' % (link, parentname(object, modname))
692
+ else:
693
+ return parentname(object, modname)
694
+
695
+ def modulelink(self, object):
696
+ """Make a link for a module."""
697
+ return '<a href="%s.html">%s</a>' % (object.__name__, object.__name__)
698
+
699
+ def modpkglink(self, modpkginfo):
700
+ """Make a link for a module or package to display in an index."""
701
+ name, path, ispackage, shadowed = modpkginfo
702
+ if shadowed:
703
+ return self.grey(name)
704
+ if path:
705
+ url = '%s.%s.html' % (path, name)
706
+ else:
707
+ url = '%s.html' % name
708
+ if ispackage:
709
+ text = '<strong>%s</strong>&nbsp;(package)' % name
710
+ else:
711
+ text = name
712
+ return '<a href="%s">%s</a>' % (url, text)
713
+
714
+ def filelink(self, url, path):
715
+ """Make a link to source file."""
716
+ return '<a href="file:%s">%s</a>' % (url, path)
717
+
718
+ def markup(self, text, escape=None, funcs={}, classes={}, methods={}):
719
+ """Mark up some plain text, given a context of symbols to look for.
720
+ Each context dictionary maps object names to anchor names."""
721
+ escape = escape or self.escape
722
+ results = []
723
+ here = 0
724
+ pattern = re.compile(r'\b((http|https|ftp)://\S+[\w/]|'
725
+ r'RFC[- ]?(\d+)|'
726
+ r'PEP[- ]?(\d+)|'
727
+ r'(self\.)?(\w+))')
728
+ while match := pattern.search(text, here):
729
+ start, end = match.span()
730
+ results.append(escape(text[here:start]))
731
+
732
+ all, scheme, rfc, pep, selfdot, name = match.groups()
733
+ if scheme:
734
+ url = escape(all).replace('"', '&quot;')
735
+ results.append('<a href="%s">%s</a>' % (url, url))
736
+ elif rfc:
737
+ url = 'https://www.rfc-editor.org/rfc/rfc%d.txt' % int(rfc)
738
+ results.append('<a href="%s">%s</a>' % (url, escape(all)))
739
+ elif pep:
740
+ url = 'https://peps.python.org/pep-%04d/' % int(pep)
741
+ results.append('<a href="%s">%s</a>' % (url, escape(all)))
742
+ elif selfdot:
743
+ # Create a link for methods like 'self.method(...)'
744
+ # and use <strong> for attributes like 'self.attr'
745
+ if text[end:end+1] == '(':
746
+ results.append('self.' + self.namelink(name, methods))
747
+ else:
748
+ results.append('self.<strong>%s</strong>' % name)
749
+ elif text[end:end+1] == '(':
750
+ results.append(self.namelink(name, methods, funcs, classes))
751
+ else:
752
+ results.append(self.namelink(name, classes))
753
+ here = end
754
+ results.append(escape(text[here:]))
755
+ return ''.join(results)
756
+
757
+ # ---------------------------------------------- type-specific routines
758
+
759
+ def formattree(self, tree, modname, parent=None):
760
+ """Produce HTML for a class tree as given by inspect.getclasstree()."""
761
+ result = ''
762
+ for entry in tree:
763
+ if isinstance(entry, tuple):
764
+ c, bases = entry
765
+ result = result + '<dt class="heading-text">'
766
+ result = result + self.classlink(c, modname)
767
+ if bases and bases != (parent,):
768
+ parents = []
769
+ for base in bases:
770
+ parents.append(self.classlink(base, modname))
771
+ result = result + '(' + ', '.join(parents) + ')'
772
+ result = result + '\n</dt>'
773
+ elif isinstance(entry, list):
774
+ result = result + '<dd>\n%s</dd>\n' % self.formattree(
775
+ entry, modname, c)
776
+ return '<dl>\n%s</dl>\n' % result
777
+
778
+ def docmodule(self, object, name=None, mod=None, *ignored):
779
+ """Produce HTML documentation for a module object."""
780
+ name = object.__name__ # ignore the passed-in name
781
+ try:
782
+ all = object.__all__
783
+ except AttributeError:
784
+ all = None
785
+ parts = name.split('.')
786
+ links = []
787
+ for i in range(len(parts)-1):
788
+ links.append(
789
+ '<a href="%s.html" class="white">%s</a>' %
790
+ ('.'.join(parts[:i+1]), parts[i]))
791
+ linkedname = '.'.join(links + parts[-1:])
792
+ head = '<strong class="title">%s</strong>' % linkedname
793
+ try:
794
+ path = inspect.getabsfile(object)
795
+ url = urllib.parse.quote(path)
796
+ filelink = self.filelink(url, path)
797
+ except TypeError:
798
+ filelink = '(built-in)'
799
+ info = []
800
+ if hasattr(object, '__version__'):
801
+ version = str(object.__version__)
802
+ if version[:11] == '$' + 'Revision: ' and version[-1:] == '$':
803
+ version = version[11:-1].strip()
804
+ info.append('version %s' % self.escape(version))
805
+ if hasattr(object, '__date__'):
806
+ info.append(self.escape(str(object.__date__)))
807
+ if info:
808
+ head = head + ' (%s)' % ', '.join(info)
809
+ docloc = self.getdocloc(object)
810
+ if docloc is not None:
811
+ docloc = '<br><a href="%(docloc)s">Module Reference</a>' % locals()
812
+ else:
813
+ docloc = ''
814
+ result = self.heading(head, '<a href=".">index</a><br>' + filelink + docloc)
815
+
816
+ modules = inspect.getmembers(object, inspect.ismodule)
817
+
818
+ classes, cdict = [], {}
819
+ for key, value in inspect.getmembers(object, inspect.isclass):
820
+ # if __all__ exists, believe it. Otherwise use old heuristic.
821
+ if (all is not None or
822
+ (inspect.getmodule(value) or object) is object):
823
+ if visiblename(key, all, object):
824
+ classes.append((key, value))
825
+ cdict[key] = cdict[value] = '#' + key
826
+ for key, value in classes:
827
+ for base in value.__bases__:
828
+ key, modname = base.__name__, base.__module__
829
+ module = sys.modules.get(modname)
830
+ if modname != name and module and hasattr(module, key):
831
+ if getattr(module, key) is base:
832
+ if not key in cdict:
833
+ cdict[key] = cdict[base] = modname + '.html#' + key
834
+ funcs, fdict = [], {}
835
+ for key, value in inspect.getmembers(object, inspect.isroutine):
836
+ # if __all__ exists, believe it. Otherwise use old heuristic.
837
+ if (all is not None or
838
+ inspect.isbuiltin(value) or inspect.getmodule(value) is object):
839
+ if visiblename(key, all, object):
840
+ funcs.append((key, value))
841
+ fdict[key] = '#-' + key
842
+ if inspect.isfunction(value): fdict[value] = fdict[key]
843
+ data = []
844
+ for key, value in inspect.getmembers(object, isdata):
845
+ if visiblename(key, all, object):
846
+ data.append((key, value))
847
+
848
+ doc = self.markup(getdoc(object), self.preformat, fdict, cdict)
849
+ doc = doc and '<span class="code">%s</span>' % doc
850
+ result = result + '<p>%s</p>\n' % doc
851
+
852
+ if hasattr(object, '__path__'):
853
+ modpkgs = []
854
+ for importer, modname, ispkg in pkgutil.iter_modules(object.__path__):
855
+ modpkgs.append((modname, name, ispkg, 0))
856
+ modpkgs.sort()
857
+ contents = self.multicolumn(modpkgs, self.modpkglink)
858
+ result = result + self.bigsection(
859
+ 'Package Contents', 'pkg-content', contents)
860
+ elif modules:
861
+ contents = self.multicolumn(
862
+ modules, lambda t: self.modulelink(t[1]))
863
+ result = result + self.bigsection(
864
+ 'Modules', 'pkg-content', contents)
865
+
866
+ if classes:
867
+ classlist = [value for (key, value) in classes]
868
+ contents = [
869
+ self.formattree(inspect.getclasstree(classlist, 1), name)]
870
+ for key, value in classes:
871
+ contents.append(self.document(value, key, name, fdict, cdict))
872
+ result = result + self.bigsection(
873
+ 'Classes', 'index', ' '.join(contents))
874
+ if funcs:
875
+ contents = []
876
+ for key, value in funcs:
877
+ contents.append(self.document(value, key, name, fdict, cdict))
878
+ result = result + self.bigsection(
879
+ 'Functions', 'functions', ' '.join(contents))
880
+ if data:
881
+ contents = []
882
+ for key, value in data:
883
+ contents.append(self.document(value, key))
884
+ result = result + self.bigsection(
885
+ 'Data', 'data', '<br>\n'.join(contents))
886
+ if hasattr(object, '__author__'):
887
+ contents = self.markup(str(object.__author__), self.preformat)
888
+ result = result + self.bigsection('Author', 'author', contents)
889
+ if hasattr(object, '__credits__'):
890
+ contents = self.markup(str(object.__credits__), self.preformat)
891
+ result = result + self.bigsection('Credits', 'credits', contents)
892
+
893
+ return result
894
+
895
+ def docclass(self, object, name=None, mod=None, funcs={}, classes={},
896
+ *ignored):
897
+ """Produce HTML documentation for a class object."""
898
+ realname = object.__name__
899
+ name = name or realname
900
+ bases = object.__bases__
901
+
902
+ contents = []
903
+ push = contents.append
904
+
905
+ # Cute little class to pump out a horizontal rule between sections.
906
+ class HorizontalRule:
907
+ def __init__(self):
908
+ self.needone = 0
909
+ def maybe(self):
910
+ if self.needone:
911
+ push('<hr>\n')
912
+ self.needone = 1
913
+ hr = HorizontalRule()
914
+
915
+ # List the mro, if non-trivial.
916
+ mro = deque(inspect.getmro(object))
917
+ if len(mro) > 2:
918
+ hr.maybe()
919
+ push('<dl><dt>Method resolution order:</dt>\n')
920
+ for base in mro:
921
+ push('<dd>%s</dd>\n' % self.classlink(base,
922
+ object.__module__))
923
+ push('</dl>\n')
924
+
925
+ def spill(msg, attrs, predicate):
926
+ ok, attrs = _split_list(attrs, predicate)
927
+ if ok:
928
+ hr.maybe()
929
+ push(msg)
930
+ for name, kind, homecls, value in ok:
931
+ try:
932
+ value = getattr(object, name)
933
+ except Exception:
934
+ # Some descriptors may meet a failure in their __get__.
935
+ # (bug #1785)
936
+ push(self.docdata(value, name, mod))
937
+ else:
938
+ push(self.document(value, name, mod,
939
+ funcs, classes, mdict, object, homecls))
940
+ push('\n')
941
+ return attrs
942
+
943
+ def spilldescriptors(msg, attrs, predicate):
944
+ ok, attrs = _split_list(attrs, predicate)
945
+ if ok:
946
+ hr.maybe()
947
+ push(msg)
948
+ for name, kind, homecls, value in ok:
949
+ push(self.docdata(value, name, mod))
950
+ return attrs
951
+
952
+ def spilldata(msg, attrs, predicate):
953
+ ok, attrs = _split_list(attrs, predicate)
954
+ if ok:
955
+ hr.maybe()
956
+ push(msg)
957
+ for name, kind, homecls, value in ok:
958
+ base = self.docother(getattr(object, name), name, mod)
959
+ doc = getdoc(value)
960
+ if not doc:
961
+ push('<dl><dt>%s</dl>\n' % base)
962
+ else:
963
+ doc = self.markup(getdoc(value), self.preformat,
964
+ funcs, classes, mdict)
965
+ doc = '<dd><span class="code">%s</span>' % doc
966
+ push('<dl><dt>%s%s</dl>\n' % (base, doc))
967
+ push('\n')
968
+ return attrs
969
+
970
+ attrs = [(name, kind, cls, value)
971
+ for name, kind, cls, value in classify_class_attrs(object)
972
+ if visiblename(name, obj=object)]
973
+
974
+ mdict = {}
975
+ for key, kind, homecls, value in attrs:
976
+ mdict[key] = anchor = '#' + name + '-' + key
977
+ try:
978
+ value = getattr(object, name)
979
+ except Exception:
980
+ # Some descriptors may meet a failure in their __get__.
981
+ # (bug #1785)
982
+ pass
983
+ try:
984
+ # The value may not be hashable (e.g., a data attr with
985
+ # a dict or list value).
986
+ mdict[value] = anchor
987
+ except TypeError:
988
+ pass
989
+
990
+ while attrs:
991
+ if mro:
992
+ thisclass = mro.popleft()
993
+ else:
994
+ thisclass = attrs[0][2]
995
+ attrs, inherited = _split_list(attrs, lambda t: t[2] is thisclass)
996
+
997
+ if object is not builtins.object and thisclass is builtins.object:
998
+ attrs = inherited
999
+ continue
1000
+ elif thisclass is object:
1001
+ tag = 'defined here'
1002
+ else:
1003
+ tag = 'inherited from %s' % self.classlink(thisclass,
1004
+ object.__module__)
1005
+ tag += ':<br>\n'
1006
+
1007
+ sort_attributes(attrs, object)
1008
+
1009
+ # Pump out the attrs, segregated by kind.
1010
+ attrs = spill('Methods %s' % tag, attrs,
1011
+ lambda t: t[1] == 'method')
1012
+ attrs = spill('Class methods %s' % tag, attrs,
1013
+ lambda t: t[1] == 'class method')
1014
+ attrs = spill('Static methods %s' % tag, attrs,
1015
+ lambda t: t[1] == 'static method')
1016
+ attrs = spilldescriptors("Readonly properties %s" % tag, attrs,
1017
+ lambda t: t[1] == 'readonly property')
1018
+ attrs = spilldescriptors('Data descriptors %s' % tag, attrs,
1019
+ lambda t: t[1] == 'data descriptor')
1020
+ attrs = spilldata('Data and other attributes %s' % tag, attrs,
1021
+ lambda t: t[1] == 'data')
1022
+ assert attrs == []
1023
+ attrs = inherited
1024
+
1025
+ contents = ''.join(contents)
1026
+
1027
+ if name == realname:
1028
+ title = '<a name="%s">class <strong>%s</strong></a>' % (
1029
+ name, realname)
1030
+ else:
1031
+ title = '<strong>%s</strong> = <a name="%s">class %s</a>' % (
1032
+ name, name, realname)
1033
+ if bases:
1034
+ parents = []
1035
+ for base in bases:
1036
+ parents.append(self.classlink(base, object.__module__))
1037
+ title = title + '(%s)' % ', '.join(parents)
1038
+
1039
+ decl = ''
1040
+ try:
1041
+ signature = inspect.signature(object)
1042
+ except (ValueError, TypeError):
1043
+ signature = None
1044
+ if signature:
1045
+ argspec = str(signature)
1046
+ if argspec and argspec != '()':
1047
+ decl = name + self.escape(argspec) + '\n\n'
1048
+
1049
+ doc = getdoc(object)
1050
+ if decl:
1051
+ doc = decl + (doc or '')
1052
+ doc = self.markup(doc, self.preformat, funcs, classes, mdict)
1053
+ doc = doc and '<span class="code">%s<br>&nbsp;</span>' % doc
1054
+
1055
+ return self.section(title, 'title', contents, 3, doc)
1056
+
1057
+ def formatvalue(self, object):
1058
+ """Format an argument default value as text."""
1059
+ return self.grey('=' + self.repr(object))
1060
+
1061
+ def docroutine(self, object, name=None, mod=None,
1062
+ funcs={}, classes={}, methods={}, cl=None, homecls=None):
1063
+ """Produce HTML documentation for a function or method object."""
1064
+ realname = object.__name__
1065
+ name = name or realname
1066
+ if homecls is None:
1067
+ homecls = cl
1068
+ anchor = ('' if cl is None else cl.__name__) + '-' + name
1069
+ note = ''
1070
+ skipdocs = False
1071
+ imfunc = None
1072
+ if _is_bound_method(object):
1073
+ imself = object.__self__
1074
+ if imself is cl:
1075
+ imfunc = getattr(object, '__func__', None)
1076
+ elif inspect.isclass(imself):
1077
+ note = ' class method of %s' % self.classlink(imself, mod)
1078
+ else:
1079
+ note = ' method of %s instance' % self.classlink(
1080
+ imself.__class__, mod)
1081
+ elif (inspect.ismethoddescriptor(object) or
1082
+ inspect.ismethodwrapper(object)):
1083
+ try:
1084
+ objclass = object.__objclass__
1085
+ except AttributeError:
1086
+ pass
1087
+ else:
1088
+ if cl is None:
1089
+ note = ' unbound %s method' % self.classlink(objclass, mod)
1090
+ elif objclass is not homecls:
1091
+ note = ' from ' + self.classlink(objclass, mod)
1092
+ else:
1093
+ imfunc = object
1094
+ if inspect.isfunction(imfunc) and homecls is not None and (
1095
+ imfunc.__module__ != homecls.__module__ or
1096
+ imfunc.__qualname__ != homecls.__qualname__ + '.' + realname):
1097
+ pname = self.parentlink(imfunc, mod)
1098
+ if pname:
1099
+ note = ' from %s' % pname
1100
+
1101
+ if (inspect.iscoroutinefunction(object) or
1102
+ inspect.isasyncgenfunction(object)):
1103
+ asyncqualifier = 'async '
1104
+ else:
1105
+ asyncqualifier = ''
1106
+
1107
+ if name == realname:
1108
+ title = '<a name="%s"><strong>%s</strong></a>' % (anchor, realname)
1109
+ else:
1110
+ if (cl is not None and
1111
+ inspect.getattr_static(cl, realname, []) is object):
1112
+ reallink = '<a href="#%s">%s</a>' % (
1113
+ cl.__name__ + '-' + realname, realname)
1114
+ skipdocs = True
1115
+ if note.startswith(' from '):
1116
+ note = ''
1117
+ else:
1118
+ reallink = realname
1119
+ title = '<a name="%s"><strong>%s</strong></a> = %s' % (
1120
+ anchor, name, reallink)
1121
+ argspec = None
1122
+ if inspect.isroutine(object):
1123
+ try:
1124
+ signature = inspect.signature(object)
1125
+ except (ValueError, TypeError):
1126
+ signature = None
1127
+ if signature:
1128
+ argspec = str(signature)
1129
+ if realname == '<lambda>':
1130
+ title = '<strong>%s</strong> <em>lambda</em> ' % name
1131
+ # XXX lambda's won't usually have func_annotations['return']
1132
+ # since the syntax doesn't support but it is possible.
1133
+ # So removing parentheses isn't truly safe.
1134
+ if not object.__annotations__:
1135
+ argspec = argspec[1:-1] # remove parentheses
1136
+ if not argspec:
1137
+ argspec = '(...)'
1138
+
1139
+ decl = asyncqualifier + title + self.escape(argspec) + (note and
1140
+ self.grey('<span class="heading-text">%s</span>' % note))
1141
+
1142
+ if skipdocs:
1143
+ return '<dl><dt>%s</dt></dl>\n' % decl
1144
+ else:
1145
+ doc = self.markup(
1146
+ getdoc(object), self.preformat, funcs, classes, methods)
1147
+ doc = doc and '<dd><span class="code">%s</span></dd>' % doc
1148
+ return '<dl><dt>%s</dt>%s</dl>\n' % (decl, doc)
1149
+
1150
+ def docdata(self, object, name=None, mod=None, cl=None, *ignored):
1151
+ """Produce html documentation for a data descriptor."""
1152
+ results = []
1153
+ push = results.append
1154
+
1155
+ if name:
1156
+ push('<dl><dt><strong>%s</strong></dt>\n' % name)
1157
+ doc = self.markup(getdoc(object), self.preformat)
1158
+ if doc:
1159
+ push('<dd><span class="code">%s</span></dd>\n' % doc)
1160
+ push('</dl>\n')
1161
+
1162
+ return ''.join(results)
1163
+
1164
+ docproperty = docdata
1165
+
1166
+ def docother(self, object, name=None, mod=None, *ignored):
1167
+ """Produce HTML documentation for a data object."""
1168
+ lhs = name and '<strong>%s</strong> = ' % name or ''
1169
+ return lhs + self.repr(object)
1170
+
1171
+ def index(self, dir, shadowed=None):
1172
+ """Generate an HTML index for a directory of modules."""
1173
+ modpkgs = []
1174
+ if shadowed is None: shadowed = {}
1175
+ for importer, name, ispkg in pkgutil.iter_modules([dir]):
1176
+ if any((0xD800 <= ord(ch) <= 0xDFFF) for ch in name):
1177
+ # ignore a module if its name contains a surrogate character
1178
+ continue
1179
+ modpkgs.append((name, '', ispkg, name in shadowed))
1180
+ shadowed[name] = 1
1181
+
1182
+ modpkgs.sort()
1183
+ contents = self.multicolumn(modpkgs, self.modpkglink)
1184
+ return self.bigsection(dir, 'index', contents)
1185
+
1186
+ # -------------------------------------------- text documentation generator
1187
+
1188
+ class TextRepr(Repr):
1189
+ """Class for safely making a text representation of a Python object."""
1190
+ def __init__(self):
1191
+ Repr.__init__(self)
1192
+ self.maxlist = self.maxtuple = 20
1193
+ self.maxdict = 10
1194
+ self.maxstring = self.maxother = 100
1195
+
1196
+ def repr1(self, x, level):
1197
+ if hasattr(type(x), '__name__'):
1198
+ methodname = 'repr_' + '_'.join(type(x).__name__.split())
1199
+ if hasattr(self, methodname):
1200
+ return getattr(self, methodname)(x, level)
1201
+ return cram(stripid(repr(x)), self.maxother)
1202
+
1203
+ def repr_string(self, x, level):
1204
+ test = cram(x, self.maxstring)
1205
+ testrepr = repr(test)
1206
+ if '\\' in test and '\\' not in replace(testrepr, r'\\', ''):
1207
+ # Backslashes are only literal in the string and are never
1208
+ # needed to make any special characters, so show a raw string.
1209
+ return 'r' + testrepr[0] + test + testrepr[0]
1210
+ return testrepr
1211
+
1212
+ repr_str = repr_string
1213
+
1214
+ def repr_instance(self, x, level):
1215
+ try:
1216
+ return cram(stripid(repr(x)), self.maxstring)
1217
+ except:
1218
+ return '<%s instance>' % x.__class__.__name__
1219
+
1220
+ class TextDoc(Doc):
1221
+ """Formatter class for text documentation."""
1222
+
1223
+ # ------------------------------------------- text formatting utilities
1224
+
1225
+ _repr_instance = TextRepr()
1226
+ repr = _repr_instance.repr
1227
+
1228
+ def bold(self, text):
1229
+ """Format a string in bold by overstriking."""
1230
+ return ''.join(ch + '\b' + ch for ch in text)
1231
+
1232
+ def indent(self, text, prefix=' '):
1233
+ """Indent text by prepending a given prefix to each line."""
1234
+ if not text: return ''
1235
+ lines = [(prefix + line).rstrip() for line in text.split('\n')]
1236
+ return '\n'.join(lines)
1237
+
1238
+ def section(self, title, contents):
1239
+ """Format a section with a given heading."""
1240
+ clean_contents = self.indent(contents).rstrip()
1241
+ return self.bold(title) + '\n' + clean_contents + '\n\n'
1242
+
1243
+ # ---------------------------------------------- type-specific routines
1244
+
1245
+ def formattree(self, tree, modname, parent=None, prefix=''):
1246
+ """Render in text a class tree as returned by inspect.getclasstree()."""
1247
+ result = ''
1248
+ for entry in tree:
1249
+ if isinstance(entry, tuple):
1250
+ c, bases = entry
1251
+ result = result + prefix + classname(c, modname)
1252
+ if bases and bases != (parent,):
1253
+ parents = (classname(c, modname) for c in bases)
1254
+ result = result + '(%s)' % ', '.join(parents)
1255
+ result = result + '\n'
1256
+ elif isinstance(entry, list):
1257
+ result = result + self.formattree(
1258
+ entry, modname, c, prefix + ' ')
1259
+ return result
1260
+
1261
+ def docmodule(self, object, name=None, mod=None, *ignored):
1262
+ """Produce text documentation for a given module object."""
1263
+ name = object.__name__ # ignore the passed-in name
1264
+ synop, desc = splitdoc(getdoc(object))
1265
+ result = self.section('NAME', name + (synop and ' - ' + synop))
1266
+ all = getattr(object, '__all__', None)
1267
+ docloc = self.getdocloc(object)
1268
+ if docloc is not None:
1269
+ result = result + self.section('MODULE REFERENCE', docloc + """
1270
+
1271
+ The following documentation is automatically generated from the Python
1272
+ source files. It may be incomplete, incorrect or include features that
1273
+ are considered implementation detail and may vary between Python
1274
+ implementations. When in doubt, consult the module reference at the
1275
+ location listed above.
1276
+ """)
1277
+
1278
+ if desc:
1279
+ result = result + self.section('DESCRIPTION', desc)
1280
+
1281
+ classes = []
1282
+ for key, value in inspect.getmembers(object, inspect.isclass):
1283
+ # if __all__ exists, believe it. Otherwise use old heuristic.
1284
+ if (all is not None
1285
+ or (inspect.getmodule(value) or object) is object):
1286
+ if visiblename(key, all, object):
1287
+ classes.append((key, value))
1288
+ funcs = []
1289
+ for key, value in inspect.getmembers(object, inspect.isroutine):
1290
+ # if __all__ exists, believe it. Otherwise use old heuristic.
1291
+ if (all is not None or
1292
+ inspect.isbuiltin(value) or inspect.getmodule(value) is object):
1293
+ if visiblename(key, all, object):
1294
+ funcs.append((key, value))
1295
+ data = []
1296
+ for key, value in inspect.getmembers(object, isdata):
1297
+ if visiblename(key, all, object):
1298
+ data.append((key, value))
1299
+
1300
+ modpkgs = []
1301
+ modpkgs_names = set()
1302
+ if hasattr(object, '__path__'):
1303
+ for importer, modname, ispkg in pkgutil.iter_modules(object.__path__):
1304
+ modpkgs_names.add(modname)
1305
+ if ispkg:
1306
+ modpkgs.append(modname + ' (package)')
1307
+ else:
1308
+ modpkgs.append(modname)
1309
+
1310
+ modpkgs.sort()
1311
+ result = result + self.section(
1312
+ 'PACKAGE CONTENTS', '\n'.join(modpkgs))
1313
+
1314
+ # Detect submodules as sometimes created by C extensions
1315
+ submodules = []
1316
+ for key, value in inspect.getmembers(object, inspect.ismodule):
1317
+ if value.__name__.startswith(name + '.') and key not in modpkgs_names:
1318
+ submodules.append(key)
1319
+ if submodules:
1320
+ submodules.sort()
1321
+ result = result + self.section(
1322
+ 'SUBMODULES', '\n'.join(submodules))
1323
+
1324
+ if classes:
1325
+ classlist = [value for key, value in classes]
1326
+ contents = [self.formattree(
1327
+ inspect.getclasstree(classlist, 1), name)]
1328
+ for key, value in classes:
1329
+ contents.append(self.document(value, key, name))
1330
+ result = result + self.section('CLASSES', '\n'.join(contents))
1331
+
1332
+ if funcs:
1333
+ contents = []
1334
+ for key, value in funcs:
1335
+ contents.append(self.document(value, key, name))
1336
+ result = result + self.section('FUNCTIONS', '\n'.join(contents))
1337
+
1338
+ if data:
1339
+ contents = []
1340
+ for key, value in data:
1341
+ contents.append(self.docother(value, key, name, maxlen=70))
1342
+ result = result + self.section('DATA', '\n'.join(contents))
1343
+
1344
+ if hasattr(object, '__version__'):
1345
+ version = str(object.__version__)
1346
+ if version[:11] == '$' + 'Revision: ' and version[-1:] == '$':
1347
+ version = version[11:-1].strip()
1348
+ result = result + self.section('VERSION', version)
1349
+ if hasattr(object, '__date__'):
1350
+ result = result + self.section('DATE', str(object.__date__))
1351
+ if hasattr(object, '__author__'):
1352
+ result = result + self.section('AUTHOR', str(object.__author__))
1353
+ if hasattr(object, '__credits__'):
1354
+ result = result + self.section('CREDITS', str(object.__credits__))
1355
+ try:
1356
+ file = inspect.getabsfile(object)
1357
+ except TypeError:
1358
+ file = '(built-in)'
1359
+ result = result + self.section('FILE', file)
1360
+ return result
1361
+
1362
+ def docclass(self, object, name=None, mod=None, *ignored):
1363
+ """Produce text documentation for a given class object."""
1364
+ realname = object.__name__
1365
+ name = name or realname
1366
+ bases = object.__bases__
1367
+
1368
+ def makename(c, m=object.__module__):
1369
+ return classname(c, m)
1370
+
1371
+ if name == realname:
1372
+ title = 'class ' + self.bold(realname)
1373
+ else:
1374
+ title = self.bold(name) + ' = class ' + realname
1375
+ if bases:
1376
+ parents = map(makename, bases)
1377
+ title = title + '(%s)' % ', '.join(parents)
1378
+
1379
+ contents = []
1380
+ push = contents.append
1381
+
1382
+ try:
1383
+ signature = inspect.signature(object)
1384
+ except (ValueError, TypeError):
1385
+ signature = None
1386
+ if signature:
1387
+ argspec = str(signature)
1388
+ if argspec and argspec != '()':
1389
+ push(name + argspec + '\n')
1390
+
1391
+ doc = getdoc(object)
1392
+ if doc:
1393
+ push(doc + '\n')
1394
+
1395
+ # List the mro, if non-trivial.
1396
+ mro = deque(inspect.getmro(object))
1397
+ if len(mro) > 2:
1398
+ push("Method resolution order:")
1399
+ for base in mro:
1400
+ push(' ' + makename(base))
1401
+ push('')
1402
+
1403
+ # List the built-in subclasses, if any:
1404
+ subclasses = sorted(
1405
+ (str(cls.__name__) for cls in type.__subclasses__(object)
1406
+ if not cls.__name__.startswith("_") and cls.__module__ == "builtins"),
1407
+ key=str.lower
1408
+ )
1409
+ no_of_subclasses = len(subclasses)
1410
+ MAX_SUBCLASSES_TO_DISPLAY = 4
1411
+ if subclasses:
1412
+ push("Built-in subclasses:")
1413
+ for subclassname in subclasses[:MAX_SUBCLASSES_TO_DISPLAY]:
1414
+ push(' ' + subclassname)
1415
+ if no_of_subclasses > MAX_SUBCLASSES_TO_DISPLAY:
1416
+ push(' ... and ' +
1417
+ str(no_of_subclasses - MAX_SUBCLASSES_TO_DISPLAY) +
1418
+ ' other subclasses')
1419
+ push('')
1420
+
1421
+ # Cute little class to pump out a horizontal rule between sections.
1422
+ class HorizontalRule:
1423
+ def __init__(self):
1424
+ self.needone = 0
1425
+ def maybe(self):
1426
+ if self.needone:
1427
+ push('-' * 70)
1428
+ self.needone = 1
1429
+ hr = HorizontalRule()
1430
+
1431
+ def spill(msg, attrs, predicate):
1432
+ ok, attrs = _split_list(attrs, predicate)
1433
+ if ok:
1434
+ hr.maybe()
1435
+ push(msg)
1436
+ for name, kind, homecls, value in ok:
1437
+ try:
1438
+ value = getattr(object, name)
1439
+ except Exception:
1440
+ # Some descriptors may meet a failure in their __get__.
1441
+ # (bug #1785)
1442
+ push(self.docdata(value, name, mod))
1443
+ else:
1444
+ push(self.document(value,
1445
+ name, mod, object, homecls))
1446
+ return attrs
1447
+
1448
+ def spilldescriptors(msg, attrs, predicate):
1449
+ ok, attrs = _split_list(attrs, predicate)
1450
+ if ok:
1451
+ hr.maybe()
1452
+ push(msg)
1453
+ for name, kind, homecls, value in ok:
1454
+ push(self.docdata(value, name, mod))
1455
+ return attrs
1456
+
1457
+ def spilldata(msg, attrs, predicate):
1458
+ ok, attrs = _split_list(attrs, predicate)
1459
+ if ok:
1460
+ hr.maybe()
1461
+ push(msg)
1462
+ for name, kind, homecls, value in ok:
1463
+ doc = getdoc(value)
1464
+ try:
1465
+ obj = getattr(object, name)
1466
+ except AttributeError:
1467
+ obj = homecls.__dict__[name]
1468
+ push(self.docother(obj, name, mod, maxlen=70, doc=doc) +
1469
+ '\n')
1470
+ return attrs
1471
+
1472
+ attrs = [(name, kind, cls, value)
1473
+ for name, kind, cls, value in classify_class_attrs(object)
1474
+ if visiblename(name, obj=object)]
1475
+
1476
+ while attrs:
1477
+ if mro:
1478
+ thisclass = mro.popleft()
1479
+ else:
1480
+ thisclass = attrs[0][2]
1481
+ attrs, inherited = _split_list(attrs, lambda t: t[2] is thisclass)
1482
+
1483
+ if object is not builtins.object and thisclass is builtins.object:
1484
+ attrs = inherited
1485
+ continue
1486
+ elif thisclass is object:
1487
+ tag = "defined here"
1488
+ else:
1489
+ tag = "inherited from %s" % classname(thisclass,
1490
+ object.__module__)
1491
+
1492
+ sort_attributes(attrs, object)
1493
+
1494
+ # Pump out the attrs, segregated by kind.
1495
+ attrs = spill("Methods %s:\n" % tag, attrs,
1496
+ lambda t: t[1] == 'method')
1497
+ attrs = spill("Class methods %s:\n" % tag, attrs,
1498
+ lambda t: t[1] == 'class method')
1499
+ attrs = spill("Static methods %s:\n" % tag, attrs,
1500
+ lambda t: t[1] == 'static method')
1501
+ attrs = spilldescriptors("Readonly properties %s:\n" % tag, attrs,
1502
+ lambda t: t[1] == 'readonly property')
1503
+ attrs = spilldescriptors("Data descriptors %s:\n" % tag, attrs,
1504
+ lambda t: t[1] == 'data descriptor')
1505
+ attrs = spilldata("Data and other attributes %s:\n" % tag, attrs,
1506
+ lambda t: t[1] == 'data')
1507
+
1508
+ assert attrs == []
1509
+ attrs = inherited
1510
+
1511
+ contents = '\n'.join(contents)
1512
+ if not contents:
1513
+ return title + '\n'
1514
+ return title + '\n' + self.indent(contents.rstrip(), ' | ') + '\n'
1515
+
1516
+ def formatvalue(self, object):
1517
+ """Format an argument default value as text."""
1518
+ return '=' + self.repr(object)
1519
+
1520
+ def docroutine(self, object, name=None, mod=None, cl=None, homecls=None):
1521
+ """Produce text documentation for a function or method object."""
1522
+ realname = object.__name__
1523
+ name = name or realname
1524
+ if homecls is None:
1525
+ homecls = cl
1526
+ note = ''
1527
+ skipdocs = False
1528
+ imfunc = None
1529
+ if _is_bound_method(object):
1530
+ imself = object.__self__
1531
+ if imself is cl:
1532
+ imfunc = getattr(object, '__func__', None)
1533
+ elif inspect.isclass(imself):
1534
+ note = ' class method of %s' % classname(imself, mod)
1535
+ else:
1536
+ note = ' method of %s instance' % classname(
1537
+ imself.__class__, mod)
1538
+ elif (inspect.ismethoddescriptor(object) or
1539
+ inspect.ismethodwrapper(object)):
1540
+ try:
1541
+ objclass = object.__objclass__
1542
+ except AttributeError:
1543
+ pass
1544
+ else:
1545
+ if cl is None:
1546
+ note = ' unbound %s method' % classname(objclass, mod)
1547
+ elif objclass is not homecls:
1548
+ note = ' from ' + classname(objclass, mod)
1549
+ else:
1550
+ imfunc = object
1551
+ if inspect.isfunction(imfunc) and homecls is not None and (
1552
+ imfunc.__module__ != homecls.__module__ or
1553
+ imfunc.__qualname__ != homecls.__qualname__ + '.' + realname):
1554
+ pname = parentname(imfunc, mod)
1555
+ if pname:
1556
+ note = ' from %s' % pname
1557
+
1558
+ if (inspect.iscoroutinefunction(object) or
1559
+ inspect.isasyncgenfunction(object)):
1560
+ asyncqualifier = 'async '
1561
+ else:
1562
+ asyncqualifier = ''
1563
+
1564
+ if name == realname:
1565
+ title = self.bold(realname)
1566
+ else:
1567
+ if (cl is not None and
1568
+ inspect.getattr_static(cl, realname, []) is object):
1569
+ skipdocs = True
1570
+ if note.startswith(' from '):
1571
+ note = ''
1572
+ title = self.bold(name) + ' = ' + realname
1573
+ argspec = None
1574
+
1575
+ if inspect.isroutine(object):
1576
+ try:
1577
+ signature = inspect.signature(object)
1578
+ except (ValueError, TypeError):
1579
+ signature = None
1580
+ if signature:
1581
+ argspec = str(signature)
1582
+ if realname == '<lambda>':
1583
+ title = self.bold(name) + ' lambda '
1584
+ # XXX lambda's won't usually have func_annotations['return']
1585
+ # since the syntax doesn't support but it is possible.
1586
+ # So removing parentheses isn't truly safe.
1587
+ if not object.__annotations__:
1588
+ argspec = argspec[1:-1] # remove parentheses
1589
+ if not argspec:
1590
+ argspec = '(...)'
1591
+ decl = asyncqualifier + title + argspec + note
1592
+
1593
+ if skipdocs:
1594
+ return decl + '\n'
1595
+ else:
1596
+ doc = getdoc(object) or ''
1597
+ return decl + '\n' + (doc and self.indent(doc).rstrip() + '\n')
1598
+
1599
+ def docdata(self, object, name=None, mod=None, cl=None, *ignored):
1600
+ """Produce text documentation for a data descriptor."""
1601
+ results = []
1602
+ push = results.append
1603
+
1604
+ if name:
1605
+ push(self.bold(name))
1606
+ push('\n')
1607
+ doc = getdoc(object) or ''
1608
+ if doc:
1609
+ push(self.indent(doc))
1610
+ push('\n')
1611
+ return ''.join(results)
1612
+
1613
+ docproperty = docdata
1614
+
1615
+ def docother(self, object, name=None, mod=None, parent=None, *ignored,
1616
+ maxlen=None, doc=None):
1617
+ """Produce text documentation for a data object."""
1618
+ repr = self.repr(object)
1619
+ if maxlen:
1620
+ line = (name and name + ' = ' or '') + repr
1621
+ chop = maxlen - len(line)
1622
+ if chop < 0: repr = repr[:chop] + '...'
1623
+ line = (name and self.bold(name) + ' = ' or '') + repr
1624
+ if not doc:
1625
+ doc = getdoc(object)
1626
+ if doc:
1627
+ line += '\n' + self.indent(str(doc)) + '\n'
1628
+ return line
1629
+
1630
+ class _PlainTextDoc(TextDoc):
1631
+ """Subclass of TextDoc which overrides string styling"""
1632
+ def bold(self, text):
1633
+ return text
1634
+
1635
+ # --------------------------------------------------------- user interfaces
1636
+
1637
+ def pager(text):
1638
+ """The first time this is called, determine what kind of pager to use."""
1639
+ global pager
1640
+ pager = getpager()
1641
+ pager(text)
1642
+
1643
+ def getpager():
1644
+ """Decide what method to use for paging through text."""
1645
+ if not hasattr(sys.stdin, "isatty"):
1646
+ return plainpager
1647
+ if not hasattr(sys.stdout, "isatty"):
1648
+ return plainpager
1649
+ if not sys.stdin.isatty() or not sys.stdout.isatty():
1650
+ return plainpager
1651
+ if sys.platform == "emscripten":
1652
+ return plainpager
1653
+ use_pager = os.environ.get('MANPAGER') or os.environ.get('PAGER')
1654
+ if use_pager:
1655
+ if sys.platform == 'win32': # pipes completely broken in Windows
1656
+ return lambda text: tempfilepager(plain(text), use_pager)
1657
+ elif os.environ.get('TERM') in ('dumb', 'emacs'):
1658
+ return lambda text: pipepager(plain(text), use_pager)
1659
+ else:
1660
+ return lambda text: pipepager(text, use_pager)
1661
+ if os.environ.get('TERM') in ('dumb', 'emacs'):
1662
+ return plainpager
1663
+ if sys.platform == 'win32':
1664
+ return lambda text: tempfilepager(plain(text), 'more <')
1665
+ if hasattr(os, 'system') and os.system('(less) 2>/dev/null') == 0:
1666
+ return lambda text: pipepager(text, 'less')
1667
+
1668
+ import tempfile
1669
+ (fd, filename) = tempfile.mkstemp()
1670
+ os.close(fd)
1671
+ try:
1672
+ if hasattr(os, 'system') and os.system('more "%s"' % filename) == 0:
1673
+ return lambda text: pipepager(text, 'more')
1674
+ else:
1675
+ return ttypager
1676
+ finally:
1677
+ os.unlink(filename)
1678
+
1679
+ def plain(text):
1680
+ """Remove boldface formatting from text."""
1681
+ return re.sub('.\b', '', text)
1682
+
1683
+ def pipepager(text, cmd):
1684
+ """Page through text by feeding it to another program."""
1685
+ import subprocess
1686
+ proc = subprocess.Popen(cmd, shell=True, stdin=subprocess.PIPE,
1687
+ errors='backslashreplace')
1688
+ try:
1689
+ with proc.stdin as pipe:
1690
+ try:
1691
+ pipe.write(text)
1692
+ except KeyboardInterrupt:
1693
+ # We've hereby abandoned whatever text hasn't been written,
1694
+ # but the pager is still in control of the terminal.
1695
+ pass
1696
+ except OSError:
1697
+ pass # Ignore broken pipes caused by quitting the pager program.
1698
+ while True:
1699
+ try:
1700
+ proc.wait()
1701
+ break
1702
+ except KeyboardInterrupt:
1703
+ # Ignore ctl-c like the pager itself does. Otherwise the pager is
1704
+ # left running and the terminal is in raw mode and unusable.
1705
+ pass
1706
+
1707
+ def tempfilepager(text, cmd):
1708
+ """Page through text by invoking a program on a temporary file."""
1709
+ import tempfile
1710
+ with tempfile.TemporaryDirectory() as tempdir:
1711
+ filename = os.path.join(tempdir, 'pydoc.out')
1712
+ with open(filename, 'w', errors='backslashreplace',
1713
+ encoding=os.device_encoding(0) if
1714
+ sys.platform == 'win32' else None
1715
+ ) as file:
1716
+ file.write(text)
1717
+ os.system(cmd + ' "' + filename + '"')
1718
+
1719
+ def _escape_stdout(text):
1720
+ # Escape non-encodable characters to avoid encoding errors later
1721
+ encoding = getattr(sys.stdout, 'encoding', None) or 'utf-8'
1722
+ return text.encode(encoding, 'backslashreplace').decode(encoding)
1723
+
1724
+ def ttypager(text):
1725
+ """Page through text on a text terminal."""
1726
+ lines = plain(_escape_stdout(text)).split('\n')
1727
+ try:
1728
+ import tty
1729
+ fd = sys.stdin.fileno()
1730
+ old = tty.tcgetattr(fd)
1731
+ tty.setcbreak(fd)
1732
+ getchar = lambda: sys.stdin.read(1)
1733
+ except (ImportError, AttributeError, io.UnsupportedOperation):
1734
+ tty = None
1735
+ getchar = lambda: sys.stdin.readline()[:-1][:1]
1736
+
1737
+ try:
1738
+ try:
1739
+ h = int(os.environ.get('LINES', 0))
1740
+ except ValueError:
1741
+ h = 0
1742
+ if h <= 1:
1743
+ h = 25
1744
+ r = inc = h - 1
1745
+ sys.stdout.write('\n'.join(lines[:inc]) + '\n')
1746
+ while lines[r:]:
1747
+ sys.stdout.write('-- more --')
1748
+ sys.stdout.flush()
1749
+ c = getchar()
1750
+
1751
+ if c in ('q', 'Q'):
1752
+ sys.stdout.write('\r \r')
1753
+ break
1754
+ elif c in ('\r', '\n'):
1755
+ sys.stdout.write('\r \r' + lines[r] + '\n')
1756
+ r = r + 1
1757
+ continue
1758
+ if c in ('b', 'B', '\x1b'):
1759
+ r = r - inc - inc
1760
+ if r < 0: r = 0
1761
+ sys.stdout.write('\n' + '\n'.join(lines[r:r+inc]) + '\n')
1762
+ r = r + inc
1763
+
1764
+ finally:
1765
+ if tty:
1766
+ tty.tcsetattr(fd, tty.TCSAFLUSH, old)
1767
+
1768
+ def plainpager(text):
1769
+ """Simply print unformatted text. This is the ultimate fallback."""
1770
+ sys.stdout.write(plain(_escape_stdout(text)))
1771
+
1772
+ def describe(thing):
1773
+ """Produce a short description of the given thing."""
1774
+ if inspect.ismodule(thing):
1775
+ if thing.__name__ in sys.builtin_module_names:
1776
+ return 'built-in module ' + thing.__name__
1777
+ if hasattr(thing, '__path__'):
1778
+ return 'package ' + thing.__name__
1779
+ else:
1780
+ return 'module ' + thing.__name__
1781
+ if inspect.isbuiltin(thing):
1782
+ return 'built-in function ' + thing.__name__
1783
+ if inspect.isgetsetdescriptor(thing):
1784
+ return 'getset descriptor %s.%s.%s' % (
1785
+ thing.__objclass__.__module__, thing.__objclass__.__name__,
1786
+ thing.__name__)
1787
+ if inspect.ismemberdescriptor(thing):
1788
+ return 'member descriptor %s.%s.%s' % (
1789
+ thing.__objclass__.__module__, thing.__objclass__.__name__,
1790
+ thing.__name__)
1791
+ if inspect.isclass(thing):
1792
+ return 'class ' + thing.__name__
1793
+ if inspect.isfunction(thing):
1794
+ return 'function ' + thing.__name__
1795
+ if inspect.ismethod(thing):
1796
+ return 'method ' + thing.__name__
1797
+ return type(thing).__name__
1798
+
1799
+ def locate(path, forceload=0):
1800
+ """Locate an object by name or dotted path, importing as necessary."""
1801
+ parts = [part for part in path.split('.') if part]
1802
+ module, n = None, 0
1803
+ while n < len(parts):
1804
+ nextmodule = safeimport('.'.join(parts[:n+1]), forceload)
1805
+ if nextmodule: module, n = nextmodule, n + 1
1806
+ else: break
1807
+ if module:
1808
+ object = module
1809
+ else:
1810
+ object = builtins
1811
+ for part in parts[n:]:
1812
+ try:
1813
+ object = getattr(object, part)
1814
+ except AttributeError:
1815
+ return None
1816
+ return object
1817
+
1818
+ # --------------------------------------- interactive interpreter interface
1819
+
1820
+ text = TextDoc()
1821
+ plaintext = _PlainTextDoc()
1822
+ html = HTMLDoc()
1823
+
1824
+ def resolve(thing, forceload=0):
1825
+ """Given an object or a path to an object, get the object and its name."""
1826
+ if isinstance(thing, str):
1827
+ object = locate(thing, forceload)
1828
+ if object is None:
1829
+ raise ImportError('''\
1830
+ No Python documentation found for %r.
1831
+ Use help() to get the interactive help utility.
1832
+ Use help(str) for help on the str class.''' % thing)
1833
+ return object, thing
1834
+ else:
1835
+ name = getattr(thing, '__name__', None)
1836
+ return thing, name if isinstance(name, str) else None
1837
+
1838
+ def render_doc(thing, title='Python Library Documentation: %s', forceload=0,
1839
+ renderer=None):
1840
+ """Render text documentation, given an object or a path to an object."""
1841
+ if renderer is None:
1842
+ renderer = text
1843
+ object, name = resolve(thing, forceload)
1844
+ desc = describe(object)
1845
+ module = inspect.getmodule(object)
1846
+ if name and '.' in name:
1847
+ desc += ' in ' + name[:name.rfind('.')]
1848
+ elif module and module is not object:
1849
+ desc += ' in module ' + module.__name__
1850
+
1851
+ if not (inspect.ismodule(object) or
1852
+ inspect.isclass(object) or
1853
+ inspect.isroutine(object) or
1854
+ inspect.isdatadescriptor(object) or
1855
+ _getdoc(object)):
1856
+ # If the passed object is a piece of data or an instance,
1857
+ # document its available methods instead of its value.
1858
+ if hasattr(object, '__origin__'):
1859
+ object = object.__origin__
1860
+ else:
1861
+ object = type(object)
1862
+ desc += ' object'
1863
+ return title % desc + '\n\n' + renderer.document(object, name)
1864
+
1865
+ def doc(thing, title='Python Library Documentation: %s', forceload=0,
1866
+ output=None, is_cli=False):
1867
+ """Display text documentation, given an object or a path to an object."""
1868
+ if output is None:
1869
+ try:
1870
+ pager(render_doc(thing, title, forceload))
1871
+ except ImportError as exc:
1872
+ if is_cli:
1873
+ raise
1874
+ print(exc)
1875
+ else:
1876
+ try:
1877
+ s = render_doc(thing, title, forceload, plaintext)
1878
+ except ImportError as exc:
1879
+ s = str(exc)
1880
+ output.write(s)
1881
+
1882
+ def writedoc(thing, forceload=0):
1883
+ """Write HTML documentation to a file in the current directory."""
1884
+ object, name = resolve(thing, forceload)
1885
+ page = html.page(describe(object), html.document(object, name))
1886
+ with open(name + '.html', 'w', encoding='utf-8') as file:
1887
+ file.write(page)
1888
+ print('wrote', name + '.html')
1889
+
1890
+ def writedocs(dir, pkgpath='', done=None):
1891
+ """Write out HTML documentation for all modules in a directory tree."""
1892
+ if done is None: done = {}
1893
+ for importer, modname, ispkg in pkgutil.walk_packages([dir], pkgpath):
1894
+ writedoc(modname)
1895
+ return
1896
+
1897
+ class Helper:
1898
+
1899
+ # These dictionaries map a topic name to either an alias, or a tuple
1900
+ # (label, seealso-items). The "label" is the label of the corresponding
1901
+ # section in the .rst file under Doc/ and an index into the dictionary
1902
+ # in pydoc_data/topics.py.
1903
+ #
1904
+ # CAUTION: if you change one of these dictionaries, be sure to adapt the
1905
+ # list of needed labels in Doc/tools/extensions/pyspecific.py and
1906
+ # regenerate the pydoc_data/topics.py file by running
1907
+ # make pydoc-topics
1908
+ # in Doc/ and copying the output file into the Lib/ directory.
1909
+
1910
+ keywords = {
1911
+ 'False': '',
1912
+ 'None': '',
1913
+ 'True': '',
1914
+ 'and': 'BOOLEAN',
1915
+ 'as': 'with',
1916
+ 'assert': ('assert', ''),
1917
+ 'async': ('async', ''),
1918
+ 'await': ('await', ''),
1919
+ 'break': ('break', 'while for'),
1920
+ 'class': ('class', 'CLASSES SPECIALMETHODS'),
1921
+ 'continue': ('continue', 'while for'),
1922
+ 'def': ('function', ''),
1923
+ 'del': ('del', 'BASICMETHODS'),
1924
+ 'elif': 'if',
1925
+ 'else': ('else', 'while for'),
1926
+ 'except': 'try',
1927
+ 'finally': 'try',
1928
+ 'for': ('for', 'break continue while'),
1929
+ 'from': 'import',
1930
+ 'global': ('global', 'nonlocal NAMESPACES'),
1931
+ 'if': ('if', 'TRUTHVALUE'),
1932
+ 'import': ('import', 'MODULES'),
1933
+ 'in': ('in', 'SEQUENCEMETHODS'),
1934
+ 'is': 'COMPARISON',
1935
+ 'lambda': ('lambda', 'FUNCTIONS'),
1936
+ 'nonlocal': ('nonlocal', 'global NAMESPACES'),
1937
+ 'not': 'BOOLEAN',
1938
+ 'or': 'BOOLEAN',
1939
+ 'pass': ('pass', ''),
1940
+ 'raise': ('raise', 'EXCEPTIONS'),
1941
+ 'return': ('return', 'FUNCTIONS'),
1942
+ 'try': ('try', 'EXCEPTIONS'),
1943
+ 'while': ('while', 'break continue if TRUTHVALUE'),
1944
+ 'with': ('with', 'CONTEXTMANAGERS EXCEPTIONS yield'),
1945
+ 'yield': ('yield', ''),
1946
+ }
1947
+ # Either add symbols to this dictionary or to the symbols dictionary
1948
+ # directly: Whichever is easier. They are merged later.
1949
+ _strprefixes = [p + q for p in ('b', 'f', 'r', 'u') for q in ("'", '"')]
1950
+ _symbols_inverse = {
1951
+ 'STRINGS' : ("'", "'''", '"', '"""', *_strprefixes),
1952
+ 'OPERATORS' : ('+', '-', '*', '**', '/', '//', '%', '<<', '>>', '&',
1953
+ '|', '^', '~', '<', '>', '<=', '>=', '==', '!=', '<>'),
1954
+ 'COMPARISON' : ('<', '>', '<=', '>=', '==', '!=', '<>'),
1955
+ 'UNARY' : ('-', '~'),
1956
+ 'AUGMENTEDASSIGNMENT' : ('+=', '-=', '*=', '/=', '%=', '&=', '|=',
1957
+ '^=', '<<=', '>>=', '**=', '//='),
1958
+ 'BITWISE' : ('<<', '>>', '&', '|', '^', '~'),
1959
+ 'COMPLEX' : ('j', 'J')
1960
+ }
1961
+ symbols = {
1962
+ '%': 'OPERATORS FORMATTING',
1963
+ '**': 'POWER',
1964
+ ',': 'TUPLES LISTS FUNCTIONS',
1965
+ '.': 'ATTRIBUTES FLOAT MODULES OBJECTS',
1966
+ '...': 'ELLIPSIS',
1967
+ ':': 'SLICINGS DICTIONARYLITERALS',
1968
+ '@': 'def class',
1969
+ '\\': 'STRINGS',
1970
+ '_': 'PRIVATENAMES',
1971
+ '__': 'PRIVATENAMES SPECIALMETHODS',
1972
+ '`': 'BACKQUOTES',
1973
+ '(': 'TUPLES FUNCTIONS CALLS',
1974
+ ')': 'TUPLES FUNCTIONS CALLS',
1975
+ '[': 'LISTS SUBSCRIPTS SLICINGS',
1976
+ ']': 'LISTS SUBSCRIPTS SLICINGS'
1977
+ }
1978
+ for topic, symbols_ in _symbols_inverse.items():
1979
+ for symbol in symbols_:
1980
+ topics = symbols.get(symbol, topic)
1981
+ if topic not in topics:
1982
+ topics = topics + ' ' + topic
1983
+ symbols[symbol] = topics
1984
+ del topic, symbols_, symbol, topics
1985
+
1986
+ topics = {
1987
+ 'TYPES': ('types', 'STRINGS UNICODE NUMBERS SEQUENCES MAPPINGS '
1988
+ 'FUNCTIONS CLASSES MODULES FILES inspect'),
1989
+ 'STRINGS': ('strings', 'str UNICODE SEQUENCES STRINGMETHODS '
1990
+ 'FORMATTING TYPES'),
1991
+ 'STRINGMETHODS': ('string-methods', 'STRINGS FORMATTING'),
1992
+ 'FORMATTING': ('formatstrings', 'OPERATORS'),
1993
+ 'UNICODE': ('strings', 'encodings unicode SEQUENCES STRINGMETHODS '
1994
+ 'FORMATTING TYPES'),
1995
+ 'NUMBERS': ('numbers', 'INTEGER FLOAT COMPLEX TYPES'),
1996
+ 'INTEGER': ('integers', 'int range'),
1997
+ 'FLOAT': ('floating', 'float math'),
1998
+ 'COMPLEX': ('imaginary', 'complex cmath'),
1999
+ 'SEQUENCES': ('typesseq', 'STRINGMETHODS FORMATTING range LISTS'),
2000
+ 'MAPPINGS': 'DICTIONARIES',
2001
+ 'FUNCTIONS': ('typesfunctions', 'def TYPES'),
2002
+ 'METHODS': ('typesmethods', 'class def CLASSES TYPES'),
2003
+ 'CODEOBJECTS': ('bltin-code-objects', 'compile FUNCTIONS TYPES'),
2004
+ 'TYPEOBJECTS': ('bltin-type-objects', 'types TYPES'),
2005
+ 'FRAMEOBJECTS': 'TYPES',
2006
+ 'TRACEBACKS': 'TYPES',
2007
+ 'NONE': ('bltin-null-object', ''),
2008
+ 'ELLIPSIS': ('bltin-ellipsis-object', 'SLICINGS'),
2009
+ 'SPECIALATTRIBUTES': ('specialattrs', ''),
2010
+ 'CLASSES': ('types', 'class SPECIALMETHODS PRIVATENAMES'),
2011
+ 'MODULES': ('typesmodules', 'import'),
2012
+ 'PACKAGES': 'import',
2013
+ 'EXPRESSIONS': ('operator-summary', 'lambda or and not in is BOOLEAN '
2014
+ 'COMPARISON BITWISE SHIFTING BINARY FORMATTING POWER '
2015
+ 'UNARY ATTRIBUTES SUBSCRIPTS SLICINGS CALLS TUPLES '
2016
+ 'LISTS DICTIONARIES'),
2017
+ 'OPERATORS': 'EXPRESSIONS',
2018
+ 'PRECEDENCE': 'EXPRESSIONS',
2019
+ 'OBJECTS': ('objects', 'TYPES'),
2020
+ 'SPECIALMETHODS': ('specialnames', 'BASICMETHODS ATTRIBUTEMETHODS '
2021
+ 'CALLABLEMETHODS SEQUENCEMETHODS MAPPINGMETHODS '
2022
+ 'NUMBERMETHODS CLASSES'),
2023
+ 'BASICMETHODS': ('customization', 'hash repr str SPECIALMETHODS'),
2024
+ 'ATTRIBUTEMETHODS': ('attribute-access', 'ATTRIBUTES SPECIALMETHODS'),
2025
+ 'CALLABLEMETHODS': ('callable-types', 'CALLS SPECIALMETHODS'),
2026
+ 'SEQUENCEMETHODS': ('sequence-types', 'SEQUENCES SEQUENCEMETHODS '
2027
+ 'SPECIALMETHODS'),
2028
+ 'MAPPINGMETHODS': ('sequence-types', 'MAPPINGS SPECIALMETHODS'),
2029
+ 'NUMBERMETHODS': ('numeric-types', 'NUMBERS AUGMENTEDASSIGNMENT '
2030
+ 'SPECIALMETHODS'),
2031
+ 'EXECUTION': ('execmodel', 'NAMESPACES DYNAMICFEATURES EXCEPTIONS'),
2032
+ 'NAMESPACES': ('naming', 'global nonlocal ASSIGNMENT DELETION DYNAMICFEATURES'),
2033
+ 'DYNAMICFEATURES': ('dynamic-features', ''),
2034
+ 'SCOPING': 'NAMESPACES',
2035
+ 'FRAMES': 'NAMESPACES',
2036
+ 'EXCEPTIONS': ('exceptions', 'try except finally raise'),
2037
+ 'CONVERSIONS': ('conversions', ''),
2038
+ 'IDENTIFIERS': ('identifiers', 'keywords SPECIALIDENTIFIERS'),
2039
+ 'SPECIALIDENTIFIERS': ('id-classes', ''),
2040
+ 'PRIVATENAMES': ('atom-identifiers', ''),
2041
+ 'LITERALS': ('atom-literals', 'STRINGS NUMBERS TUPLELITERALS '
2042
+ 'LISTLITERALS DICTIONARYLITERALS'),
2043
+ 'TUPLES': 'SEQUENCES',
2044
+ 'TUPLELITERALS': ('exprlists', 'TUPLES LITERALS'),
2045
+ 'LISTS': ('typesseq-mutable', 'LISTLITERALS'),
2046
+ 'LISTLITERALS': ('lists', 'LISTS LITERALS'),
2047
+ 'DICTIONARIES': ('typesmapping', 'DICTIONARYLITERALS'),
2048
+ 'DICTIONARYLITERALS': ('dict', 'DICTIONARIES LITERALS'),
2049
+ 'ATTRIBUTES': ('attribute-references', 'getattr hasattr setattr ATTRIBUTEMETHODS'),
2050
+ 'SUBSCRIPTS': ('subscriptions', 'SEQUENCEMETHODS'),
2051
+ 'SLICINGS': ('slicings', 'SEQUENCEMETHODS'),
2052
+ 'CALLS': ('calls', 'EXPRESSIONS'),
2053
+ 'POWER': ('power', 'EXPRESSIONS'),
2054
+ 'UNARY': ('unary', 'EXPRESSIONS'),
2055
+ 'BINARY': ('binary', 'EXPRESSIONS'),
2056
+ 'SHIFTING': ('shifting', 'EXPRESSIONS'),
2057
+ 'BITWISE': ('bitwise', 'EXPRESSIONS'),
2058
+ 'COMPARISON': ('comparisons', 'EXPRESSIONS BASICMETHODS'),
2059
+ 'BOOLEAN': ('booleans', 'EXPRESSIONS TRUTHVALUE'),
2060
+ 'ASSERTION': 'assert',
2061
+ 'ASSIGNMENT': ('assignment', 'AUGMENTEDASSIGNMENT'),
2062
+ 'AUGMENTEDASSIGNMENT': ('augassign', 'NUMBERMETHODS'),
2063
+ 'DELETION': 'del',
2064
+ 'RETURNING': 'return',
2065
+ 'IMPORTING': 'import',
2066
+ 'CONDITIONAL': 'if',
2067
+ 'LOOPING': ('compound', 'for while break continue'),
2068
+ 'TRUTHVALUE': ('truth', 'if while and or not BASICMETHODS'),
2069
+ 'DEBUGGING': ('debugger', 'pdb'),
2070
+ 'CONTEXTMANAGERS': ('context-managers', 'with'),
2071
+ }
2072
+
2073
+ def __init__(self, input=None, output=None):
2074
+ self._input = input
2075
+ self._output = output
2076
+
2077
+ @property
2078
+ def input(self):
2079
+ return self._input or sys.stdin
2080
+
2081
+ @property
2082
+ def output(self):
2083
+ return self._output or sys.stdout
2084
+
2085
+ def __repr__(self):
2086
+ if inspect.stack()[1][3] == '?':
2087
+ self()
2088
+ return ''
2089
+ return '<%s.%s instance>' % (self.__class__.__module__,
2090
+ self.__class__.__qualname__)
2091
+
2092
+ _GoInteractive = object()
2093
+ def __call__(self, request=_GoInteractive):
2094
+ if request is not self._GoInteractive:
2095
+ try:
2096
+ self.help(request)
2097
+ except ImportError as err:
2098
+ self.output.write(f'{err}\n')
2099
+ else:
2100
+ self.intro()
2101
+ self.interact()
2102
+ self.output.write('''
2103
+ You are now leaving help and returning to the Python interpreter.
2104
+ If you want to ask for help on a particular object directly from the
2105
+ interpreter, you can type "help(object)". Executing "help('string')"
2106
+ has the same effect as typing a particular string at the help> prompt.
2107
+ ''')
2108
+
2109
+ def interact(self):
2110
+ self.output.write('\n')
2111
+ while True:
2112
+ try:
2113
+ request = self.getline('help> ')
2114
+ if not request: break
2115
+ except (KeyboardInterrupt, EOFError):
2116
+ break
2117
+ request = request.strip()
2118
+
2119
+ # Make sure significant trailing quoting marks of literals don't
2120
+ # get deleted while cleaning input
2121
+ if (len(request) > 2 and request[0] == request[-1] in ("'", '"')
2122
+ and request[0] not in request[1:-1]):
2123
+ request = request[1:-1]
2124
+ if request.lower() in ('q', 'quit'): break
2125
+ if request == 'help':
2126
+ self.intro()
2127
+ else:
2128
+ self.help(request)
2129
+
2130
+ def getline(self, prompt):
2131
+ """Read one line, using input() when appropriate."""
2132
+ if self.input is sys.stdin:
2133
+ return input(prompt)
2134
+ else:
2135
+ self.output.write(prompt)
2136
+ self.output.flush()
2137
+ return self.input.readline()
2138
+
2139
+ def help(self, request, is_cli=False):
2140
+ if isinstance(request, str):
2141
+ request = request.strip()
2142
+ if request == 'keywords': self.listkeywords()
2143
+ elif request == 'symbols': self.listsymbols()
2144
+ elif request == 'topics': self.listtopics()
2145
+ elif request == 'modules': self.listmodules()
2146
+ elif request[:8] == 'modules ':
2147
+ self.listmodules(request.split()[1])
2148
+ elif request in self.symbols: self.showsymbol(request)
2149
+ elif request in ['True', 'False', 'None']:
2150
+ # special case these keywords since they are objects too
2151
+ doc(eval(request), 'Help on %s:', output=self._output, is_cli=is_cli)
2152
+ elif request in self.keywords: self.showtopic(request)
2153
+ elif request in self.topics: self.showtopic(request)
2154
+ elif request: doc(request, 'Help on %s:', output=self._output, is_cli=is_cli)
2155
+ else: doc(str, 'Help on %s:', output=self._output, is_cli=is_cli)
2156
+ elif isinstance(request, Helper): self()
2157
+ else: doc(request, 'Help on %s:', output=self._output, is_cli=is_cli)
2158
+ self.output.write('\n')
2159
+
2160
+ def intro(self):
2161
+ self.output.write('''\
2162
+ Welcome to Python {0}'s help utility! If this is your first time using
2163
+ Python, you should definitely check out the tutorial at
2164
+ https://docs.python.org/{0}/tutorial/.
2165
+
2166
+ Enter the name of any module, keyword, or topic to get help on writing
2167
+ Python programs and using Python modules. To get a list of available
2168
+ modules, keywords, symbols, or topics, enter "modules", "keywords",
2169
+ "symbols", or "topics".
2170
+
2171
+ Each module also comes with a one-line summary of what it does; to list
2172
+ the modules whose name or summary contain a given string such as "spam",
2173
+ enter "modules spam".
2174
+
2175
+ To quit this help utility and return to the interpreter,
2176
+ enter "q" or "quit".
2177
+ '''.format('%d.%d' % sys.version_info[:2]))
2178
+
2179
+ def list(self, items, columns=4, width=80):
2180
+ items = list(sorted(items))
2181
+ colw = width // columns
2182
+ rows = (len(items) + columns - 1) // columns
2183
+ for row in range(rows):
2184
+ for col in range(columns):
2185
+ i = col * rows + row
2186
+ if i < len(items):
2187
+ self.output.write(items[i])
2188
+ if col < columns - 1:
2189
+ self.output.write(' ' + ' ' * (colw - 1 - len(items[i])))
2190
+ self.output.write('\n')
2191
+
2192
+ def listkeywords(self):
2193
+ self.output.write('''
2194
+ Here is a list of the Python keywords. Enter any keyword to get more help.
2195
+
2196
+ ''')
2197
+ self.list(self.keywords.keys())
2198
+
2199
+ def listsymbols(self):
2200
+ self.output.write('''
2201
+ Here is a list of the punctuation symbols which Python assigns special meaning
2202
+ to. Enter any symbol to get more help.
2203
+
2204
+ ''')
2205
+ self.list(self.symbols.keys())
2206
+
2207
+ def listtopics(self):
2208
+ self.output.write('''
2209
+ Here is a list of available topics. Enter any topic name to get more help.
2210
+
2211
+ ''')
2212
+ self.list(self.topics.keys())
2213
+
2214
+ def showtopic(self, topic, more_xrefs=''):
2215
+ try:
2216
+ import pydoc_data.topics
2217
+ except ImportError:
2218
+ self.output.write('''
2219
+ Sorry, topic and keyword documentation is not available because the
2220
+ module "pydoc_data.topics" could not be found.
2221
+ ''')
2222
+ return
2223
+ target = self.topics.get(topic, self.keywords.get(topic))
2224
+ if not target:
2225
+ self.output.write('no documentation found for %s\n' % repr(topic))
2226
+ return
2227
+ if isinstance(target, str):
2228
+ return self.showtopic(target, more_xrefs)
2229
+
2230
+ label, xrefs = target
2231
+ try:
2232
+ doc = pydoc_data.topics.topics[label]
2233
+ except KeyError:
2234
+ self.output.write('no documentation found for %s\n' % repr(topic))
2235
+ return
2236
+ doc = doc.strip() + '\n'
2237
+ if more_xrefs:
2238
+ xrefs = (xrefs or '') + ' ' + more_xrefs
2239
+ if xrefs:
2240
+ import textwrap
2241
+ text = 'Related help topics: ' + ', '.join(xrefs.split()) + '\n'
2242
+ wrapped_text = textwrap.wrap(text, 72)
2243
+ doc += '\n%s\n' % '\n'.join(wrapped_text)
2244
+
2245
+ if self._output is None:
2246
+ pager(doc)
2247
+ else:
2248
+ self.output.write(doc)
2249
+
2250
+ def _gettopic(self, topic, more_xrefs=''):
2251
+ """Return unbuffered tuple of (topic, xrefs).
2252
+
2253
+ If an error occurs here, the exception is caught and displayed by
2254
+ the url handler.
2255
+
2256
+ This function duplicates the showtopic method but returns its
2257
+ result directly so it can be formatted for display in an html page.
2258
+ """
2259
+ try:
2260
+ import pydoc_data.topics
2261
+ except ImportError:
2262
+ return('''
2263
+ Sorry, topic and keyword documentation is not available because the
2264
+ module "pydoc_data.topics" could not be found.
2265
+ ''' , '')
2266
+ target = self.topics.get(topic, self.keywords.get(topic))
2267
+ if not target:
2268
+ raise ValueError('could not find topic')
2269
+ if isinstance(target, str):
2270
+ return self._gettopic(target, more_xrefs)
2271
+ label, xrefs = target
2272
+ doc = pydoc_data.topics.topics[label]
2273
+ if more_xrefs:
2274
+ xrefs = (xrefs or '') + ' ' + more_xrefs
2275
+ return doc, xrefs
2276
+
2277
+ def showsymbol(self, symbol):
2278
+ target = self.symbols[symbol]
2279
+ topic, _, xrefs = target.partition(' ')
2280
+ self.showtopic(topic, xrefs)
2281
+
2282
+ def listmodules(self, key=''):
2283
+ if key:
2284
+ self.output.write('''
2285
+ Here is a list of modules whose name or summary contains '{}'.
2286
+ If there are any, enter a module name to get more help.
2287
+
2288
+ '''.format(key))
2289
+ apropos(key)
2290
+ else:
2291
+ self.output.write('''
2292
+ Please wait a moment while I gather a list of all available modules...
2293
+
2294
+ ''')
2295
+ modules = {}
2296
+ def callback(path, modname, desc, modules=modules):
2297
+ if modname and modname[-9:] == '.__init__':
2298
+ modname = modname[:-9] + ' (package)'
2299
+ if modname.find('.') < 0:
2300
+ modules[modname] = 1
2301
+ def onerror(modname):
2302
+ callback(None, modname, None)
2303
+ ModuleScanner().run(callback, onerror=onerror)
2304
+ self.list(modules.keys())
2305
+ self.output.write('''
2306
+ Enter any module name to get more help. Or, type "modules spam" to search
2307
+ for modules whose name or summary contain the string "spam".
2308
+ ''')
2309
+
2310
+ help = Helper()
2311
+
2312
+ class ModuleScanner:
2313
+ """An interruptible scanner that searches module synopses."""
2314
+
2315
+ def run(self, callback, key=None, completer=None, onerror=None):
2316
+ if key: key = key.lower()
2317
+ self.quit = False
2318
+ seen = {}
2319
+
2320
+ for modname in sys.builtin_module_names:
2321
+ if modname != '__main__':
2322
+ seen[modname] = 1
2323
+ if key is None:
2324
+ callback(None, modname, '')
2325
+ else:
2326
+ name = __import__(modname).__doc__ or ''
2327
+ desc = name.split('\n')[0]
2328
+ name = modname + ' - ' + desc
2329
+ if name.lower().find(key) >= 0:
2330
+ callback(None, modname, desc)
2331
+
2332
+ for importer, modname, ispkg in pkgutil.walk_packages(onerror=onerror):
2333
+ if self.quit:
2334
+ break
2335
+
2336
+ if key is None:
2337
+ callback(None, modname, '')
2338
+ else:
2339
+ try:
2340
+ spec = importer.find_spec(modname)
2341
+ except SyntaxError:
2342
+ # raised by tests for bad coding cookies or BOM
2343
+ continue
2344
+ loader = spec.loader
2345
+ if hasattr(loader, 'get_source'):
2346
+ try:
2347
+ source = loader.get_source(modname)
2348
+ except Exception:
2349
+ if onerror:
2350
+ onerror(modname)
2351
+ continue
2352
+ desc = source_synopsis(io.StringIO(source)) or ''
2353
+ if hasattr(loader, 'get_filename'):
2354
+ path = loader.get_filename(modname)
2355
+ else:
2356
+ path = None
2357
+ else:
2358
+ try:
2359
+ module = importlib._bootstrap._load(spec)
2360
+ except ImportError:
2361
+ if onerror:
2362
+ onerror(modname)
2363
+ continue
2364
+ desc = module.__doc__.splitlines()[0] if module.__doc__ else ''
2365
+ path = getattr(module,'__file__',None)
2366
+ name = modname + ' - ' + desc
2367
+ if name.lower().find(key) >= 0:
2368
+ callback(path, modname, desc)
2369
+
2370
+ if completer:
2371
+ completer()
2372
+
2373
+ def apropos(key):
2374
+ """Print all the one-line module summaries that contain a substring."""
2375
+ def callback(path, modname, desc):
2376
+ if modname[-9:] == '.__init__':
2377
+ modname = modname[:-9] + ' (package)'
2378
+ print(modname, desc and '- ' + desc)
2379
+ def onerror(modname):
2380
+ pass
2381
+ with warnings.catch_warnings():
2382
+ warnings.filterwarnings('ignore') # ignore problems during import
2383
+ ModuleScanner().run(callback, key, onerror=onerror)
2384
+
2385
+ # --------------------------------------- enhanced web browser interface
2386
+
2387
+ def _start_server(urlhandler, hostname, port):
2388
+ """Start an HTTP server thread on a specific port.
2389
+
2390
+ Start an HTML/text server thread, so HTML or text documents can be
2391
+ browsed dynamically and interactively with a web browser. Example use:
2392
+
2393
+ >>> import time
2394
+ >>> import pydoc
2395
+
2396
+ Define a URL handler. To determine what the client is asking
2397
+ for, check the URL and content_type.
2398
+
2399
+ Then get or generate some text or HTML code and return it.
2400
+
2401
+ >>> def my_url_handler(url, content_type):
2402
+ ... text = 'the URL sent was: (%s, %s)' % (url, content_type)
2403
+ ... return text
2404
+
2405
+ Start server thread on port 0.
2406
+ If you use port 0, the server will pick a random port number.
2407
+ You can then use serverthread.port to get the port number.
2408
+
2409
+ >>> port = 0
2410
+ >>> serverthread = pydoc._start_server(my_url_handler, port)
2411
+
2412
+ Check that the server is really started. If it is, open browser
2413
+ and get first page. Use serverthread.url as the starting page.
2414
+
2415
+ >>> if serverthread.serving:
2416
+ ... import webbrowser
2417
+
2418
+ The next two lines are commented out so a browser doesn't open if
2419
+ doctest is run on this module.
2420
+
2421
+ #... webbrowser.open(serverthread.url)
2422
+ #True
2423
+
2424
+ Let the server do its thing. We just need to monitor its status.
2425
+ Use time.sleep so the loop doesn't hog the CPU.
2426
+
2427
+ >>> starttime = time.monotonic()
2428
+ >>> timeout = 1 #seconds
2429
+
2430
+ This is a short timeout for testing purposes.
2431
+
2432
+ >>> while serverthread.serving:
2433
+ ... time.sleep(.01)
2434
+ ... if serverthread.serving and time.monotonic() - starttime > timeout:
2435
+ ... serverthread.stop()
2436
+ ... break
2437
+
2438
+ Print any errors that may have occurred.
2439
+
2440
+ >>> print(serverthread.error)
2441
+ None
2442
+ """
2443
+ import http.server
2444
+ import email.message
2445
+ import select
2446
+ import threading
2447
+
2448
+ class DocHandler(http.server.BaseHTTPRequestHandler):
2449
+
2450
+ def do_GET(self):
2451
+ """Process a request from an HTML browser.
2452
+
2453
+ The URL received is in self.path.
2454
+ Get an HTML page from self.urlhandler and send it.
2455
+ """
2456
+ if self.path.endswith('.css'):
2457
+ content_type = 'text/css'
2458
+ else:
2459
+ content_type = 'text/html'
2460
+ self.send_response(200)
2461
+ self.send_header('Content-Type', '%s; charset=UTF-8' % content_type)
2462
+ self.end_headers()
2463
+ self.wfile.write(self.urlhandler(
2464
+ self.path, content_type).encode('utf-8'))
2465
+
2466
+ def log_message(self, *args):
2467
+ # Don't log messages.
2468
+ pass
2469
+
2470
+ class DocServer(http.server.HTTPServer):
2471
+
2472
+ def __init__(self, host, port, callback):
2473
+ self.host = host
2474
+ self.address = (self.host, port)
2475
+ self.callback = callback
2476
+ self.base.__init__(self, self.address, self.handler)
2477
+ self.quit = False
2478
+
2479
+ def serve_until_quit(self):
2480
+ while not self.quit:
2481
+ rd, wr, ex = select.select([self.socket.fileno()], [], [], 1)
2482
+ if rd:
2483
+ self.handle_request()
2484
+ self.server_close()
2485
+
2486
+ def server_activate(self):
2487
+ self.base.server_activate(self)
2488
+ if self.callback:
2489
+ self.callback(self)
2490
+
2491
+ class ServerThread(threading.Thread):
2492
+
2493
+ def __init__(self, urlhandler, host, port):
2494
+ self.urlhandler = urlhandler
2495
+ self.host = host
2496
+ self.port = int(port)
2497
+ threading.Thread.__init__(self)
2498
+ self.serving = False
2499
+ self.error = None
2500
+ self.docserver = None
2501
+
2502
+ def run(self):
2503
+ """Start the server."""
2504
+ try:
2505
+ DocServer.base = http.server.HTTPServer
2506
+ DocServer.handler = DocHandler
2507
+ DocHandler.MessageClass = email.message.Message
2508
+ DocHandler.urlhandler = staticmethod(self.urlhandler)
2509
+ docsvr = DocServer(self.host, self.port, self.ready)
2510
+ self.docserver = docsvr
2511
+ docsvr.serve_until_quit()
2512
+ except Exception as err:
2513
+ self.error = err
2514
+
2515
+ def ready(self, server):
2516
+ self.serving = True
2517
+ self.host = server.host
2518
+ self.port = server.server_port
2519
+ self.url = 'http://%s:%d/' % (self.host, self.port)
2520
+
2521
+ def stop(self):
2522
+ """Stop the server and this thread nicely"""
2523
+ self.docserver.quit = True
2524
+ self.join()
2525
+ # explicitly break a reference cycle: DocServer.callback
2526
+ # has indirectly a reference to ServerThread.
2527
+ self.docserver = None
2528
+ self.serving = False
2529
+ self.url = None
2530
+
2531
+ thread = ServerThread(urlhandler, hostname, port)
2532
+ thread.start()
2533
+ # Wait until thread.serving is True and thread.docserver is set
2534
+ # to make sure we are really up before returning.
2535
+ while not thread.error and not (thread.serving and thread.docserver):
2536
+ time.sleep(.01)
2537
+ return thread
2538
+
2539
+
2540
+ def _url_handler(url, content_type="text/html"):
2541
+ """The pydoc url handler for use with the pydoc server.
2542
+
2543
+ If the content_type is 'text/css', the _pydoc.css style
2544
+ sheet is read and returned if it exits.
2545
+
2546
+ If the content_type is 'text/html', then the result of
2547
+ get_html_page(url) is returned.
2548
+ """
2549
+ class _HTMLDoc(HTMLDoc):
2550
+
2551
+ def page(self, title, contents):
2552
+ """Format an HTML page."""
2553
+ css_path = "pydoc_data/_pydoc.css"
2554
+ css_link = (
2555
+ '<link rel="stylesheet" type="text/css" href="%s">' %
2556
+ css_path)
2557
+ return '''\
2558
+ <!DOCTYPE>
2559
+ <html lang="en">
2560
+ <head>
2561
+ <meta charset="utf-8">
2562
+ <title>Pydoc: %s</title>
2563
+ %s</head><body>%s<div style="clear:both;padding-top:.5em;">%s</div>
2564
+ </body></html>''' % (title, css_link, html_navbar(), contents)
2565
+
2566
+
2567
+ html = _HTMLDoc()
2568
+
2569
+ def html_navbar():
2570
+ version = html.escape("%s [%s, %s]" % (platform.python_version(),
2571
+ platform.python_build()[0],
2572
+ platform.python_compiler()))
2573
+ return """
2574
+ <div style='float:left'>
2575
+ Python %s<br>%s
2576
+ </div>
2577
+ <div style='float:right'>
2578
+ <div style='text-align:center'>
2579
+ <a href="index.html">Module Index</a>
2580
+ : <a href="topics.html">Topics</a>
2581
+ : <a href="keywords.html">Keywords</a>
2582
+ </div>
2583
+ <div>
2584
+ <form action="get" style='display:inline;'>
2585
+ <input type=text name=key size=15>
2586
+ <input type=submit value="Get">
2587
+ </form>&nbsp;
2588
+ <form action="search" style='display:inline;'>
2589
+ <input type=text name=key size=15>
2590
+ <input type=submit value="Search">
2591
+ </form>
2592
+ </div>
2593
+ </div>
2594
+ """ % (version, html.escape(platform.platform(terse=True)))
2595
+
2596
+ def html_index():
2597
+ """Module Index page."""
2598
+
2599
+ def bltinlink(name):
2600
+ return '<a href="%s.html">%s</a>' % (name, name)
2601
+
2602
+ heading = html.heading(
2603
+ '<strong class="title">Index of Modules</strong>'
2604
+ )
2605
+ names = [name for name in sys.builtin_module_names
2606
+ if name != '__main__']
2607
+ contents = html.multicolumn(names, bltinlink)
2608
+ contents = [heading, '<p>' + html.bigsection(
2609
+ 'Built-in Modules', 'index', contents)]
2610
+
2611
+ seen = {}
2612
+ for dir in sys.path:
2613
+ contents.append(html.index(dir, seen))
2614
+
2615
+ contents.append(
2616
+ '<p align=right class="heading-text grey"><strong>pydoc</strong> by Ka-Ping Yee'
2617
+ '&lt;ping@lfw.org&gt;</p>')
2618
+ return 'Index of Modules', ''.join(contents)
2619
+
2620
+ def html_search(key):
2621
+ """Search results page."""
2622
+ # scan for modules
2623
+ search_result = []
2624
+
2625
+ def callback(path, modname, desc):
2626
+ if modname[-9:] == '.__init__':
2627
+ modname = modname[:-9] + ' (package)'
2628
+ search_result.append((modname, desc and '- ' + desc))
2629
+
2630
+ with warnings.catch_warnings():
2631
+ warnings.filterwarnings('ignore') # ignore problems during import
2632
+ def onerror(modname):
2633
+ pass
2634
+ ModuleScanner().run(callback, key, onerror=onerror)
2635
+
2636
+ # format page
2637
+ def bltinlink(name):
2638
+ return '<a href="%s.html">%s</a>' % (name, name)
2639
+
2640
+ results = []
2641
+ heading = html.heading(
2642
+ '<strong class="title">Search Results</strong>',
2643
+ )
2644
+ for name, desc in search_result:
2645
+ results.append(bltinlink(name) + desc)
2646
+ contents = heading + html.bigsection(
2647
+ 'key = %s' % key, 'index', '<br>'.join(results))
2648
+ return 'Search Results', contents
2649
+
2650
+ def html_topics():
2651
+ """Index of topic texts available."""
2652
+
2653
+ def bltinlink(name):
2654
+ return '<a href="topic?key=%s">%s</a>' % (name, name)
2655
+
2656
+ heading = html.heading(
2657
+ '<strong class="title">INDEX</strong>',
2658
+ )
2659
+ names = sorted(Helper.topics.keys())
2660
+
2661
+ contents = html.multicolumn(names, bltinlink)
2662
+ contents = heading + html.bigsection(
2663
+ 'Topics', 'index', contents)
2664
+ return 'Topics', contents
2665
+
2666
+ def html_keywords():
2667
+ """Index of keywords."""
2668
+ heading = html.heading(
2669
+ '<strong class="title">INDEX</strong>',
2670
+ )
2671
+ names = sorted(Helper.keywords.keys())
2672
+
2673
+ def bltinlink(name):
2674
+ return '<a href="topic?key=%s">%s</a>' % (name, name)
2675
+
2676
+ contents = html.multicolumn(names, bltinlink)
2677
+ contents = heading + html.bigsection(
2678
+ 'Keywords', 'index', contents)
2679
+ return 'Keywords', contents
2680
+
2681
+ def html_topicpage(topic):
2682
+ """Topic or keyword help page."""
2683
+ buf = io.StringIO()
2684
+ htmlhelp = Helper(buf, buf)
2685
+ contents, xrefs = htmlhelp._gettopic(topic)
2686
+ if topic in htmlhelp.keywords:
2687
+ title = 'KEYWORD'
2688
+ else:
2689
+ title = 'TOPIC'
2690
+ heading = html.heading(
2691
+ '<strong class="title">%s</strong>' % title,
2692
+ )
2693
+ contents = '<pre>%s</pre>' % html.markup(contents)
2694
+ contents = html.bigsection(topic , 'index', contents)
2695
+ if xrefs:
2696
+ xrefs = sorted(xrefs.split())
2697
+
2698
+ def bltinlink(name):
2699
+ return '<a href="topic?key=%s">%s</a>' % (name, name)
2700
+
2701
+ xrefs = html.multicolumn(xrefs, bltinlink)
2702
+ xrefs = html.section('Related help topics: ', 'index', xrefs)
2703
+ return ('%s %s' % (title, topic),
2704
+ ''.join((heading, contents, xrefs)))
2705
+
2706
+ def html_getobj(url):
2707
+ obj = locate(url, forceload=1)
2708
+ if obj is None and url != 'None':
2709
+ raise ValueError('could not find object')
2710
+ title = describe(obj)
2711
+ content = html.document(obj, url)
2712
+ return title, content
2713
+
2714
+ def html_error(url, exc):
2715
+ heading = html.heading(
2716
+ '<strong class="title">Error</strong>',
2717
+ )
2718
+ contents = '<br>'.join(html.escape(line) for line in
2719
+ format_exception_only(type(exc), exc))
2720
+ contents = heading + html.bigsection(url, 'error', contents)
2721
+ return "Error - %s" % url, contents
2722
+
2723
+ def get_html_page(url):
2724
+ """Generate an HTML page for url."""
2725
+ complete_url = url
2726
+ if url.endswith('.html'):
2727
+ url = url[:-5]
2728
+ try:
2729
+ if url in ("", "index"):
2730
+ title, content = html_index()
2731
+ elif url == "topics":
2732
+ title, content = html_topics()
2733
+ elif url == "keywords":
2734
+ title, content = html_keywords()
2735
+ elif '=' in url:
2736
+ op, _, url = url.partition('=')
2737
+ if op == "search?key":
2738
+ title, content = html_search(url)
2739
+ elif op == "topic?key":
2740
+ # try topics first, then objects.
2741
+ try:
2742
+ title, content = html_topicpage(url)
2743
+ except ValueError:
2744
+ title, content = html_getobj(url)
2745
+ elif op == "get?key":
2746
+ # try objects first, then topics.
2747
+ if url in ("", "index"):
2748
+ title, content = html_index()
2749
+ else:
2750
+ try:
2751
+ title, content = html_getobj(url)
2752
+ except ValueError:
2753
+ title, content = html_topicpage(url)
2754
+ else:
2755
+ raise ValueError('bad pydoc url')
2756
+ else:
2757
+ title, content = html_getobj(url)
2758
+ except Exception as exc:
2759
+ # Catch any errors and display them in an error page.
2760
+ title, content = html_error(complete_url, exc)
2761
+ return html.page(title, content)
2762
+
2763
+ if url.startswith('/'):
2764
+ url = url[1:]
2765
+ if content_type == 'text/css':
2766
+ path_here = os.path.dirname(os.path.realpath(__file__))
2767
+ css_path = os.path.join(path_here, url)
2768
+ with open(css_path) as fp:
2769
+ return ''.join(fp.readlines())
2770
+ elif content_type == 'text/html':
2771
+ return get_html_page(url)
2772
+ # Errors outside the url handler are caught by the server.
2773
+ raise TypeError('unknown content type %r for url %s' % (content_type, url))
2774
+
2775
+
2776
+ def browse(port=0, *, open_browser=True, hostname='localhost'):
2777
+ """Start the enhanced pydoc web server and open a web browser.
2778
+
2779
+ Use port '0' to start the server on an arbitrary port.
2780
+ Set open_browser to False to suppress opening a browser.
2781
+ """
2782
+ import webbrowser
2783
+ serverthread = _start_server(_url_handler, hostname, port)
2784
+ if serverthread.error:
2785
+ print(serverthread.error)
2786
+ return
2787
+ if serverthread.serving:
2788
+ server_help_msg = 'Server commands: [b]rowser, [q]uit'
2789
+ if open_browser:
2790
+ webbrowser.open(serverthread.url)
2791
+ try:
2792
+ print('Server ready at', serverthread.url)
2793
+ print(server_help_msg)
2794
+ while serverthread.serving:
2795
+ cmd = input('server> ')
2796
+ cmd = cmd.lower()
2797
+ if cmd == 'q':
2798
+ break
2799
+ elif cmd == 'b':
2800
+ webbrowser.open(serverthread.url)
2801
+ else:
2802
+ print(server_help_msg)
2803
+ except (KeyboardInterrupt, EOFError):
2804
+ print()
2805
+ finally:
2806
+ if serverthread.serving:
2807
+ serverthread.stop()
2808
+ print('Server stopped')
2809
+
2810
+
2811
+ # -------------------------------------------------- command-line interface
2812
+
2813
+ def ispath(x):
2814
+ return isinstance(x, str) and x.find(os.sep) >= 0
2815
+
2816
+ def _get_revised_path(given_path, argv0):
2817
+ """Ensures current directory is on returned path, and argv0 directory is not
2818
+
2819
+ Exception: argv0 dir is left alone if it's also pydoc's directory.
2820
+
2821
+ Returns a new path entry list, or None if no adjustment is needed.
2822
+ """
2823
+ # Scripts may get the current directory in their path by default if they're
2824
+ # run with the -m switch, or directly from the current directory.
2825
+ # The interactive prompt also allows imports from the current directory.
2826
+
2827
+ # Accordingly, if the current directory is already present, don't make
2828
+ # any changes to the given_path
2829
+ if '' in given_path or os.curdir in given_path or os.getcwd() in given_path:
2830
+ return None
2831
+
2832
+ # Otherwise, add the current directory to the given path, and remove the
2833
+ # script directory (as long as the latter isn't also pydoc's directory.
2834
+ stdlib_dir = os.path.dirname(__file__)
2835
+ script_dir = os.path.dirname(argv0)
2836
+ revised_path = given_path.copy()
2837
+ if script_dir in given_path and not os.path.samefile(script_dir, stdlib_dir):
2838
+ revised_path.remove(script_dir)
2839
+ revised_path.insert(0, os.getcwd())
2840
+ return revised_path
2841
+
2842
+
2843
+ # Note: the tests only cover _get_revised_path, not _adjust_cli_path itself
2844
+ def _adjust_cli_sys_path():
2845
+ """Ensures current directory is on sys.path, and __main__ directory is not.
2846
+
2847
+ Exception: __main__ dir is left alone if it's also pydoc's directory.
2848
+ """
2849
+ revised_path = _get_revised_path(sys.path, sys.argv[0])
2850
+ if revised_path is not None:
2851
+ sys.path[:] = revised_path
2852
+
2853
+
2854
+ def cli():
2855
+ """Command-line interface (looks at sys.argv to decide what to do)."""
2856
+ import getopt
2857
+ class BadUsage(Exception): pass
2858
+
2859
+ _adjust_cli_sys_path()
2860
+
2861
+ try:
2862
+ opts, args = getopt.getopt(sys.argv[1:], 'bk:n:p:w')
2863
+ writing = False
2864
+ start_server = False
2865
+ open_browser = False
2866
+ port = 0
2867
+ hostname = 'localhost'
2868
+ for opt, val in opts:
2869
+ if opt == '-b':
2870
+ start_server = True
2871
+ open_browser = True
2872
+ if opt == '-k':
2873
+ apropos(val)
2874
+ return
2875
+ if opt == '-p':
2876
+ start_server = True
2877
+ port = val
2878
+ if opt == '-w':
2879
+ writing = True
2880
+ if opt == '-n':
2881
+ start_server = True
2882
+ hostname = val
2883
+
2884
+ if start_server:
2885
+ browse(port, hostname=hostname, open_browser=open_browser)
2886
+ return
2887
+
2888
+ if not args: raise BadUsage
2889
+ for arg in args:
2890
+ if ispath(arg) and not os.path.exists(arg):
2891
+ print('file %r does not exist' % arg)
2892
+ sys.exit(1)
2893
+ try:
2894
+ if ispath(arg) and os.path.isfile(arg):
2895
+ arg = importfile(arg)
2896
+ if writing:
2897
+ if ispath(arg) and os.path.isdir(arg):
2898
+ writedocs(arg)
2899
+ else:
2900
+ writedoc(arg)
2901
+ else:
2902
+ help.help(arg, is_cli=True)
2903
+ except (ImportError, ErrorDuringImport) as value:
2904
+ print(value)
2905
+ sys.exit(1)
2906
+
2907
+ except (getopt.error, BadUsage):
2908
+ cmd = os.path.splitext(os.path.basename(sys.argv[0]))[0]
2909
+ print("""pydoc - the Python documentation tool
2910
+
2911
+ {cmd} <name> ...
2912
+ Show text documentation on something. <name> may be the name of a
2913
+ Python keyword, topic, function, module, or package, or a dotted
2914
+ reference to a class or function within a module or module in a
2915
+ package. If <name> contains a '{sep}', it is used as the path to a
2916
+ Python source file to document. If name is 'keywords', 'topics',
2917
+ or 'modules', a listing of these things is displayed.
2918
+
2919
+ {cmd} -k <keyword>
2920
+ Search for a keyword in the synopsis lines of all available modules.
2921
+
2922
+ {cmd} -n <hostname>
2923
+ Start an HTTP server with the given hostname (default: localhost).
2924
+
2925
+ {cmd} -p <port>
2926
+ Start an HTTP server on the given port on the local machine. Port
2927
+ number 0 can be used to get an arbitrary unused port.
2928
+
2929
+ {cmd} -b
2930
+ Start an HTTP server on an arbitrary unused port and open a web browser
2931
+ to interactively browse documentation. This option can be used in
2932
+ combination with -n and/or -p.
2933
+
2934
+ {cmd} -w <name> ...
2935
+ Write out the HTML documentation for a module to a file in the current
2936
+ directory. If <name> contains a '{sep}', it is treated as a filename; if
2937
+ it names a directory, documentation is written for all the contents.
2938
+ """.format(cmd=cmd, sep=os.sep))
2939
+
2940
+ if __name__ == '__main__':
2941
+ cli()