@pairling/runtime-darwin-arm64 0.1.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (1318) hide show
  1. package/README.md +1 -1
  2. package/bin/pairling-connectd +0 -0
  3. package/manifest.json +9 -3
  4. package/package.json +3 -3
  5. package/python/bin/2to3-3.12 +7 -0
  6. package/python/bin/idle3.12 +7 -0
  7. package/python/bin/pip +8 -0
  8. package/python/bin/pip3 +8 -0
  9. package/python/bin/pip3.12 +8 -0
  10. package/python/bin/pydoc3.12 +7 -0
  11. package/python/bin/python3 +0 -0
  12. package/python/bin/python3.12 +0 -0
  13. package/python/bin/python3.12-config +76 -0
  14. package/python/include/python3.12/Python.h +109 -0
  15. package/python/include/python3.12/abstract.h +899 -0
  16. package/python/include/python3.12/bltinmodule.h +14 -0
  17. package/python/include/python3.12/boolobject.h +42 -0
  18. package/python/include/python3.12/bytearrayobject.h +44 -0
  19. package/python/include/python3.12/bytesobject.h +69 -0
  20. package/python/include/python3.12/ceval.h +168 -0
  21. package/python/include/python3.12/codecs.h +248 -0
  22. package/python/include/python3.12/compile.h +22 -0
  23. package/python/include/python3.12/complexobject.h +30 -0
  24. package/python/include/python3.12/cpython/abstract.h +206 -0
  25. package/python/include/python3.12/cpython/bytearrayobject.h +34 -0
  26. package/python/include/python3.12/cpython/bytesobject.h +133 -0
  27. package/python/include/python3.12/cpython/cellobject.h +44 -0
  28. package/python/include/python3.12/cpython/ceval.h +35 -0
  29. package/python/include/python3.12/cpython/classobject.h +71 -0
  30. package/python/include/python3.12/cpython/code.h +389 -0
  31. package/python/include/python3.12/cpython/compile.h +69 -0
  32. package/python/include/python3.12/cpython/complexobject.h +44 -0
  33. package/python/include/python3.12/cpython/context.h +78 -0
  34. package/python/include/python3.12/cpython/descrobject.h +64 -0
  35. package/python/include/python3.12/cpython/dictobject.h +118 -0
  36. package/python/include/python3.12/cpython/fileobject.h +19 -0
  37. package/python/include/python3.12/cpython/fileutils.h +8 -0
  38. package/python/include/python3.12/cpython/floatobject.h +27 -0
  39. package/python/include/python3.12/cpython/frameobject.h +29 -0
  40. package/python/include/python3.12/cpython/funcobject.h +190 -0
  41. package/python/include/python3.12/cpython/genobject.h +89 -0
  42. package/python/include/python3.12/cpython/import.h +46 -0
  43. package/python/include/python3.12/cpython/initconfig.h +256 -0
  44. package/python/include/python3.12/cpython/interpreteridobject.h +11 -0
  45. package/python/include/python3.12/cpython/listobject.h +47 -0
  46. package/python/include/python3.12/cpython/longintrepr.h +133 -0
  47. package/python/include/python3.12/cpython/longobject.h +100 -0
  48. package/python/include/python3.12/cpython/memoryobject.h +52 -0
  49. package/python/include/python3.12/cpython/methodobject.h +66 -0
  50. package/python/include/python3.12/cpython/modsupport.h +109 -0
  51. package/python/include/python3.12/cpython/object.h +575 -0
  52. package/python/include/python3.12/cpython/objimpl.h +95 -0
  53. package/python/include/python3.12/cpython/odictobject.h +43 -0
  54. package/python/include/python3.12/cpython/picklebufobject.h +31 -0
  55. package/python/include/python3.12/cpython/pthread_stubs.h +88 -0
  56. package/python/include/python3.12/cpython/pyctype.h +39 -0
  57. package/python/include/python3.12/cpython/pydebug.h +38 -0
  58. package/python/include/python3.12/cpython/pyerrors.h +178 -0
  59. package/python/include/python3.12/cpython/pyfpe.h +15 -0
  60. package/python/include/python3.12/cpython/pyframe.h +35 -0
  61. package/python/include/python3.12/cpython/pylifecycle.h +111 -0
  62. package/python/include/python3.12/cpython/pymem.h +98 -0
  63. package/python/include/python3.12/cpython/pystate.h +456 -0
  64. package/python/include/python3.12/cpython/pythonrun.h +121 -0
  65. package/python/include/python3.12/cpython/pythread.h +42 -0
  66. package/python/include/python3.12/cpython/pytime.h +331 -0
  67. package/python/include/python3.12/cpython/setobject.h +72 -0
  68. package/python/include/python3.12/cpython/sysmodule.h +16 -0
  69. package/python/include/python3.12/cpython/traceback.h +16 -0
  70. package/python/include/python3.12/cpython/tupleobject.h +39 -0
  71. package/python/include/python3.12/cpython/unicodeobject.h +976 -0
  72. package/python/include/python3.12/cpython/warnings.h +20 -0
  73. package/python/include/python3.12/cpython/weakrefobject.h +56 -0
  74. package/python/include/python3.12/datetime.h +267 -0
  75. package/python/include/python3.12/descrobject.h +100 -0
  76. package/python/include/python3.12/dictobject.h +97 -0
  77. package/python/include/python3.12/dynamic_annotations.h +499 -0
  78. package/python/include/python3.12/enumobject.h +17 -0
  79. package/python/include/python3.12/errcode.h +38 -0
  80. package/python/include/python3.12/exports.h +36 -0
  81. package/python/include/python3.12/fileobject.h +49 -0
  82. package/python/include/python3.12/fileutils.h +26 -0
  83. package/python/include/python3.12/floatobject.h +54 -0
  84. package/python/include/python3.12/frameobject.h +20 -0
  85. package/python/include/python3.12/genericaliasobject.h +14 -0
  86. package/python/include/python3.12/import.h +98 -0
  87. package/python/include/python3.12/internal/pycore_abstract.h +25 -0
  88. package/python/include/python3.12/internal/pycore_asdl.h +112 -0
  89. package/python/include/python3.12/internal/pycore_ast.h +922 -0
  90. package/python/include/python3.12/internal/pycore_ast_state.h +265 -0
  91. package/python/include/python3.12/internal/pycore_atexit.h +57 -0
  92. package/python/include/python3.12/internal/pycore_atomic.h +557 -0
  93. package/python/include/python3.12/internal/pycore_atomic_funcs.h +94 -0
  94. package/python/include/python3.12/internal/pycore_bitutils.h +186 -0
  95. package/python/include/python3.12/internal/pycore_blocks_output_buffer.h +317 -0
  96. package/python/include/python3.12/internal/pycore_bytes_methods.h +73 -0
  97. package/python/include/python3.12/internal/pycore_bytesobject.h +47 -0
  98. package/python/include/python3.12/internal/pycore_call.h +133 -0
  99. package/python/include/python3.12/internal/pycore_ceval.h +164 -0
  100. package/python/include/python3.12/internal/pycore_ceval_state.h +103 -0
  101. package/python/include/python3.12/internal/pycore_code.h +496 -0
  102. package/python/include/python3.12/internal/pycore_compile.h +118 -0
  103. package/python/include/python3.12/internal/pycore_condvar.h +99 -0
  104. package/python/include/python3.12/internal/pycore_context.h +71 -0
  105. package/python/include/python3.12/internal/pycore_descrobject.h +26 -0
  106. package/python/include/python3.12/internal/pycore_dict.h +199 -0
  107. package/python/include/python3.12/internal/pycore_dict_state.h +50 -0
  108. package/python/include/python3.12/internal/pycore_dtoa.h +69 -0
  109. package/python/include/python3.12/internal/pycore_emscripten_signal.h +25 -0
  110. package/python/include/python3.12/internal/pycore_exceptions.h +37 -0
  111. package/python/include/python3.12/internal/pycore_faulthandler.h +99 -0
  112. package/python/include/python3.12/internal/pycore_fileutils.h +292 -0
  113. package/python/include/python3.12/internal/pycore_fileutils_windows.h +98 -0
  114. package/python/include/python3.12/internal/pycore_floatobject.h +71 -0
  115. package/python/include/python3.12/internal/pycore_flowgraph.h +120 -0
  116. package/python/include/python3.12/internal/pycore_format.h +27 -0
  117. package/python/include/python3.12/internal/pycore_frame.h +283 -0
  118. package/python/include/python3.12/internal/pycore_function.h +26 -0
  119. package/python/include/python3.12/internal/pycore_gc.h +211 -0
  120. package/python/include/python3.12/internal/pycore_genobject.h +49 -0
  121. package/python/include/python3.12/internal/pycore_getopt.h +22 -0
  122. package/python/include/python3.12/internal/pycore_gil.h +50 -0
  123. package/python/include/python3.12/internal/pycore_global_objects.h +105 -0
  124. package/python/include/python3.12/internal/pycore_global_objects_fini_generated.h +1517 -0
  125. package/python/include/python3.12/internal/pycore_global_strings.h +777 -0
  126. package/python/include/python3.12/internal/pycore_hamt.h +134 -0
  127. package/python/include/python3.12/internal/pycore_hashtable.h +149 -0
  128. package/python/include/python3.12/internal/pycore_import.h +183 -0
  129. package/python/include/python3.12/internal/pycore_initconfig.h +179 -0
  130. package/python/include/python3.12/internal/pycore_instruments.h +106 -0
  131. package/python/include/python3.12/internal/pycore_interp.h +275 -0
  132. package/python/include/python3.12/internal/pycore_intrinsics.h +32 -0
  133. package/python/include/python3.12/internal/pycore_list.h +83 -0
  134. package/python/include/python3.12/internal/pycore_long.h +258 -0
  135. package/python/include/python3.12/internal/pycore_memoryobject.h +18 -0
  136. package/python/include/python3.12/internal/pycore_moduleobject.h +45 -0
  137. package/python/include/python3.12/internal/pycore_namespace.h +20 -0
  138. package/python/include/python3.12/internal/pycore_object.h +455 -0
  139. package/python/include/python3.12/internal/pycore_object_state.h +42 -0
  140. package/python/include/python3.12/internal/pycore_obmalloc.h +700 -0
  141. package/python/include/python3.12/internal/pycore_obmalloc_init.h +73 -0
  142. package/python/include/python3.12/internal/pycore_opcode.h +587 -0
  143. package/python/include/python3.12/internal/pycore_opcode_utils.h +92 -0
  144. package/python/include/python3.12/internal/pycore_parser.h +66 -0
  145. package/python/include/python3.12/internal/pycore_pathconfig.h +24 -0
  146. package/python/include/python3.12/internal/pycore_pyarena.h +64 -0
  147. package/python/include/python3.12/internal/pycore_pyerrors.h +129 -0
  148. package/python/include/python3.12/internal/pycore_pyhash.h +40 -0
  149. package/python/include/python3.12/internal/pycore_pylifecycle.h +99 -0
  150. package/python/include/python3.12/internal/pycore_pymath.h +205 -0
  151. package/python/include/python3.12/internal/pycore_pymem.h +98 -0
  152. package/python/include/python3.12/internal/pycore_pymem_init.h +85 -0
  153. package/python/include/python3.12/internal/pycore_pystate.h +180 -0
  154. package/python/include/python3.12/internal/pycore_pythread.h +81 -0
  155. package/python/include/python3.12/internal/pycore_range.h +21 -0
  156. package/python/include/python3.12/internal/pycore_runtime.h +235 -0
  157. package/python/include/python3.12/internal/pycore_runtime_init.h +188 -0
  158. package/python/include/python3.12/internal/pycore_runtime_init_generated.h +1511 -0
  159. package/python/include/python3.12/internal/pycore_signal.h +98 -0
  160. package/python/include/python3.12/internal/pycore_sliceobject.h +22 -0
  161. package/python/include/python3.12/internal/pycore_strhex.h +36 -0
  162. package/python/include/python3.12/internal/pycore_structseq.h +39 -0
  163. package/python/include/python3.12/internal/pycore_symtable.h +160 -0
  164. package/python/include/python3.12/internal/pycore_sysmodule.h +34 -0
  165. package/python/include/python3.12/internal/pycore_time.h +25 -0
  166. package/python/include/python3.12/internal/pycore_token.h +108 -0
  167. package/python/include/python3.12/internal/pycore_traceback.h +101 -0
  168. package/python/include/python3.12/internal/pycore_tracemalloc.h +123 -0
  169. package/python/include/python3.12/internal/pycore_tuple.h +79 -0
  170. package/python/include/python3.12/internal/pycore_typeobject.h +151 -0
  171. package/python/include/python3.12/internal/pycore_typevarobject.h +24 -0
  172. package/python/include/python3.12/internal/pycore_ucnhash.h +34 -0
  173. package/python/include/python3.12/internal/pycore_unicodeobject.h +86 -0
  174. package/python/include/python3.12/internal/pycore_unicodeobject_generated.h +2832 -0
  175. package/python/include/python3.12/internal/pycore_unionobject.h +23 -0
  176. package/python/include/python3.12/internal/pycore_warnings.h +29 -0
  177. package/python/include/python3.12/interpreteridobject.h +17 -0
  178. package/python/include/python3.12/intrcheck.h +30 -0
  179. package/python/include/python3.12/iterobject.h +27 -0
  180. package/python/include/python3.12/listobject.h +52 -0
  181. package/python/include/python3.12/longobject.h +108 -0
  182. package/python/include/python3.12/marshal.h +31 -0
  183. package/python/include/python3.12/memoryobject.h +34 -0
  184. package/python/include/python3.12/methodobject.h +132 -0
  185. package/python/include/python3.12/modsupport.h +168 -0
  186. package/python/include/python3.12/moduleobject.h +119 -0
  187. package/python/include/python3.12/object.h +993 -0
  188. package/python/include/python3.12/objimpl.h +234 -0
  189. package/python/include/python3.12/opcode.h +271 -0
  190. package/python/include/python3.12/osdefs.h +51 -0
  191. package/python/include/python3.12/osmodule.h +17 -0
  192. package/python/include/python3.12/patchlevel.h +35 -0
  193. package/python/include/python3.12/py_curses.h +99 -0
  194. package/python/include/python3.12/pybuffer.h +145 -0
  195. package/python/include/python3.12/pycapsule.h +59 -0
  196. package/python/include/python3.12/pyconfig.h +1943 -0
  197. package/python/include/python3.12/pydtrace.h +59 -0
  198. package/python/include/python3.12/pyerrors.h +337 -0
  199. package/python/include/python3.12/pyexpat.h +62 -0
  200. package/python/include/python3.12/pyframe.h +26 -0
  201. package/python/include/python3.12/pyhash.h +144 -0
  202. package/python/include/python3.12/pylifecycle.h +78 -0
  203. package/python/include/python3.12/pymacconfig.h +99 -0
  204. package/python/include/python3.12/pymacro.h +172 -0
  205. package/python/include/python3.12/pymath.h +62 -0
  206. package/python/include/python3.12/pymem.h +104 -0
  207. package/python/include/python3.12/pyport.h +782 -0
  208. package/python/include/python3.12/pystate.h +132 -0
  209. package/python/include/python3.12/pystats.h +110 -0
  210. package/python/include/python3.12/pystrcmp.h +23 -0
  211. package/python/include/python3.12/pystrtod.h +46 -0
  212. package/python/include/python3.12/pythonrun.h +49 -0
  213. package/python/include/python3.12/pythread.h +135 -0
  214. package/python/include/python3.12/pytypedefs.h +30 -0
  215. package/python/include/python3.12/rangeobject.h +27 -0
  216. package/python/include/python3.12/setobject.h +49 -0
  217. package/python/include/python3.12/sliceobject.h +65 -0
  218. package/python/include/python3.12/structmember.h +56 -0
  219. package/python/include/python3.12/structseq.h +49 -0
  220. package/python/include/python3.12/sysmodule.h +54 -0
  221. package/python/include/python3.12/traceback.h +26 -0
  222. package/python/include/python3.12/tracemalloc.h +77 -0
  223. package/python/include/python3.12/tupleobject.h +46 -0
  224. package/python/include/python3.12/typeslots.h +88 -0
  225. package/python/include/python3.12/unicodeobject.h +1020 -0
  226. package/python/include/python3.12/warnings.h +45 -0
  227. package/python/include/python3.12/weakrefobject.h +42 -0
  228. package/python/lib/libpython3.12.dylib +0 -0
  229. package/python/lib/python3.12/LICENSE.txt +279 -0
  230. package/python/lib/python3.12/__future__.py +147 -0
  231. package/python/lib/python3.12/__hello__.py +16 -0
  232. package/python/lib/python3.12/__phello__/__init__.py +7 -0
  233. package/python/lib/python3.12/__phello__/spam.py +7 -0
  234. package/python/lib/python3.12/__pycache__/_compression.cpython-312.pyc +0 -0
  235. package/python/lib/python3.12/__pycache__/_weakrefset.cpython-312.pyc +0 -0
  236. package/python/lib/python3.12/__pycache__/base64.cpython-312.pyc +0 -0
  237. package/python/lib/python3.12/__pycache__/bisect.cpython-312.pyc +0 -0
  238. package/python/lib/python3.12/__pycache__/bz2.cpython-312.pyc +0 -0
  239. package/python/lib/python3.12/__pycache__/calendar.cpython-312.pyc +0 -0
  240. package/python/lib/python3.12/__pycache__/contextlib.cpython-312.pyc +0 -0
  241. package/python/lib/python3.12/__pycache__/copyreg.cpython-312.pyc +0 -0
  242. package/python/lib/python3.12/__pycache__/datetime.cpython-312.pyc +0 -0
  243. package/python/lib/python3.12/__pycache__/enum.cpython-312.pyc +0 -0
  244. package/python/lib/python3.12/__pycache__/fnmatch.cpython-312.pyc +0 -0
  245. package/python/lib/python3.12/__pycache__/functools.cpython-312.pyc +0 -0
  246. package/python/lib/python3.12/__pycache__/hashlib.cpython-312.pyc +0 -0
  247. package/python/lib/python3.12/__pycache__/hmac.cpython-312.pyc +0 -0
  248. package/python/lib/python3.12/__pycache__/ipaddress.cpython-312.pyc +0 -0
  249. package/python/lib/python3.12/__pycache__/keyword.cpython-312.pyc +0 -0
  250. package/python/lib/python3.12/__pycache__/locale.cpython-312.pyc +0 -0
  251. package/python/lib/python3.12/__pycache__/lzma.cpython-312.pyc +0 -0
  252. package/python/lib/python3.12/__pycache__/operator.cpython-312.pyc +0 -0
  253. package/python/lib/python3.12/__pycache__/plistlib.cpython-312.pyc +0 -0
  254. package/python/lib/python3.12/__pycache__/pty.cpython-312.pyc +0 -0
  255. package/python/lib/python3.12/__pycache__/quopri.cpython-312.pyc +0 -0
  256. package/python/lib/python3.12/__pycache__/random.cpython-312.pyc +0 -0
  257. package/python/lib/python3.12/__pycache__/reprlib.cpython-312.pyc +0 -0
  258. package/python/lib/python3.12/__pycache__/selectors.cpython-312.pyc +0 -0
  259. package/python/lib/python3.12/__pycache__/shutil.cpython-312.pyc +0 -0
  260. package/python/lib/python3.12/__pycache__/signal.cpython-312.pyc +0 -0
  261. package/python/lib/python3.12/__pycache__/socket.cpython-312.pyc +0 -0
  262. package/python/lib/python3.12/__pycache__/ssl.cpython-312.pyc +0 -0
  263. package/python/lib/python3.12/__pycache__/string.cpython-312.pyc +0 -0
  264. package/python/lib/python3.12/__pycache__/struct.cpython-312.pyc +0 -0
  265. package/python/lib/python3.12/__pycache__/subprocess.cpython-312.pyc +0 -0
  266. package/python/lib/python3.12/__pycache__/tempfile.cpython-312.pyc +0 -0
  267. package/python/lib/python3.12/__pycache__/threading.cpython-312.pyc +0 -0
  268. package/python/lib/python3.12/__pycache__/tty.cpython-312.pyc +0 -0
  269. package/python/lib/python3.12/__pycache__/types.cpython-312.pyc +0 -0
  270. package/python/lib/python3.12/__pycache__/warnings.cpython-312.pyc +0 -0
  271. package/python/lib/python3.12/__pycache__/weakref.cpython-312.pyc +0 -0
  272. package/python/lib/python3.12/_aix_support.py +108 -0
  273. package/python/lib/python3.12/_collections_abc.py +1173 -0
  274. package/python/lib/python3.12/_compat_pickle.py +252 -0
  275. package/python/lib/python3.12/_compression.py +162 -0
  276. package/python/lib/python3.12/_markupbase.py +396 -0
  277. package/python/lib/python3.12/_osx_support.py +579 -0
  278. package/python/lib/python3.12/_py_abc.py +147 -0
  279. package/python/lib/python3.12/_pydatetime.py +2643 -0
  280. package/python/lib/python3.12/_pydecimal.py +6339 -0
  281. package/python/lib/python3.12/_pyio.py +2698 -0
  282. package/python/lib/python3.12/_pylong.py +329 -0
  283. package/python/lib/python3.12/_sitebuiltins.py +103 -0
  284. package/python/lib/python3.12/_strptime.py +664 -0
  285. package/python/lib/python3.12/_sysconfigdata__darwin_darwin.py +984 -0
  286. package/python/lib/python3.12/_threading_local.py +242 -0
  287. package/python/lib/python3.12/_weakrefset.py +205 -0
  288. package/python/lib/python3.12/abc.py +188 -0
  289. package/python/lib/python3.12/aifc.py +984 -0
  290. package/python/lib/python3.12/antigravity.py +17 -0
  291. package/python/lib/python3.12/argparse.py +2650 -0
  292. package/python/lib/python3.12/ast.py +1840 -0
  293. package/python/lib/python3.12/asyncio/__init__.py +47 -0
  294. package/python/lib/python3.12/asyncio/__main__.py +128 -0
  295. package/python/lib/python3.12/asyncio/base_events.py +2024 -0
  296. package/python/lib/python3.12/asyncio/base_futures.py +67 -0
  297. package/python/lib/python3.12/asyncio/base_subprocess.py +285 -0
  298. package/python/lib/python3.12/asyncio/base_tasks.py +94 -0
  299. package/python/lib/python3.12/asyncio/constants.py +41 -0
  300. package/python/lib/python3.12/asyncio/coroutines.py +109 -0
  301. package/python/lib/python3.12/asyncio/events.py +868 -0
  302. package/python/lib/python3.12/asyncio/exceptions.py +62 -0
  303. package/python/lib/python3.12/asyncio/format_helpers.py +76 -0
  304. package/python/lib/python3.12/asyncio/futures.py +430 -0
  305. package/python/lib/python3.12/asyncio/locks.py +586 -0
  306. package/python/lib/python3.12/asyncio/log.py +7 -0
  307. package/python/lib/python3.12/asyncio/mixins.py +21 -0
  308. package/python/lib/python3.12/asyncio/proactor_events.py +897 -0
  309. package/python/lib/python3.12/asyncio/protocols.py +216 -0
  310. package/python/lib/python3.12/asyncio/queues.py +244 -0
  311. package/python/lib/python3.12/asyncio/runners.py +216 -0
  312. package/python/lib/python3.12/asyncio/selector_events.py +1324 -0
  313. package/python/lib/python3.12/asyncio/sslproto.py +929 -0
  314. package/python/lib/python3.12/asyncio/staggered.py +174 -0
  315. package/python/lib/python3.12/asyncio/streams.py +770 -0
  316. package/python/lib/python3.12/asyncio/subprocess.py +229 -0
  317. package/python/lib/python3.12/asyncio/taskgroups.py +268 -0
  318. package/python/lib/python3.12/asyncio/tasks.py +1065 -0
  319. package/python/lib/python3.12/asyncio/threads.py +25 -0
  320. package/python/lib/python3.12/asyncio/timeouts.py +168 -0
  321. package/python/lib/python3.12/asyncio/transports.py +335 -0
  322. package/python/lib/python3.12/asyncio/trsock.py +98 -0
  323. package/python/lib/python3.12/asyncio/unix_events.py +1500 -0
  324. package/python/lib/python3.12/asyncio/windows_events.py +901 -0
  325. package/python/lib/python3.12/asyncio/windows_utils.py +173 -0
  326. package/python/lib/python3.12/base64.py +586 -0
  327. package/python/lib/python3.12/bdb.py +920 -0
  328. package/python/lib/python3.12/bisect.py +118 -0
  329. package/python/lib/python3.12/bz2.py +344 -0
  330. package/python/lib/python3.12/cProfile.py +195 -0
  331. package/python/lib/python3.12/calendar.py +808 -0
  332. package/python/lib/python3.12/cgi.py +1014 -0
  333. package/python/lib/python3.12/cgitb.py +332 -0
  334. package/python/lib/python3.12/chunk.py +173 -0
  335. package/python/lib/python3.12/cmd.py +401 -0
  336. package/python/lib/python3.12/code.py +324 -0
  337. package/python/lib/python3.12/codecs.py +1129 -0
  338. package/python/lib/python3.12/codeop.py +161 -0
  339. package/python/lib/python3.12/collections/__init__.py +1592 -0
  340. package/python/lib/python3.12/collections/__pycache__/__init__.cpython-312.pyc +0 -0
  341. package/python/lib/python3.12/collections/__pycache__/abc.cpython-312.pyc +0 -0
  342. package/python/lib/python3.12/collections/abc.py +3 -0
  343. package/python/lib/python3.12/colorsys.py +166 -0
  344. package/python/lib/python3.12/compileall.py +469 -0
  345. package/python/lib/python3.12/concurrent/__init__.py +1 -0
  346. package/python/lib/python3.12/concurrent/futures/__init__.py +54 -0
  347. package/python/lib/python3.12/concurrent/futures/_base.py +654 -0
  348. package/python/lib/python3.12/concurrent/futures/process.py +876 -0
  349. package/python/lib/python3.12/concurrent/futures/thread.py +240 -0
  350. package/python/lib/python3.12/config-3.12-darwin/Makefile +3224 -0
  351. package/python/lib/python3.12/config-3.12-darwin/Setup +303 -0
  352. package/python/lib/python3.12/config-3.12-darwin/Setup.bootstrap +36 -0
  353. package/python/lib/python3.12/config-3.12-darwin/Setup.local +90 -0
  354. package/python/lib/python3.12/config-3.12-darwin/Setup.stdlib +183 -0
  355. package/python/lib/python3.12/config-3.12-darwin/config.c +246 -0
  356. package/python/lib/python3.12/config-3.12-darwin/config.c.in +71 -0
  357. package/python/lib/python3.12/config-3.12-darwin/install-sh +541 -0
  358. package/python/lib/python3.12/config-3.12-darwin/makesetup +353 -0
  359. package/python/lib/python3.12/config-3.12-darwin/python-config.py +76 -0
  360. package/python/lib/python3.12/config-3.12-darwin/python.o +0 -0
  361. package/python/lib/python3.12/configparser.py +1333 -0
  362. package/python/lib/python3.12/contextlib.py +800 -0
  363. package/python/lib/python3.12/contextvars.py +4 -0
  364. package/python/lib/python3.12/copy.py +292 -0
  365. package/python/lib/python3.12/copyreg.py +217 -0
  366. package/python/lib/python3.12/crypt.py +124 -0
  367. package/python/lib/python3.12/csv.py +451 -0
  368. package/python/lib/python3.12/ctypes/__init__.py +582 -0
  369. package/python/lib/python3.12/ctypes/_aix.py +327 -0
  370. package/python/lib/python3.12/ctypes/_endian.py +78 -0
  371. package/python/lib/python3.12/ctypes/macholib/README.ctypes +7 -0
  372. package/python/lib/python3.12/ctypes/macholib/__init__.py +9 -0
  373. package/python/lib/python3.12/ctypes/macholib/dyld.py +165 -0
  374. package/python/lib/python3.12/ctypes/macholib/dylib.py +42 -0
  375. package/python/lib/python3.12/ctypes/macholib/fetch_macholib +2 -0
  376. package/python/lib/python3.12/ctypes/macholib/fetch_macholib.bat +1 -0
  377. package/python/lib/python3.12/ctypes/macholib/framework.py +42 -0
  378. package/python/lib/python3.12/ctypes/util.py +379 -0
  379. package/python/lib/python3.12/ctypes/wintypes.py +202 -0
  380. package/python/lib/python3.12/curses/__init__.py +101 -0
  381. package/python/lib/python3.12/curses/ascii.py +99 -0
  382. package/python/lib/python3.12/curses/has_key.py +192 -0
  383. package/python/lib/python3.12/curses/panel.py +6 -0
  384. package/python/lib/python3.12/curses/textpad.py +204 -0
  385. package/python/lib/python3.12/dataclasses.py +1588 -0
  386. package/python/lib/python3.12/datetime.py +9 -0
  387. package/python/lib/python3.12/dbm/__init__.py +190 -0
  388. package/python/lib/python3.12/dbm/dumb.py +317 -0
  389. package/python/lib/python3.12/dbm/gnu.py +3 -0
  390. package/python/lib/python3.12/dbm/ndbm.py +3 -0
  391. package/python/lib/python3.12/decimal.py +108 -0
  392. package/python/lib/python3.12/difflib.py +2056 -0
  393. package/python/lib/python3.12/dis.py +805 -0
  394. package/python/lib/python3.12/doctest.py +2845 -0
  395. package/python/lib/python3.12/email/__init__.py +61 -0
  396. package/python/lib/python3.12/email/__pycache__/__init__.cpython-312.pyc +0 -0
  397. package/python/lib/python3.12/email/__pycache__/_encoded_words.cpython-312.pyc +0 -0
  398. package/python/lib/python3.12/email/__pycache__/_parseaddr.cpython-312.pyc +0 -0
  399. package/python/lib/python3.12/email/__pycache__/_policybase.cpython-312.pyc +0 -0
  400. package/python/lib/python3.12/email/__pycache__/base64mime.cpython-312.pyc +0 -0
  401. package/python/lib/python3.12/email/__pycache__/charset.cpython-312.pyc +0 -0
  402. package/python/lib/python3.12/email/__pycache__/encoders.cpython-312.pyc +0 -0
  403. package/python/lib/python3.12/email/__pycache__/errors.cpython-312.pyc +0 -0
  404. package/python/lib/python3.12/email/__pycache__/feedparser.cpython-312.pyc +0 -0
  405. package/python/lib/python3.12/email/__pycache__/header.cpython-312.pyc +0 -0
  406. package/python/lib/python3.12/email/__pycache__/iterators.cpython-312.pyc +0 -0
  407. package/python/lib/python3.12/email/__pycache__/message.cpython-312.pyc +0 -0
  408. package/python/lib/python3.12/email/__pycache__/parser.cpython-312.pyc +0 -0
  409. package/python/lib/python3.12/email/__pycache__/quoprimime.cpython-312.pyc +0 -0
  410. package/python/lib/python3.12/email/__pycache__/utils.cpython-312.pyc +0 -0
  411. package/python/lib/python3.12/email/_encoded_words.py +233 -0
  412. package/python/lib/python3.12/email/_header_value_parser.py +3108 -0
  413. package/python/lib/python3.12/email/_parseaddr.py +557 -0
  414. package/python/lib/python3.12/email/_policybase.py +382 -0
  415. package/python/lib/python3.12/email/architecture.rst +216 -0
  416. package/python/lib/python3.12/email/base64mime.py +115 -0
  417. package/python/lib/python3.12/email/charset.py +398 -0
  418. package/python/lib/python3.12/email/contentmanager.py +251 -0
  419. package/python/lib/python3.12/email/encoders.py +65 -0
  420. package/python/lib/python3.12/email/errors.py +117 -0
  421. package/python/lib/python3.12/email/feedparser.py +534 -0
  422. package/python/lib/python3.12/email/generator.py +530 -0
  423. package/python/lib/python3.12/email/header.py +573 -0
  424. package/python/lib/python3.12/email/headerregistry.py +604 -0
  425. package/python/lib/python3.12/email/iterators.py +68 -0
  426. package/python/lib/python3.12/email/message.py +1215 -0
  427. package/python/lib/python3.12/email/mime/__init__.py +0 -0
  428. package/python/lib/python3.12/email/mime/application.py +37 -0
  429. package/python/lib/python3.12/email/mime/audio.py +100 -0
  430. package/python/lib/python3.12/email/mime/base.py +29 -0
  431. package/python/lib/python3.12/email/mime/image.py +152 -0
  432. package/python/lib/python3.12/email/mime/message.py +33 -0
  433. package/python/lib/python3.12/email/mime/multipart.py +47 -0
  434. package/python/lib/python3.12/email/mime/nonmultipart.py +21 -0
  435. package/python/lib/python3.12/email/mime/text.py +40 -0
  436. package/python/lib/python3.12/email/parser.py +127 -0
  437. package/python/lib/python3.12/email/policy.py +232 -0
  438. package/python/lib/python3.12/email/quoprimime.py +300 -0
  439. package/python/lib/python3.12/email/utils.py +486 -0
  440. package/python/lib/python3.12/encodings/__init__.py +174 -0
  441. package/python/lib/python3.12/encodings/__pycache__/__init__.cpython-312.pyc +0 -0
  442. package/python/lib/python3.12/encodings/__pycache__/aliases.cpython-312.pyc +0 -0
  443. package/python/lib/python3.12/encodings/__pycache__/utf_8.cpython-312.pyc +0 -0
  444. package/python/lib/python3.12/encodings/aliases.py +551 -0
  445. package/python/lib/python3.12/encodings/ascii.py +50 -0
  446. package/python/lib/python3.12/encodings/base64_codec.py +55 -0
  447. package/python/lib/python3.12/encodings/big5.py +39 -0
  448. package/python/lib/python3.12/encodings/big5hkscs.py +39 -0
  449. package/python/lib/python3.12/encodings/bz2_codec.py +78 -0
  450. package/python/lib/python3.12/encodings/charmap.py +69 -0
  451. package/python/lib/python3.12/encodings/cp037.py +307 -0
  452. package/python/lib/python3.12/encodings/cp1006.py +307 -0
  453. package/python/lib/python3.12/encodings/cp1026.py +307 -0
  454. package/python/lib/python3.12/encodings/cp1125.py +698 -0
  455. package/python/lib/python3.12/encodings/cp1140.py +307 -0
  456. package/python/lib/python3.12/encodings/cp1250.py +307 -0
  457. package/python/lib/python3.12/encodings/cp1251.py +307 -0
  458. package/python/lib/python3.12/encodings/cp1252.py +307 -0
  459. package/python/lib/python3.12/encodings/cp1253.py +307 -0
  460. package/python/lib/python3.12/encodings/cp1254.py +307 -0
  461. package/python/lib/python3.12/encodings/cp1255.py +307 -0
  462. package/python/lib/python3.12/encodings/cp1256.py +307 -0
  463. package/python/lib/python3.12/encodings/cp1257.py +307 -0
  464. package/python/lib/python3.12/encodings/cp1258.py +307 -0
  465. package/python/lib/python3.12/encodings/cp273.py +307 -0
  466. package/python/lib/python3.12/encodings/cp424.py +307 -0
  467. package/python/lib/python3.12/encodings/cp437.py +698 -0
  468. package/python/lib/python3.12/encodings/cp500.py +307 -0
  469. package/python/lib/python3.12/encodings/cp720.py +309 -0
  470. package/python/lib/python3.12/encodings/cp737.py +698 -0
  471. package/python/lib/python3.12/encodings/cp775.py +697 -0
  472. package/python/lib/python3.12/encodings/cp850.py +698 -0
  473. package/python/lib/python3.12/encodings/cp852.py +698 -0
  474. package/python/lib/python3.12/encodings/cp855.py +698 -0
  475. package/python/lib/python3.12/encodings/cp856.py +307 -0
  476. package/python/lib/python3.12/encodings/cp857.py +694 -0
  477. package/python/lib/python3.12/encodings/cp858.py +698 -0
  478. package/python/lib/python3.12/encodings/cp860.py +698 -0
  479. package/python/lib/python3.12/encodings/cp861.py +698 -0
  480. package/python/lib/python3.12/encodings/cp862.py +698 -0
  481. package/python/lib/python3.12/encodings/cp863.py +698 -0
  482. package/python/lib/python3.12/encodings/cp864.py +690 -0
  483. package/python/lib/python3.12/encodings/cp865.py +698 -0
  484. package/python/lib/python3.12/encodings/cp866.py +698 -0
  485. package/python/lib/python3.12/encodings/cp869.py +689 -0
  486. package/python/lib/python3.12/encodings/cp874.py +307 -0
  487. package/python/lib/python3.12/encodings/cp875.py +307 -0
  488. package/python/lib/python3.12/encodings/cp932.py +39 -0
  489. package/python/lib/python3.12/encodings/cp949.py +39 -0
  490. package/python/lib/python3.12/encodings/cp950.py +39 -0
  491. package/python/lib/python3.12/encodings/euc_jis_2004.py +39 -0
  492. package/python/lib/python3.12/encodings/euc_jisx0213.py +39 -0
  493. package/python/lib/python3.12/encodings/euc_jp.py +39 -0
  494. package/python/lib/python3.12/encodings/euc_kr.py +39 -0
  495. package/python/lib/python3.12/encodings/gb18030.py +39 -0
  496. package/python/lib/python3.12/encodings/gb2312.py +39 -0
  497. package/python/lib/python3.12/encodings/gbk.py +39 -0
  498. package/python/lib/python3.12/encodings/hex_codec.py +55 -0
  499. package/python/lib/python3.12/encodings/hp_roman8.py +314 -0
  500. package/python/lib/python3.12/encodings/hz.py +39 -0
  501. package/python/lib/python3.12/encodings/idna.py +317 -0
  502. package/python/lib/python3.12/encodings/iso2022_jp.py +39 -0
  503. package/python/lib/python3.12/encodings/iso2022_jp_1.py +39 -0
  504. package/python/lib/python3.12/encodings/iso2022_jp_2.py +39 -0
  505. package/python/lib/python3.12/encodings/iso2022_jp_2004.py +39 -0
  506. package/python/lib/python3.12/encodings/iso2022_jp_3.py +39 -0
  507. package/python/lib/python3.12/encodings/iso2022_jp_ext.py +39 -0
  508. package/python/lib/python3.12/encodings/iso2022_kr.py +39 -0
  509. package/python/lib/python3.12/encodings/iso8859_1.py +307 -0
  510. package/python/lib/python3.12/encodings/iso8859_10.py +307 -0
  511. package/python/lib/python3.12/encodings/iso8859_11.py +307 -0
  512. package/python/lib/python3.12/encodings/iso8859_13.py +307 -0
  513. package/python/lib/python3.12/encodings/iso8859_14.py +307 -0
  514. package/python/lib/python3.12/encodings/iso8859_15.py +307 -0
  515. package/python/lib/python3.12/encodings/iso8859_16.py +307 -0
  516. package/python/lib/python3.12/encodings/iso8859_2.py +307 -0
  517. package/python/lib/python3.12/encodings/iso8859_3.py +307 -0
  518. package/python/lib/python3.12/encodings/iso8859_4.py +307 -0
  519. package/python/lib/python3.12/encodings/iso8859_5.py +307 -0
  520. package/python/lib/python3.12/encodings/iso8859_6.py +307 -0
  521. package/python/lib/python3.12/encodings/iso8859_7.py +307 -0
  522. package/python/lib/python3.12/encodings/iso8859_8.py +307 -0
  523. package/python/lib/python3.12/encodings/iso8859_9.py +307 -0
  524. package/python/lib/python3.12/encodings/johab.py +39 -0
  525. package/python/lib/python3.12/encodings/koi8_r.py +307 -0
  526. package/python/lib/python3.12/encodings/koi8_t.py +308 -0
  527. package/python/lib/python3.12/encodings/koi8_u.py +307 -0
  528. package/python/lib/python3.12/encodings/kz1048.py +307 -0
  529. package/python/lib/python3.12/encodings/latin_1.py +50 -0
  530. package/python/lib/python3.12/encodings/mac_arabic.py +698 -0
  531. package/python/lib/python3.12/encodings/mac_croatian.py +307 -0
  532. package/python/lib/python3.12/encodings/mac_cyrillic.py +307 -0
  533. package/python/lib/python3.12/encodings/mac_farsi.py +307 -0
  534. package/python/lib/python3.12/encodings/mac_greek.py +307 -0
  535. package/python/lib/python3.12/encodings/mac_iceland.py +307 -0
  536. package/python/lib/python3.12/encodings/mac_latin2.py +312 -0
  537. package/python/lib/python3.12/encodings/mac_roman.py +307 -0
  538. package/python/lib/python3.12/encodings/mac_romanian.py +307 -0
  539. package/python/lib/python3.12/encodings/mac_turkish.py +307 -0
  540. package/python/lib/python3.12/encodings/mbcs.py +47 -0
  541. package/python/lib/python3.12/encodings/oem.py +41 -0
  542. package/python/lib/python3.12/encodings/palmos.py +308 -0
  543. package/python/lib/python3.12/encodings/ptcp154.py +312 -0
  544. package/python/lib/python3.12/encodings/punycode.py +237 -0
  545. package/python/lib/python3.12/encodings/quopri_codec.py +56 -0
  546. package/python/lib/python3.12/encodings/raw_unicode_escape.py +46 -0
  547. package/python/lib/python3.12/encodings/rot_13.py +113 -0
  548. package/python/lib/python3.12/encodings/shift_jis.py +39 -0
  549. package/python/lib/python3.12/encodings/shift_jis_2004.py +39 -0
  550. package/python/lib/python3.12/encodings/shift_jisx0213.py +39 -0
  551. package/python/lib/python3.12/encodings/tis_620.py +307 -0
  552. package/python/lib/python3.12/encodings/undefined.py +49 -0
  553. package/python/lib/python3.12/encodings/unicode_escape.py +46 -0
  554. package/python/lib/python3.12/encodings/utf_16.py +155 -0
  555. package/python/lib/python3.12/encodings/utf_16_be.py +42 -0
  556. package/python/lib/python3.12/encodings/utf_16_le.py +42 -0
  557. package/python/lib/python3.12/encodings/utf_32.py +150 -0
  558. package/python/lib/python3.12/encodings/utf_32_be.py +37 -0
  559. package/python/lib/python3.12/encodings/utf_32_le.py +37 -0
  560. package/python/lib/python3.12/encodings/utf_7.py +38 -0
  561. package/python/lib/python3.12/encodings/utf_8.py +42 -0
  562. package/python/lib/python3.12/encodings/utf_8_sig.py +130 -0
  563. package/python/lib/python3.12/encodings/uu_codec.py +103 -0
  564. package/python/lib/python3.12/encodings/zlib_codec.py +77 -0
  565. package/python/lib/python3.12/ensurepip/__init__.py +291 -0
  566. package/python/lib/python3.12/ensurepip/__main__.py +5 -0
  567. package/python/lib/python3.12/ensurepip/_bundled/pip-25.0.1-py3-none-any.whl +0 -0
  568. package/python/lib/python3.12/ensurepip/_uninstall.py +31 -0
  569. package/python/lib/python3.12/enum.py +2108 -0
  570. package/python/lib/python3.12/filecmp.py +315 -0
  571. package/python/lib/python3.12/fileinput.py +442 -0
  572. package/python/lib/python3.12/fnmatch.py +185 -0
  573. package/python/lib/python3.12/fractions.py +990 -0
  574. package/python/lib/python3.12/ftplib.py +966 -0
  575. package/python/lib/python3.12/functools.py +1009 -0
  576. package/python/lib/python3.12/genericpath.py +176 -0
  577. package/python/lib/python3.12/getopt.py +215 -0
  578. package/python/lib/python3.12/getpass.py +185 -0
  579. package/python/lib/python3.12/gettext.py +646 -0
  580. package/python/lib/python3.12/glob.py +252 -0
  581. package/python/lib/python3.12/graphlib.py +250 -0
  582. package/python/lib/python3.12/gzip.py +711 -0
  583. package/python/lib/python3.12/hashlib.py +253 -0
  584. package/python/lib/python3.12/heapq.py +603 -0
  585. package/python/lib/python3.12/hmac.py +219 -0
  586. package/python/lib/python3.12/html/__init__.py +132 -0
  587. package/python/lib/python3.12/html/entities.py +2513 -0
  588. package/python/lib/python3.12/html/parser.py +535 -0
  589. package/python/lib/python3.12/http/__init__.py +200 -0
  590. package/python/lib/python3.12/http/__pycache__/__init__.cpython-312.pyc +0 -0
  591. package/python/lib/python3.12/http/__pycache__/client.cpython-312.pyc +0 -0
  592. package/python/lib/python3.12/http/client.py +1570 -0
  593. package/python/lib/python3.12/http/cookiejar.py +2121 -0
  594. package/python/lib/python3.12/http/cookies.py +615 -0
  595. package/python/lib/python3.12/http/server.py +1335 -0
  596. package/python/lib/python3.12/imaplib.py +1641 -0
  597. package/python/lib/python3.12/imghdr.py +180 -0
  598. package/python/lib/python3.12/importlib/__init__.py +138 -0
  599. package/python/lib/python3.12/importlib/_abc.py +39 -0
  600. package/python/lib/python3.12/importlib/_bootstrap.py +1551 -0
  601. package/python/lib/python3.12/importlib/_bootstrap_external.py +1749 -0
  602. package/python/lib/python3.12/importlib/abc.py +239 -0
  603. package/python/lib/python3.12/importlib/machinery.py +20 -0
  604. package/python/lib/python3.12/importlib/metadata/__init__.py +966 -0
  605. package/python/lib/python3.12/importlib/metadata/_adapters.py +89 -0
  606. package/python/lib/python3.12/importlib/metadata/_collections.py +30 -0
  607. package/python/lib/python3.12/importlib/metadata/_functools.py +104 -0
  608. package/python/lib/python3.12/importlib/metadata/_itertools.py +73 -0
  609. package/python/lib/python3.12/importlib/metadata/_meta.py +63 -0
  610. package/python/lib/python3.12/importlib/metadata/_text.py +99 -0
  611. package/python/lib/python3.12/importlib/readers.py +12 -0
  612. package/python/lib/python3.12/importlib/resources/__init__.py +38 -0
  613. package/python/lib/python3.12/importlib/resources/_adapters.py +168 -0
  614. package/python/lib/python3.12/importlib/resources/_common.py +208 -0
  615. package/python/lib/python3.12/importlib/resources/_itertools.py +38 -0
  616. package/python/lib/python3.12/importlib/resources/_legacy.py +98 -0
  617. package/python/lib/python3.12/importlib/resources/abc.py +173 -0
  618. package/python/lib/python3.12/importlib/resources/readers.py +146 -0
  619. package/python/lib/python3.12/importlib/resources/simple.py +106 -0
  620. package/python/lib/python3.12/importlib/simple.py +14 -0
  621. package/python/lib/python3.12/importlib/util.py +270 -0
  622. package/python/lib/python3.12/inspect.py +3433 -0
  623. package/python/lib/python3.12/io.py +99 -0
  624. package/python/lib/python3.12/ipaddress.py +2430 -0
  625. package/python/lib/python3.12/json/__init__.py +359 -0
  626. package/python/lib/python3.12/json/__pycache__/__init__.cpython-312.pyc +0 -0
  627. package/python/lib/python3.12/json/__pycache__/decoder.cpython-312.pyc +0 -0
  628. package/python/lib/python3.12/json/__pycache__/encoder.cpython-312.pyc +0 -0
  629. package/python/lib/python3.12/json/__pycache__/scanner.cpython-312.pyc +0 -0
  630. package/python/lib/python3.12/json/decoder.py +357 -0
  631. package/python/lib/python3.12/json/encoder.py +443 -0
  632. package/python/lib/python3.12/json/scanner.py +73 -0
  633. package/python/lib/python3.12/json/tool.py +85 -0
  634. package/python/lib/python3.12/keyword.py +64 -0
  635. package/python/lib/python3.12/lib-dynload/.empty +0 -0
  636. package/python/lib/python3.12/lib-dynload/_crypt.cpython-312-darwin.so +0 -0
  637. package/python/lib/python3.12/lib-dynload/_dbm.cpython-312-darwin.so +0 -0
  638. package/python/lib/python3.12/linecache.py +185 -0
  639. package/python/lib/python3.12/locale.py +1779 -0
  640. package/python/lib/python3.12/logging/__init__.py +2345 -0
  641. package/python/lib/python3.12/logging/config.py +1078 -0
  642. package/python/lib/python3.12/logging/handlers.py +1624 -0
  643. package/python/lib/python3.12/lzma.py +356 -0
  644. package/python/lib/python3.12/mailbox.py +2153 -0
  645. package/python/lib/python3.12/mailcap.py +302 -0
  646. package/python/lib/python3.12/mimetypes.py +656 -0
  647. package/python/lib/python3.12/modulefinder.py +666 -0
  648. package/python/lib/python3.12/multiprocessing/__init__.py +37 -0
  649. package/python/lib/python3.12/multiprocessing/connection.py +1178 -0
  650. package/python/lib/python3.12/multiprocessing/context.py +377 -0
  651. package/python/lib/python3.12/multiprocessing/dummy/__init__.py +126 -0
  652. package/python/lib/python3.12/multiprocessing/dummy/connection.py +75 -0
  653. package/python/lib/python3.12/multiprocessing/forkserver.py +350 -0
  654. package/python/lib/python3.12/multiprocessing/heap.py +337 -0
  655. package/python/lib/python3.12/multiprocessing/managers.py +1387 -0
  656. package/python/lib/python3.12/multiprocessing/pool.py +957 -0
  657. package/python/lib/python3.12/multiprocessing/popen_fork.py +83 -0
  658. package/python/lib/python3.12/multiprocessing/popen_forkserver.py +74 -0
  659. package/python/lib/python3.12/multiprocessing/popen_spawn_posix.py +72 -0
  660. package/python/lib/python3.12/multiprocessing/popen_spawn_win32.py +145 -0
  661. package/python/lib/python3.12/multiprocessing/process.py +439 -0
  662. package/python/lib/python3.12/multiprocessing/queues.py +401 -0
  663. package/python/lib/python3.12/multiprocessing/reduction.py +281 -0
  664. package/python/lib/python3.12/multiprocessing/resource_sharer.py +154 -0
  665. package/python/lib/python3.12/multiprocessing/resource_tracker.py +294 -0
  666. package/python/lib/python3.12/multiprocessing/shared_memory.py +534 -0
  667. package/python/lib/python3.12/multiprocessing/sharedctypes.py +240 -0
  668. package/python/lib/python3.12/multiprocessing/spawn.py +307 -0
  669. package/python/lib/python3.12/multiprocessing/synchronize.py +404 -0
  670. package/python/lib/python3.12/multiprocessing/util.py +494 -0
  671. package/python/lib/python3.12/netrc.py +192 -0
  672. package/python/lib/python3.12/nntplib.py +1093 -0
  673. package/python/lib/python3.12/ntpath.py +869 -0
  674. package/python/lib/python3.12/nturl2path.py +69 -0
  675. package/python/lib/python3.12/numbers.py +418 -0
  676. package/python/lib/python3.12/opcode.py +493 -0
  677. package/python/lib/python3.12/operator.py +467 -0
  678. package/python/lib/python3.12/optparse.py +1681 -0
  679. package/python/lib/python3.12/os.py +1159 -0
  680. package/python/lib/python3.12/pathlib.py +1435 -0
  681. package/python/lib/python3.12/pdb.py +1987 -0
  682. package/python/lib/python3.12/pickle.py +1866 -0
  683. package/python/lib/python3.12/pickletools.py +2904 -0
  684. package/python/lib/python3.12/pipes.py +250 -0
  685. package/python/lib/python3.12/pkgutil.py +529 -0
  686. package/python/lib/python3.12/platform.py +1359 -0
  687. package/python/lib/python3.12/plistlib.py +920 -0
  688. package/python/lib/python3.12/poplib.py +478 -0
  689. package/python/lib/python3.12/posixpath.py +577 -0
  690. package/python/lib/python3.12/pprint.py +658 -0
  691. package/python/lib/python3.12/profile.py +615 -0
  692. package/python/lib/python3.12/pstats.py +778 -0
  693. package/python/lib/python3.12/pty.py +211 -0
  694. package/python/lib/python3.12/py_compile.py +212 -0
  695. package/python/lib/python3.12/pyclbr.py +314 -0
  696. package/python/lib/python3.12/pydoc.py +2950 -0
  697. package/python/lib/python3.12/pydoc_data/__init__.py +0 -0
  698. package/python/lib/python3.12/pydoc_data/_pydoc.css +112 -0
  699. package/python/lib/python3.12/pydoc_data/topics.py +12500 -0
  700. package/python/lib/python3.12/queue.py +326 -0
  701. package/python/lib/python3.12/quopri.py +237 -0
  702. package/python/lib/python3.12/random.py +996 -0
  703. package/python/lib/python3.12/re/__init__.py +385 -0
  704. package/python/lib/python3.12/re/__pycache__/__init__.cpython-312.pyc +0 -0
  705. package/python/lib/python3.12/re/__pycache__/_casefix.cpython-312.pyc +0 -0
  706. package/python/lib/python3.12/re/__pycache__/_compiler.cpython-312.pyc +0 -0
  707. package/python/lib/python3.12/re/__pycache__/_constants.cpython-312.pyc +0 -0
  708. package/python/lib/python3.12/re/__pycache__/_parser.cpython-312.pyc +0 -0
  709. package/python/lib/python3.12/re/_casefix.py +106 -0
  710. package/python/lib/python3.12/re/_compiler.py +770 -0
  711. package/python/lib/python3.12/re/_constants.py +220 -0
  712. package/python/lib/python3.12/re/_parser.py +1080 -0
  713. package/python/lib/python3.12/reprlib.py +214 -0
  714. package/python/lib/python3.12/rlcompleter.py +219 -0
  715. package/python/lib/python3.12/runpy.py +319 -0
  716. package/python/lib/python3.12/sched.py +167 -0
  717. package/python/lib/python3.12/secrets.py +71 -0
  718. package/python/lib/python3.12/selectors.py +623 -0
  719. package/python/lib/python3.12/shelve.py +243 -0
  720. package/python/lib/python3.12/shlex.py +345 -0
  721. package/python/lib/python3.12/shutil.py +1566 -0
  722. package/python/lib/python3.12/signal.py +94 -0
  723. package/python/lib/python3.12/site-packages/README.txt +2 -0
  724. package/python/lib/python3.12/site-packages/pip/__init__.py +13 -0
  725. package/python/lib/python3.12/site-packages/pip/__main__.py +24 -0
  726. package/python/lib/python3.12/site-packages/pip/__pip-runner__.py +50 -0
  727. package/python/lib/python3.12/site-packages/pip/_internal/__init__.py +18 -0
  728. package/python/lib/python3.12/site-packages/pip/_internal/build_env.py +606 -0
  729. package/python/lib/python3.12/site-packages/pip/_internal/cache.py +291 -0
  730. package/python/lib/python3.12/site-packages/pip/_internal/cli/__init__.py +3 -0
  731. package/python/lib/python3.12/site-packages/pip/_internal/cli/autocompletion.py +184 -0
  732. package/python/lib/python3.12/site-packages/pip/_internal/cli/base_command.py +264 -0
  733. package/python/lib/python3.12/site-packages/pip/_internal/cli/cmdoptions.py +1298 -0
  734. package/python/lib/python3.12/site-packages/pip/_internal/cli/command_context.py +28 -0
  735. package/python/lib/python3.12/site-packages/pip/_internal/cli/index_command.py +212 -0
  736. package/python/lib/python3.12/site-packages/pip/_internal/cli/main.py +85 -0
  737. package/python/lib/python3.12/site-packages/pip/_internal/cli/main_parser.py +136 -0
  738. package/python/lib/python3.12/site-packages/pip/_internal/cli/parser.py +358 -0
  739. package/python/lib/python3.12/site-packages/pip/_internal/cli/progress_bars.py +153 -0
  740. package/python/lib/python3.12/site-packages/pip/_internal/cli/req_command.py +472 -0
  741. package/python/lib/python3.12/site-packages/pip/_internal/cli/spinners.py +235 -0
  742. package/python/lib/python3.12/site-packages/pip/_internal/cli/status_codes.py +6 -0
  743. package/python/lib/python3.12/site-packages/pip/_internal/commands/__init__.py +139 -0
  744. package/python/lib/python3.12/site-packages/pip/_internal/commands/cache.py +255 -0
  745. package/python/lib/python3.12/site-packages/pip/_internal/commands/check.py +66 -0
  746. package/python/lib/python3.12/site-packages/pip/_internal/commands/completion.py +136 -0
  747. package/python/lib/python3.12/site-packages/pip/_internal/commands/configuration.py +288 -0
  748. package/python/lib/python3.12/site-packages/pip/_internal/commands/debug.py +196 -0
  749. package/python/lib/python3.12/site-packages/pip/_internal/commands/download.py +146 -0
  750. package/python/lib/python3.12/site-packages/pip/_internal/commands/freeze.py +107 -0
  751. package/python/lib/python3.12/site-packages/pip/_internal/commands/hash.py +58 -0
  752. package/python/lib/python3.12/site-packages/pip/_internal/commands/help.py +40 -0
  753. package/python/lib/python3.12/site-packages/pip/_internal/commands/index.py +166 -0
  754. package/python/lib/python3.12/site-packages/pip/_internal/commands/inspect.py +92 -0
  755. package/python/lib/python3.12/site-packages/pip/_internal/commands/install.py +904 -0
  756. package/python/lib/python3.12/site-packages/pip/_internal/commands/list.py +403 -0
  757. package/python/lib/python3.12/site-packages/pip/_internal/commands/lock.py +175 -0
  758. package/python/lib/python3.12/site-packages/pip/_internal/commands/search.py +178 -0
  759. package/python/lib/python3.12/site-packages/pip/_internal/commands/show.py +231 -0
  760. package/python/lib/python3.12/site-packages/pip/_internal/commands/uninstall.py +113 -0
  761. package/python/lib/python3.12/site-packages/pip/_internal/commands/wheel.py +171 -0
  762. package/python/lib/python3.12/site-packages/pip/_internal/configuration.py +396 -0
  763. package/python/lib/python3.12/site-packages/pip/_internal/distributions/__init__.py +21 -0
  764. package/python/lib/python3.12/site-packages/pip/_internal/distributions/base.py +55 -0
  765. package/python/lib/python3.12/site-packages/pip/_internal/distributions/installed.py +33 -0
  766. package/python/lib/python3.12/site-packages/pip/_internal/distributions/sdist.py +164 -0
  767. package/python/lib/python3.12/site-packages/pip/_internal/distributions/wheel.py +44 -0
  768. package/python/lib/python3.12/site-packages/pip/_internal/exceptions.py +971 -0
  769. package/python/lib/python3.12/site-packages/pip/_internal/index/__init__.py +1 -0
  770. package/python/lib/python3.12/site-packages/pip/_internal/index/collector.py +488 -0
  771. package/python/lib/python3.12/site-packages/pip/_internal/index/package_finder.py +1113 -0
  772. package/python/lib/python3.12/site-packages/pip/_internal/index/sources.py +287 -0
  773. package/python/lib/python3.12/site-packages/pip/_internal/locations/__init__.py +438 -0
  774. package/python/lib/python3.12/site-packages/pip/_internal/locations/_distutils.py +173 -0
  775. package/python/lib/python3.12/site-packages/pip/_internal/locations/_sysconfig.py +218 -0
  776. package/python/lib/python3.12/site-packages/pip/_internal/locations/base.py +82 -0
  777. package/python/lib/python3.12/site-packages/pip/_internal/main.py +12 -0
  778. package/python/lib/python3.12/site-packages/pip/_internal/metadata/__init__.py +169 -0
  779. package/python/lib/python3.12/site-packages/pip/_internal/metadata/_json.py +87 -0
  780. package/python/lib/python3.12/site-packages/pip/_internal/metadata/base.py +685 -0
  781. package/python/lib/python3.12/site-packages/pip/_internal/metadata/importlib/__init__.py +6 -0
  782. package/python/lib/python3.12/site-packages/pip/_internal/metadata/importlib/_compat.py +87 -0
  783. package/python/lib/python3.12/site-packages/pip/_internal/metadata/importlib/_dists.py +235 -0
  784. package/python/lib/python3.12/site-packages/pip/_internal/metadata/importlib/_envs.py +143 -0
  785. package/python/lib/python3.12/site-packages/pip/_internal/metadata/pkg_resources.py +298 -0
  786. package/python/lib/python3.12/site-packages/pip/_internal/models/__init__.py +1 -0
  787. package/python/lib/python3.12/site-packages/pip/_internal/models/candidate.py +23 -0
  788. package/python/lib/python3.12/site-packages/pip/_internal/models/direct_url.py +42 -0
  789. package/python/lib/python3.12/site-packages/pip/_internal/models/format_control.py +78 -0
  790. package/python/lib/python3.12/site-packages/pip/_internal/models/index.py +28 -0
  791. package/python/lib/python3.12/site-packages/pip/_internal/models/installation_report.py +57 -0
  792. package/python/lib/python3.12/site-packages/pip/_internal/models/link.py +617 -0
  793. package/python/lib/python3.12/site-packages/pip/_internal/models/release_control.py +91 -0
  794. package/python/lib/python3.12/site-packages/pip/_internal/models/scheme.py +23 -0
  795. package/python/lib/python3.12/site-packages/pip/_internal/models/search_scope.py +124 -0
  796. package/python/lib/python3.12/site-packages/pip/_internal/models/selection_prefs.py +36 -0
  797. package/python/lib/python3.12/site-packages/pip/_internal/models/target_python.py +122 -0
  798. package/python/lib/python3.12/site-packages/pip/_internal/models/wheel.py +80 -0
  799. package/python/lib/python3.12/site-packages/pip/_internal/network/__init__.py +1 -0
  800. package/python/lib/python3.12/site-packages/pip/_internal/network/auth.py +570 -0
  801. package/python/lib/python3.12/site-packages/pip/_internal/network/cache.py +128 -0
  802. package/python/lib/python3.12/site-packages/pip/_internal/network/download.py +340 -0
  803. package/python/lib/python3.12/site-packages/pip/_internal/network/lazy_wheel.py +215 -0
  804. package/python/lib/python3.12/site-packages/pip/_internal/network/session.py +537 -0
  805. package/python/lib/python3.12/site-packages/pip/_internal/network/utils.py +98 -0
  806. package/python/lib/python3.12/site-packages/pip/_internal/network/xmlrpc.py +61 -0
  807. package/python/lib/python3.12/site-packages/pip/_internal/operations/__init__.py +0 -0
  808. package/python/lib/python3.12/site-packages/pip/_internal/operations/build/__init__.py +0 -0
  809. package/python/lib/python3.12/site-packages/pip/_internal/operations/build/build_tracker.py +140 -0
  810. package/python/lib/python3.12/site-packages/pip/_internal/operations/build/metadata.py +38 -0
  811. package/python/lib/python3.12/site-packages/pip/_internal/operations/build/metadata_editable.py +41 -0
  812. package/python/lib/python3.12/site-packages/pip/_internal/operations/build/wheel.py +38 -0
  813. package/python/lib/python3.12/site-packages/pip/_internal/operations/build/wheel_editable.py +47 -0
  814. package/python/lib/python3.12/site-packages/pip/_internal/operations/check.py +175 -0
  815. package/python/lib/python3.12/site-packages/pip/_internal/operations/freeze.py +259 -0
  816. package/python/lib/python3.12/site-packages/pip/_internal/operations/install/__init__.py +1 -0
  817. package/python/lib/python3.12/site-packages/pip/_internal/operations/install/wheel.py +759 -0
  818. package/python/lib/python3.12/site-packages/pip/_internal/operations/prepare.py +751 -0
  819. package/python/lib/python3.12/site-packages/pip/_internal/pyproject.py +123 -0
  820. package/python/lib/python3.12/site-packages/pip/_internal/req/__init__.py +103 -0
  821. package/python/lib/python3.12/site-packages/pip/_internal/req/constructors.py +677 -0
  822. package/python/lib/python3.12/site-packages/pip/_internal/req/pep723.py +41 -0
  823. package/python/lib/python3.12/site-packages/pip/_internal/req/req_dependency_group.py +86 -0
  824. package/python/lib/python3.12/site-packages/pip/_internal/req/req_file.py +622 -0
  825. package/python/lib/python3.12/site-packages/pip/_internal/req/req_install.py +838 -0
  826. package/python/lib/python3.12/site-packages/pip/_internal/req/req_set.py +81 -0
  827. package/python/lib/python3.12/site-packages/pip/_internal/req/req_uninstall.py +639 -0
  828. package/python/lib/python3.12/site-packages/pip/_internal/resolution/__init__.py +0 -0
  829. package/python/lib/python3.12/site-packages/pip/_internal/resolution/base.py +20 -0
  830. package/python/lib/python3.12/site-packages/pip/_internal/resolution/legacy/__init__.py +0 -0
  831. package/python/lib/python3.12/site-packages/pip/_internal/resolution/legacy/resolver.py +598 -0
  832. package/python/lib/python3.12/site-packages/pip/_internal/resolution/resolvelib/__init__.py +0 -0
  833. package/python/lib/python3.12/site-packages/pip/_internal/resolution/resolvelib/base.py +164 -0
  834. package/python/lib/python3.12/site-packages/pip/_internal/resolution/resolvelib/candidates.py +599 -0
  835. package/python/lib/python3.12/site-packages/pip/_internal/resolution/resolvelib/factory.py +914 -0
  836. package/python/lib/python3.12/site-packages/pip/_internal/resolution/resolvelib/found_candidates.py +166 -0
  837. package/python/lib/python3.12/site-packages/pip/_internal/resolution/resolvelib/provider.py +306 -0
  838. package/python/lib/python3.12/site-packages/pip/_internal/resolution/resolvelib/reporter.py +98 -0
  839. package/python/lib/python3.12/site-packages/pip/_internal/resolution/resolvelib/requirements.py +251 -0
  840. package/python/lib/python3.12/site-packages/pip/_internal/resolution/resolvelib/resolver.py +332 -0
  841. package/python/lib/python3.12/site-packages/pip/_internal/self_outdated_check.py +246 -0
  842. package/python/lib/python3.12/site-packages/pip/_internal/utils/__init__.py +0 -0
  843. package/python/lib/python3.12/site-packages/pip/_internal/utils/_jaraco_text.py +109 -0
  844. package/python/lib/python3.12/site-packages/pip/_internal/utils/_log.py +38 -0
  845. package/python/lib/python3.12/site-packages/pip/_internal/utils/appdirs.py +52 -0
  846. package/python/lib/python3.12/site-packages/pip/_internal/utils/compat.py +85 -0
  847. package/python/lib/python3.12/site-packages/pip/_internal/utils/compatibility_tags.py +201 -0
  848. package/python/lib/python3.12/site-packages/pip/_internal/utils/datetime.py +28 -0
  849. package/python/lib/python3.12/site-packages/pip/_internal/utils/deprecation.py +139 -0
  850. package/python/lib/python3.12/site-packages/pip/_internal/utils/direct_url_helpers.py +92 -0
  851. package/python/lib/python3.12/site-packages/pip/_internal/utils/egg_link.py +81 -0
  852. package/python/lib/python3.12/site-packages/pip/_internal/utils/entrypoints.py +88 -0
  853. package/python/lib/python3.12/site-packages/pip/_internal/utils/filesystem.py +201 -0
  854. package/python/lib/python3.12/site-packages/pip/_internal/utils/filetypes.py +24 -0
  855. package/python/lib/python3.12/site-packages/pip/_internal/utils/glibc.py +102 -0
  856. package/python/lib/python3.12/site-packages/pip/_internal/utils/hashes.py +150 -0
  857. package/python/lib/python3.12/site-packages/pip/_internal/utils/logging.py +396 -0
  858. package/python/lib/python3.12/site-packages/pip/_internal/utils/misc.py +771 -0
  859. package/python/lib/python3.12/site-packages/pip/_internal/utils/packaging.py +44 -0
  860. package/python/lib/python3.12/site-packages/pip/_internal/utils/pylock.py +283 -0
  861. package/python/lib/python3.12/site-packages/pip/_internal/utils/retry.py +45 -0
  862. package/python/lib/python3.12/site-packages/pip/_internal/utils/subprocess.py +248 -0
  863. package/python/lib/python3.12/site-packages/pip/_internal/utils/temp_dir.py +294 -0
  864. package/python/lib/python3.12/site-packages/pip/_internal/utils/unpacking.py +381 -0
  865. package/python/lib/python3.12/site-packages/pip/_internal/utils/urls.py +55 -0
  866. package/python/lib/python3.12/site-packages/pip/_internal/utils/virtualenv.py +105 -0
  867. package/python/lib/python3.12/site-packages/pip/_internal/utils/wheel.py +132 -0
  868. package/python/lib/python3.12/site-packages/pip/_internal/vcs/__init__.py +15 -0
  869. package/python/lib/python3.12/site-packages/pip/_internal/vcs/bazaar.py +130 -0
  870. package/python/lib/python3.12/site-packages/pip/_internal/vcs/git.py +571 -0
  871. package/python/lib/python3.12/site-packages/pip/_internal/vcs/mercurial.py +186 -0
  872. package/python/lib/python3.12/site-packages/pip/_internal/vcs/subversion.py +335 -0
  873. package/python/lib/python3.12/site-packages/pip/_internal/vcs/versioncontrol.py +695 -0
  874. package/python/lib/python3.12/site-packages/pip/_internal/wheel_builder.py +261 -0
  875. package/python/lib/python3.12/site-packages/pip/_vendor/README.rst +178 -0
  876. package/python/lib/python3.12/site-packages/pip/_vendor/__init__.py +117 -0
  877. package/python/lib/python3.12/site-packages/pip/_vendor/cachecontrol/LICENSE.txt +13 -0
  878. package/python/lib/python3.12/site-packages/pip/_vendor/cachecontrol/__init__.py +32 -0
  879. package/python/lib/python3.12/site-packages/pip/_vendor/cachecontrol/_cmd.py +70 -0
  880. package/python/lib/python3.12/site-packages/pip/_vendor/cachecontrol/adapter.py +167 -0
  881. package/python/lib/python3.12/site-packages/pip/_vendor/cachecontrol/cache.py +75 -0
  882. package/python/lib/python3.12/site-packages/pip/_vendor/cachecontrol/caches/__init__.py +8 -0
  883. package/python/lib/python3.12/site-packages/pip/_vendor/cachecontrol/caches/file_cache.py +145 -0
  884. package/python/lib/python3.12/site-packages/pip/_vendor/cachecontrol/caches/redis_cache.py +48 -0
  885. package/python/lib/python3.12/site-packages/pip/_vendor/cachecontrol/controller.py +511 -0
  886. package/python/lib/python3.12/site-packages/pip/_vendor/cachecontrol/filewrapper.py +121 -0
  887. package/python/lib/python3.12/site-packages/pip/_vendor/cachecontrol/heuristics.py +157 -0
  888. package/python/lib/python3.12/site-packages/pip/_vendor/cachecontrol/py.typed +0 -0
  889. package/python/lib/python3.12/site-packages/pip/_vendor/cachecontrol/serialize.py +146 -0
  890. package/python/lib/python3.12/site-packages/pip/_vendor/cachecontrol/wrapper.py +43 -0
  891. package/python/lib/python3.12/site-packages/pip/_vendor/certifi/LICENSE +20 -0
  892. package/python/lib/python3.12/site-packages/pip/_vendor/certifi/__init__.py +4 -0
  893. package/python/lib/python3.12/site-packages/pip/_vendor/certifi/__main__.py +12 -0
  894. package/python/lib/python3.12/site-packages/pip/_vendor/certifi/cacert.pem +4494 -0
  895. package/python/lib/python3.12/site-packages/pip/_vendor/certifi/core.py +83 -0
  896. package/python/lib/python3.12/site-packages/pip/_vendor/certifi/py.typed +0 -0
  897. package/python/lib/python3.12/site-packages/pip/_vendor/distlib/LICENSE.txt +284 -0
  898. package/python/lib/python3.12/site-packages/pip/_vendor/distlib/__init__.py +33 -0
  899. package/python/lib/python3.12/site-packages/pip/_vendor/distlib/compat.py +1137 -0
  900. package/python/lib/python3.12/site-packages/pip/_vendor/distlib/resources.py +358 -0
  901. package/python/lib/python3.12/site-packages/pip/_vendor/distlib/scripts.py +447 -0
  902. package/python/lib/python3.12/site-packages/pip/_vendor/distlib/t32.exe +0 -0
  903. package/python/lib/python3.12/site-packages/pip/_vendor/distlib/t64-arm.exe +0 -0
  904. package/python/lib/python3.12/site-packages/pip/_vendor/distlib/t64.exe +0 -0
  905. package/python/lib/python3.12/site-packages/pip/_vendor/distlib/util.py +1984 -0
  906. package/python/lib/python3.12/site-packages/pip/_vendor/distlib/w32.exe +0 -0
  907. package/python/lib/python3.12/site-packages/pip/_vendor/distlib/w64-arm.exe +0 -0
  908. package/python/lib/python3.12/site-packages/pip/_vendor/distlib/w64.exe +0 -0
  909. package/python/lib/python3.12/site-packages/pip/_vendor/distro/LICENSE +202 -0
  910. package/python/lib/python3.12/site-packages/pip/_vendor/distro/__init__.py +54 -0
  911. package/python/lib/python3.12/site-packages/pip/_vendor/distro/__main__.py +4 -0
  912. package/python/lib/python3.12/site-packages/pip/_vendor/distro/distro.py +1403 -0
  913. package/python/lib/python3.12/site-packages/pip/_vendor/distro/py.typed +0 -0
  914. package/python/lib/python3.12/site-packages/pip/_vendor/idna/LICENSE.md +31 -0
  915. package/python/lib/python3.12/site-packages/pip/_vendor/idna/__init__.py +45 -0
  916. package/python/lib/python3.12/site-packages/pip/_vendor/idna/codec.py +122 -0
  917. package/python/lib/python3.12/site-packages/pip/_vendor/idna/compat.py +15 -0
  918. package/python/lib/python3.12/site-packages/pip/_vendor/idna/core.py +437 -0
  919. package/python/lib/python3.12/site-packages/pip/_vendor/idna/idnadata.py +4309 -0
  920. package/python/lib/python3.12/site-packages/pip/_vendor/idna/intranges.py +57 -0
  921. package/python/lib/python3.12/site-packages/pip/_vendor/idna/package_data.py +1 -0
  922. package/python/lib/python3.12/site-packages/pip/_vendor/idna/py.typed +0 -0
  923. package/python/lib/python3.12/site-packages/pip/_vendor/idna/uts46data.py +8841 -0
  924. package/python/lib/python3.12/site-packages/pip/_vendor/msgpack/COPYING +14 -0
  925. package/python/lib/python3.12/site-packages/pip/_vendor/msgpack/__init__.py +55 -0
  926. package/python/lib/python3.12/site-packages/pip/_vendor/msgpack/exceptions.py +48 -0
  927. package/python/lib/python3.12/site-packages/pip/_vendor/msgpack/ext.py +170 -0
  928. package/python/lib/python3.12/site-packages/pip/_vendor/msgpack/fallback.py +929 -0
  929. package/python/lib/python3.12/site-packages/pip/_vendor/packaging/LICENSE +3 -0
  930. package/python/lib/python3.12/site-packages/pip/_vendor/packaging/LICENSE.APACHE +177 -0
  931. package/python/lib/python3.12/site-packages/pip/_vendor/packaging/LICENSE.BSD +23 -0
  932. package/python/lib/python3.12/site-packages/pip/_vendor/packaging/__init__.py +15 -0
  933. package/python/lib/python3.12/site-packages/pip/_vendor/packaging/_elffile.py +108 -0
  934. package/python/lib/python3.12/site-packages/pip/_vendor/packaging/_manylinux.py +262 -0
  935. package/python/lib/python3.12/site-packages/pip/_vendor/packaging/_musllinux.py +85 -0
  936. package/python/lib/python3.12/site-packages/pip/_vendor/packaging/_parser.py +393 -0
  937. package/python/lib/python3.12/site-packages/pip/_vendor/packaging/_structures.py +33 -0
  938. package/python/lib/python3.12/site-packages/pip/_vendor/packaging/_tokenizer.py +193 -0
  939. package/python/lib/python3.12/site-packages/pip/_vendor/packaging/dependency_groups.py +302 -0
  940. package/python/lib/python3.12/site-packages/pip/_vendor/packaging/direct_url.py +325 -0
  941. package/python/lib/python3.12/site-packages/pip/_vendor/packaging/errors.py +94 -0
  942. package/python/lib/python3.12/site-packages/pip/_vendor/packaging/licenses/__init__.py +186 -0
  943. package/python/lib/python3.12/site-packages/pip/_vendor/packaging/licenses/_spdx.py +799 -0
  944. package/python/lib/python3.12/site-packages/pip/_vendor/packaging/markers.py +492 -0
  945. package/python/lib/python3.12/site-packages/pip/_vendor/packaging/metadata.py +964 -0
  946. package/python/lib/python3.12/site-packages/pip/_vendor/packaging/py.typed +0 -0
  947. package/python/lib/python3.12/site-packages/pip/_vendor/packaging/pylock.py +905 -0
  948. package/python/lib/python3.12/site-packages/pip/_vendor/packaging/requirements.py +129 -0
  949. package/python/lib/python3.12/site-packages/pip/_vendor/packaging/specifiers.py +1943 -0
  950. package/python/lib/python3.12/site-packages/pip/_vendor/packaging/tags.py +932 -0
  951. package/python/lib/python3.12/site-packages/pip/_vendor/packaging/utils.py +296 -0
  952. package/python/lib/python3.12/site-packages/pip/_vendor/packaging/version.py +1231 -0
  953. package/python/lib/python3.12/site-packages/pip/_vendor/pkg_resources/LICENSE +17 -0
  954. package/python/lib/python3.12/site-packages/pip/_vendor/pkg_resources/__init__.py +3676 -0
  955. package/python/lib/python3.12/site-packages/pip/_vendor/platformdirs/LICENSE +21 -0
  956. package/python/lib/python3.12/site-packages/pip/_vendor/platformdirs/__init__.py +631 -0
  957. package/python/lib/python3.12/site-packages/pip/_vendor/platformdirs/__main__.py +55 -0
  958. package/python/lib/python3.12/site-packages/pip/_vendor/platformdirs/android.py +249 -0
  959. package/python/lib/python3.12/site-packages/pip/_vendor/platformdirs/api.py +299 -0
  960. package/python/lib/python3.12/site-packages/pip/_vendor/platformdirs/macos.py +146 -0
  961. package/python/lib/python3.12/site-packages/pip/_vendor/platformdirs/py.typed +0 -0
  962. package/python/lib/python3.12/site-packages/pip/_vendor/platformdirs/unix.py +272 -0
  963. package/python/lib/python3.12/site-packages/pip/_vendor/platformdirs/version.py +34 -0
  964. package/python/lib/python3.12/site-packages/pip/_vendor/platformdirs/windows.py +278 -0
  965. package/python/lib/python3.12/site-packages/pip/_vendor/pygments/LICENSE +25 -0
  966. package/python/lib/python3.12/site-packages/pip/_vendor/pygments/__init__.py +82 -0
  967. package/python/lib/python3.12/site-packages/pip/_vendor/pygments/__main__.py +17 -0
  968. package/python/lib/python3.12/site-packages/pip/_vendor/pygments/console.py +70 -0
  969. package/python/lib/python3.12/site-packages/pip/_vendor/pygments/filter.py +70 -0
  970. package/python/lib/python3.12/site-packages/pip/_vendor/pygments/filters/__init__.py +940 -0
  971. package/python/lib/python3.12/site-packages/pip/_vendor/pygments/formatter.py +129 -0
  972. package/python/lib/python3.12/site-packages/pip/_vendor/pygments/formatters/__init__.py +157 -0
  973. package/python/lib/python3.12/site-packages/pip/_vendor/pygments/formatters/_mapping.py +23 -0
  974. package/python/lib/python3.12/site-packages/pip/_vendor/pygments/lexer.py +963 -0
  975. package/python/lib/python3.12/site-packages/pip/_vendor/pygments/lexers/__init__.py +362 -0
  976. package/python/lib/python3.12/site-packages/pip/_vendor/pygments/lexers/_mapping.py +602 -0
  977. package/python/lib/python3.12/site-packages/pip/_vendor/pygments/lexers/python.py +1201 -0
  978. package/python/lib/python3.12/site-packages/pip/_vendor/pygments/modeline.py +43 -0
  979. package/python/lib/python3.12/site-packages/pip/_vendor/pygments/plugin.py +72 -0
  980. package/python/lib/python3.12/site-packages/pip/_vendor/pygments/regexopt.py +91 -0
  981. package/python/lib/python3.12/site-packages/pip/_vendor/pygments/scanner.py +104 -0
  982. package/python/lib/python3.12/site-packages/pip/_vendor/pygments/sphinxext.py +247 -0
  983. package/python/lib/python3.12/site-packages/pip/_vendor/pygments/style.py +203 -0
  984. package/python/lib/python3.12/site-packages/pip/_vendor/pygments/styles/__init__.py +61 -0
  985. package/python/lib/python3.12/site-packages/pip/_vendor/pygments/styles/_mapping.py +54 -0
  986. package/python/lib/python3.12/site-packages/pip/_vendor/pygments/token.py +214 -0
  987. package/python/lib/python3.12/site-packages/pip/_vendor/pygments/unistring.py +153 -0
  988. package/python/lib/python3.12/site-packages/pip/_vendor/pygments/util.py +324 -0
  989. package/python/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/LICENSE +21 -0
  990. package/python/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/__init__.py +31 -0
  991. package/python/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_impl.py +410 -0
  992. package/python/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/__init__.py +21 -0
  993. package/python/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py +389 -0
  994. package/python/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/py.typed +0 -0
  995. package/python/lib/python3.12/site-packages/pip/_vendor/requests/LICENSE +175 -0
  996. package/python/lib/python3.12/site-packages/pip/_vendor/requests/__init__.py +178 -0
  997. package/python/lib/python3.12/site-packages/pip/_vendor/requests/__version__.py +14 -0
  998. package/python/lib/python3.12/site-packages/pip/_vendor/requests/_internal_utils.py +51 -0
  999. package/python/lib/python3.12/site-packages/pip/_vendor/requests/adapters.py +697 -0
  1000. package/python/lib/python3.12/site-packages/pip/_vendor/requests/api.py +157 -0
  1001. package/python/lib/python3.12/site-packages/pip/_vendor/requests/auth.py +314 -0
  1002. package/python/lib/python3.12/site-packages/pip/_vendor/requests/certs.py +18 -0
  1003. package/python/lib/python3.12/site-packages/pip/_vendor/requests/compat.py +90 -0
  1004. package/python/lib/python3.12/site-packages/pip/_vendor/requests/cookies.py +561 -0
  1005. package/python/lib/python3.12/site-packages/pip/_vendor/requests/exceptions.py +152 -0
  1006. package/python/lib/python3.12/site-packages/pip/_vendor/requests/help.py +124 -0
  1007. package/python/lib/python3.12/site-packages/pip/_vendor/requests/hooks.py +34 -0
  1008. package/python/lib/python3.12/site-packages/pip/_vendor/requests/models.py +1041 -0
  1009. package/python/lib/python3.12/site-packages/pip/_vendor/requests/packages.py +25 -0
  1010. package/python/lib/python3.12/site-packages/pip/_vendor/requests/sessions.py +834 -0
  1011. package/python/lib/python3.12/site-packages/pip/_vendor/requests/status_codes.py +128 -0
  1012. package/python/lib/python3.12/site-packages/pip/_vendor/requests/structures.py +99 -0
  1013. package/python/lib/python3.12/site-packages/pip/_vendor/requests/utils.py +1083 -0
  1014. package/python/lib/python3.12/site-packages/pip/_vendor/resolvelib/LICENSE +13 -0
  1015. package/python/lib/python3.12/site-packages/pip/_vendor/resolvelib/__init__.py +27 -0
  1016. package/python/lib/python3.12/site-packages/pip/_vendor/resolvelib/providers.py +196 -0
  1017. package/python/lib/python3.12/site-packages/pip/_vendor/resolvelib/py.typed +0 -0
  1018. package/python/lib/python3.12/site-packages/pip/_vendor/resolvelib/reporters.py +55 -0
  1019. package/python/lib/python3.12/site-packages/pip/_vendor/resolvelib/resolvers/__init__.py +27 -0
  1020. package/python/lib/python3.12/site-packages/pip/_vendor/resolvelib/resolvers/abstract.py +47 -0
  1021. package/python/lib/python3.12/site-packages/pip/_vendor/resolvelib/resolvers/criterion.py +48 -0
  1022. package/python/lib/python3.12/site-packages/pip/_vendor/resolvelib/resolvers/exceptions.py +57 -0
  1023. package/python/lib/python3.12/site-packages/pip/_vendor/resolvelib/resolvers/resolution.py +627 -0
  1024. package/python/lib/python3.12/site-packages/pip/_vendor/resolvelib/structs.py +209 -0
  1025. package/python/lib/python3.12/site-packages/pip/_vendor/rich/LICENSE +19 -0
  1026. package/python/lib/python3.12/site-packages/pip/_vendor/rich/__init__.py +177 -0
  1027. package/python/lib/python3.12/site-packages/pip/_vendor/rich/__main__.py +245 -0
  1028. package/python/lib/python3.12/site-packages/pip/_vendor/rich/_cell_widths.py +454 -0
  1029. package/python/lib/python3.12/site-packages/pip/_vendor/rich/_emoji_codes.py +3610 -0
  1030. package/python/lib/python3.12/site-packages/pip/_vendor/rich/_emoji_replace.py +32 -0
  1031. package/python/lib/python3.12/site-packages/pip/_vendor/rich/_export_format.py +76 -0
  1032. package/python/lib/python3.12/site-packages/pip/_vendor/rich/_extension.py +10 -0
  1033. package/python/lib/python3.12/site-packages/pip/_vendor/rich/_fileno.py +24 -0
  1034. package/python/lib/python3.12/site-packages/pip/_vendor/rich/_inspect.py +268 -0
  1035. package/python/lib/python3.12/site-packages/pip/_vendor/rich/_log_render.py +94 -0
  1036. package/python/lib/python3.12/site-packages/pip/_vendor/rich/_loop.py +43 -0
  1037. package/python/lib/python3.12/site-packages/pip/_vendor/rich/_null_file.py +69 -0
  1038. package/python/lib/python3.12/site-packages/pip/_vendor/rich/_palettes.py +309 -0
  1039. package/python/lib/python3.12/site-packages/pip/_vendor/rich/_pick.py +17 -0
  1040. package/python/lib/python3.12/site-packages/pip/_vendor/rich/_ratio.py +153 -0
  1041. package/python/lib/python3.12/site-packages/pip/_vendor/rich/_spinners.py +482 -0
  1042. package/python/lib/python3.12/site-packages/pip/_vendor/rich/_stack.py +16 -0
  1043. package/python/lib/python3.12/site-packages/pip/_vendor/rich/_timer.py +19 -0
  1044. package/python/lib/python3.12/site-packages/pip/_vendor/rich/_win32_console.py +661 -0
  1045. package/python/lib/python3.12/site-packages/pip/_vendor/rich/_windows.py +71 -0
  1046. package/python/lib/python3.12/site-packages/pip/_vendor/rich/_windows_renderer.py +56 -0
  1047. package/python/lib/python3.12/site-packages/pip/_vendor/rich/_wrap.py +93 -0
  1048. package/python/lib/python3.12/site-packages/pip/_vendor/rich/abc.py +33 -0
  1049. package/python/lib/python3.12/site-packages/pip/_vendor/rich/align.py +306 -0
  1050. package/python/lib/python3.12/site-packages/pip/_vendor/rich/ansi.py +241 -0
  1051. package/python/lib/python3.12/site-packages/pip/_vendor/rich/bar.py +93 -0
  1052. package/python/lib/python3.12/site-packages/pip/_vendor/rich/box.py +474 -0
  1053. package/python/lib/python3.12/site-packages/pip/_vendor/rich/cells.py +174 -0
  1054. package/python/lib/python3.12/site-packages/pip/_vendor/rich/color.py +621 -0
  1055. package/python/lib/python3.12/site-packages/pip/_vendor/rich/color_triplet.py +38 -0
  1056. package/python/lib/python3.12/site-packages/pip/_vendor/rich/columns.py +187 -0
  1057. package/python/lib/python3.12/site-packages/pip/_vendor/rich/console.py +2680 -0
  1058. package/python/lib/python3.12/site-packages/pip/_vendor/rich/constrain.py +37 -0
  1059. package/python/lib/python3.12/site-packages/pip/_vendor/rich/containers.py +167 -0
  1060. package/python/lib/python3.12/site-packages/pip/_vendor/rich/control.py +219 -0
  1061. package/python/lib/python3.12/site-packages/pip/_vendor/rich/default_styles.py +193 -0
  1062. package/python/lib/python3.12/site-packages/pip/_vendor/rich/diagnose.py +39 -0
  1063. package/python/lib/python3.12/site-packages/pip/_vendor/rich/emoji.py +91 -0
  1064. package/python/lib/python3.12/site-packages/pip/_vendor/rich/errors.py +34 -0
  1065. package/python/lib/python3.12/site-packages/pip/_vendor/rich/file_proxy.py +57 -0
  1066. package/python/lib/python3.12/site-packages/pip/_vendor/rich/filesize.py +88 -0
  1067. package/python/lib/python3.12/site-packages/pip/_vendor/rich/highlighter.py +232 -0
  1068. package/python/lib/python3.12/site-packages/pip/_vendor/rich/json.py +139 -0
  1069. package/python/lib/python3.12/site-packages/pip/_vendor/rich/jupyter.py +101 -0
  1070. package/python/lib/python3.12/site-packages/pip/_vendor/rich/layout.py +442 -0
  1071. package/python/lib/python3.12/site-packages/pip/_vendor/rich/live.py +400 -0
  1072. package/python/lib/python3.12/site-packages/pip/_vendor/rich/live_render.py +106 -0
  1073. package/python/lib/python3.12/site-packages/pip/_vendor/rich/logging.py +297 -0
  1074. package/python/lib/python3.12/site-packages/pip/_vendor/rich/markup.py +251 -0
  1075. package/python/lib/python3.12/site-packages/pip/_vendor/rich/measure.py +151 -0
  1076. package/python/lib/python3.12/site-packages/pip/_vendor/rich/padding.py +141 -0
  1077. package/python/lib/python3.12/site-packages/pip/_vendor/rich/pager.py +34 -0
  1078. package/python/lib/python3.12/site-packages/pip/_vendor/rich/palette.py +100 -0
  1079. package/python/lib/python3.12/site-packages/pip/_vendor/rich/panel.py +317 -0
  1080. package/python/lib/python3.12/site-packages/pip/_vendor/rich/pretty.py +1016 -0
  1081. package/python/lib/python3.12/site-packages/pip/_vendor/rich/progress.py +1715 -0
  1082. package/python/lib/python3.12/site-packages/pip/_vendor/rich/progress_bar.py +223 -0
  1083. package/python/lib/python3.12/site-packages/pip/_vendor/rich/prompt.py +400 -0
  1084. package/python/lib/python3.12/site-packages/pip/_vendor/rich/protocol.py +42 -0
  1085. package/python/lib/python3.12/site-packages/pip/_vendor/rich/py.typed +0 -0
  1086. package/python/lib/python3.12/site-packages/pip/_vendor/rich/region.py +10 -0
  1087. package/python/lib/python3.12/site-packages/pip/_vendor/rich/repr.py +149 -0
  1088. package/python/lib/python3.12/site-packages/pip/_vendor/rich/rule.py +130 -0
  1089. package/python/lib/python3.12/site-packages/pip/_vendor/rich/scope.py +86 -0
  1090. package/python/lib/python3.12/site-packages/pip/_vendor/rich/screen.py +54 -0
  1091. package/python/lib/python3.12/site-packages/pip/_vendor/rich/segment.py +752 -0
  1092. package/python/lib/python3.12/site-packages/pip/_vendor/rich/spinner.py +132 -0
  1093. package/python/lib/python3.12/site-packages/pip/_vendor/rich/status.py +131 -0
  1094. package/python/lib/python3.12/site-packages/pip/_vendor/rich/style.py +792 -0
  1095. package/python/lib/python3.12/site-packages/pip/_vendor/rich/styled.py +42 -0
  1096. package/python/lib/python3.12/site-packages/pip/_vendor/rich/syntax.py +985 -0
  1097. package/python/lib/python3.12/site-packages/pip/_vendor/rich/table.py +1006 -0
  1098. package/python/lib/python3.12/site-packages/pip/_vendor/rich/terminal_theme.py +153 -0
  1099. package/python/lib/python3.12/site-packages/pip/_vendor/rich/text.py +1361 -0
  1100. package/python/lib/python3.12/site-packages/pip/_vendor/rich/theme.py +115 -0
  1101. package/python/lib/python3.12/site-packages/pip/_vendor/rich/themes.py +5 -0
  1102. package/python/lib/python3.12/site-packages/pip/_vendor/rich/traceback.py +899 -0
  1103. package/python/lib/python3.12/site-packages/pip/_vendor/rich/tree.py +257 -0
  1104. package/python/lib/python3.12/site-packages/pip/_vendor/tomli/LICENSE +21 -0
  1105. package/python/lib/python3.12/site-packages/pip/_vendor/tomli/__init__.py +8 -0
  1106. package/python/lib/python3.12/site-packages/pip/_vendor/tomli/_parser.py +788 -0
  1107. package/python/lib/python3.12/site-packages/pip/_vendor/tomli/_re.py +115 -0
  1108. package/python/lib/python3.12/site-packages/pip/_vendor/tomli/_types.py +10 -0
  1109. package/python/lib/python3.12/site-packages/pip/_vendor/tomli/py.typed +1 -0
  1110. package/python/lib/python3.12/site-packages/pip/_vendor/tomli_w/LICENSE +21 -0
  1111. package/python/lib/python3.12/site-packages/pip/_vendor/tomli_w/__init__.py +4 -0
  1112. package/python/lib/python3.12/site-packages/pip/_vendor/tomli_w/_writer.py +229 -0
  1113. package/python/lib/python3.12/site-packages/pip/_vendor/tomli_w/py.typed +1 -0
  1114. package/python/lib/python3.12/site-packages/pip/_vendor/truststore/LICENSE +21 -0
  1115. package/python/lib/python3.12/site-packages/pip/_vendor/truststore/__init__.py +36 -0
  1116. package/python/lib/python3.12/site-packages/pip/_vendor/truststore/_api.py +341 -0
  1117. package/python/lib/python3.12/site-packages/pip/_vendor/truststore/_macos.py +571 -0
  1118. package/python/lib/python3.12/site-packages/pip/_vendor/truststore/_openssl.py +68 -0
  1119. package/python/lib/python3.12/site-packages/pip/_vendor/truststore/_ssl_constants.py +31 -0
  1120. package/python/lib/python3.12/site-packages/pip/_vendor/truststore/_windows.py +567 -0
  1121. package/python/lib/python3.12/site-packages/pip/_vendor/truststore/py.typed +0 -0
  1122. package/python/lib/python3.12/site-packages/pip/_vendor/urllib3/LICENSE.txt +21 -0
  1123. package/python/lib/python3.12/site-packages/pip/_vendor/urllib3/__init__.py +211 -0
  1124. package/python/lib/python3.12/site-packages/pip/_vendor/urllib3/_base_connection.py +165 -0
  1125. package/python/lib/python3.12/site-packages/pip/_vendor/urllib3/_collections.py +487 -0
  1126. package/python/lib/python3.12/site-packages/pip/_vendor/urllib3/_request_methods.py +278 -0
  1127. package/python/lib/python3.12/site-packages/pip/_vendor/urllib3/_version.py +34 -0
  1128. package/python/lib/python3.12/site-packages/pip/_vendor/urllib3/connection.py +1099 -0
  1129. package/python/lib/python3.12/site-packages/pip/_vendor/urllib3/connectionpool.py +1178 -0
  1130. package/python/lib/python3.12/site-packages/pip/_vendor/urllib3/contrib/__init__.py +0 -0
  1131. package/python/lib/python3.12/site-packages/pip/_vendor/urllib3/contrib/emscripten/__init__.py +17 -0
  1132. package/python/lib/python3.12/site-packages/pip/_vendor/urllib3/contrib/emscripten/connection.py +260 -0
  1133. package/python/lib/python3.12/site-packages/pip/_vendor/urllib3/contrib/emscripten/emscripten_fetch_worker.js +110 -0
  1134. package/python/lib/python3.12/site-packages/pip/_vendor/urllib3/contrib/emscripten/fetch.py +726 -0
  1135. package/python/lib/python3.12/site-packages/pip/_vendor/urllib3/contrib/emscripten/request.py +22 -0
  1136. package/python/lib/python3.12/site-packages/pip/_vendor/urllib3/contrib/emscripten/response.py +277 -0
  1137. package/python/lib/python3.12/site-packages/pip/_vendor/urllib3/contrib/pyopenssl.py +564 -0
  1138. package/python/lib/python3.12/site-packages/pip/_vendor/urllib3/contrib/socks.py +228 -0
  1139. package/python/lib/python3.12/site-packages/pip/_vendor/urllib3/exceptions.py +335 -0
  1140. package/python/lib/python3.12/site-packages/pip/_vendor/urllib3/fields.py +341 -0
  1141. package/python/lib/python3.12/site-packages/pip/_vendor/urllib3/filepost.py +89 -0
  1142. package/python/lib/python3.12/site-packages/pip/_vendor/urllib3/http2/__init__.py +53 -0
  1143. package/python/lib/python3.12/site-packages/pip/_vendor/urllib3/http2/connection.py +356 -0
  1144. package/python/lib/python3.12/site-packages/pip/_vendor/urllib3/http2/probe.py +87 -0
  1145. package/python/lib/python3.12/site-packages/pip/_vendor/urllib3/poolmanager.py +651 -0
  1146. package/python/lib/python3.12/site-packages/pip/_vendor/urllib3/py.typed +2 -0
  1147. package/python/lib/python3.12/site-packages/pip/_vendor/urllib3/response.py +1474 -0
  1148. package/python/lib/python3.12/site-packages/pip/_vendor/urllib3/util/__init__.py +42 -0
  1149. package/python/lib/python3.12/site-packages/pip/_vendor/urllib3/util/connection.py +137 -0
  1150. package/python/lib/python3.12/site-packages/pip/_vendor/urllib3/util/proxy.py +43 -0
  1151. package/python/lib/python3.12/site-packages/pip/_vendor/urllib3/util/request.py +254 -0
  1152. package/python/lib/python3.12/site-packages/pip/_vendor/urllib3/util/response.py +101 -0
  1153. package/python/lib/python3.12/site-packages/pip/_vendor/urllib3/util/retry.py +549 -0
  1154. package/python/lib/python3.12/site-packages/pip/_vendor/urllib3/util/ssl_.py +527 -0
  1155. package/python/lib/python3.12/site-packages/pip/_vendor/urllib3/util/ssl_match_hostname.py +159 -0
  1156. package/python/lib/python3.12/site-packages/pip/_vendor/urllib3/util/ssltransport.py +271 -0
  1157. package/python/lib/python3.12/site-packages/pip/_vendor/urllib3/util/timeout.py +275 -0
  1158. package/python/lib/python3.12/site-packages/pip/_vendor/urllib3/util/url.py +469 -0
  1159. package/python/lib/python3.12/site-packages/pip/_vendor/urllib3/util/util.py +42 -0
  1160. package/python/lib/python3.12/site-packages/pip/_vendor/urllib3/util/wait.py +124 -0
  1161. package/python/lib/python3.12/site-packages/pip/_vendor/vendor.txt +18 -0
  1162. package/python/lib/python3.12/site-packages/pip/py.typed +4 -0
  1163. package/python/lib/python3.12/site-packages/pip-26.1.2.dist-info/INSTALLER +1 -0
  1164. package/python/lib/python3.12/site-packages/pip-26.1.2.dist-info/METADATA +109 -0
  1165. package/python/lib/python3.12/site-packages/pip-26.1.2.dist-info/RECORD +866 -0
  1166. package/python/lib/python3.12/site-packages/pip-26.1.2.dist-info/REQUESTED +0 -0
  1167. package/python/lib/python3.12/site-packages/pip-26.1.2.dist-info/WHEEL +4 -0
  1168. package/python/lib/python3.12/site-packages/pip-26.1.2.dist-info/direct_url.json +1 -0
  1169. package/python/lib/python3.12/site-packages/pip-26.1.2.dist-info/entry_points.txt +4 -0
  1170. package/python/lib/python3.12/site-packages/pip-26.1.2.dist-info/licenses/AUTHORS.txt +868 -0
  1171. package/python/lib/python3.12/site-packages/pip-26.1.2.dist-info/licenses/LICENSE.txt +20 -0
  1172. package/python/lib/python3.12/site-packages/pip-26.1.2.dist-info/licenses/src/pip/_vendor/cachecontrol/LICENSE.txt +13 -0
  1173. package/python/lib/python3.12/site-packages/pip-26.1.2.dist-info/licenses/src/pip/_vendor/certifi/LICENSE +20 -0
  1174. package/python/lib/python3.12/site-packages/pip-26.1.2.dist-info/licenses/src/pip/_vendor/distlib/LICENSE.txt +284 -0
  1175. package/python/lib/python3.12/site-packages/pip-26.1.2.dist-info/licenses/src/pip/_vendor/distro/LICENSE +202 -0
  1176. package/python/lib/python3.12/site-packages/pip-26.1.2.dist-info/licenses/src/pip/_vendor/idna/LICENSE.md +31 -0
  1177. package/python/lib/python3.12/site-packages/pip-26.1.2.dist-info/licenses/src/pip/_vendor/msgpack/COPYING +14 -0
  1178. package/python/lib/python3.12/site-packages/pip-26.1.2.dist-info/licenses/src/pip/_vendor/packaging/LICENSE +3 -0
  1179. package/python/lib/python3.12/site-packages/pip-26.1.2.dist-info/licenses/src/pip/_vendor/packaging/LICENSE.APACHE +177 -0
  1180. package/python/lib/python3.12/site-packages/pip-26.1.2.dist-info/licenses/src/pip/_vendor/packaging/LICENSE.BSD +23 -0
  1181. package/python/lib/python3.12/site-packages/pip-26.1.2.dist-info/licenses/src/pip/_vendor/pkg_resources/LICENSE +17 -0
  1182. package/python/lib/python3.12/site-packages/pip-26.1.2.dist-info/licenses/src/pip/_vendor/platformdirs/LICENSE +21 -0
  1183. package/python/lib/python3.12/site-packages/pip-26.1.2.dist-info/licenses/src/pip/_vendor/pygments/LICENSE +25 -0
  1184. package/python/lib/python3.12/site-packages/pip-26.1.2.dist-info/licenses/src/pip/_vendor/pyproject_hooks/LICENSE +21 -0
  1185. package/python/lib/python3.12/site-packages/pip-26.1.2.dist-info/licenses/src/pip/_vendor/requests/LICENSE +175 -0
  1186. package/python/lib/python3.12/site-packages/pip-26.1.2.dist-info/licenses/src/pip/_vendor/resolvelib/LICENSE +13 -0
  1187. package/python/lib/python3.12/site-packages/pip-26.1.2.dist-info/licenses/src/pip/_vendor/rich/LICENSE +19 -0
  1188. package/python/lib/python3.12/site-packages/pip-26.1.2.dist-info/licenses/src/pip/_vendor/tomli/LICENSE +21 -0
  1189. package/python/lib/python3.12/site-packages/pip-26.1.2.dist-info/licenses/src/pip/_vendor/tomli_w/LICENSE +21 -0
  1190. package/python/lib/python3.12/site-packages/pip-26.1.2.dist-info/licenses/src/pip/_vendor/truststore/LICENSE +21 -0
  1191. package/python/lib/python3.12/site-packages/pip-26.1.2.dist-info/licenses/src/pip/_vendor/urllib3/LICENSE.txt +21 -0
  1192. package/python/lib/python3.12/site.py +693 -0
  1193. package/python/lib/python3.12/smtplib.py +1109 -0
  1194. package/python/lib/python3.12/sndhdr.py +271 -0
  1195. package/python/lib/python3.12/socket.py +983 -0
  1196. package/python/lib/python3.12/socketserver.py +863 -0
  1197. package/python/lib/python3.12/sqlite3/__init__.py +70 -0
  1198. package/python/lib/python3.12/sqlite3/__main__.py +127 -0
  1199. package/python/lib/python3.12/sqlite3/__pycache__/__init__.cpython-312.pyc +0 -0
  1200. package/python/lib/python3.12/sqlite3/__pycache__/dbapi2.cpython-312.pyc +0 -0
  1201. package/python/lib/python3.12/sqlite3/dbapi2.py +108 -0
  1202. package/python/lib/python3.12/sqlite3/dump.py +89 -0
  1203. package/python/lib/python3.12/sre_compile.py +7 -0
  1204. package/python/lib/python3.12/sre_constants.py +7 -0
  1205. package/python/lib/python3.12/sre_parse.py +7 -0
  1206. package/python/lib/python3.12/ssl.py +1488 -0
  1207. package/python/lib/python3.12/stat.py +195 -0
  1208. package/python/lib/python3.12/statistics.py +1454 -0
  1209. package/python/lib/python3.12/string.py +309 -0
  1210. package/python/lib/python3.12/stringprep.py +272 -0
  1211. package/python/lib/python3.12/struct.py +15 -0
  1212. package/python/lib/python3.12/subprocess.py +2216 -0
  1213. package/python/lib/python3.12/sunau.py +533 -0
  1214. package/python/lib/python3.12/symtable.py +362 -0
  1215. package/python/lib/python3.12/sysconfig.py +894 -0
  1216. package/python/lib/python3.12/tabnanny.py +340 -0
  1217. package/python/lib/python3.12/tarfile.py +3031 -0
  1218. package/python/lib/python3.12/telnetlib.py +680 -0
  1219. package/python/lib/python3.12/tempfile.py +956 -0
  1220. package/python/lib/python3.12/textwrap.py +491 -0
  1221. package/python/lib/python3.12/this.py +28 -0
  1222. package/python/lib/python3.12/threading.py +1708 -0
  1223. package/python/lib/python3.12/timeit.py +381 -0
  1224. package/python/lib/python3.12/token.py +143 -0
  1225. package/python/lib/python3.12/tokenize.py +594 -0
  1226. package/python/lib/python3.12/tomllib/__init__.py +10 -0
  1227. package/python/lib/python3.12/tomllib/_parser.py +691 -0
  1228. package/python/lib/python3.12/tomllib/_re.py +107 -0
  1229. package/python/lib/python3.12/tomllib/_types.py +10 -0
  1230. package/python/lib/python3.12/trace.py +748 -0
  1231. package/python/lib/python3.12/traceback.py +1187 -0
  1232. package/python/lib/python3.12/tracemalloc.py +560 -0
  1233. package/python/lib/python3.12/tty.py +73 -0
  1234. package/python/lib/python3.12/turtle.py +4207 -0
  1235. package/python/lib/python3.12/types.py +333 -0
  1236. package/python/lib/python3.12/typing.py +3494 -0
  1237. package/python/lib/python3.12/unittest/__init__.py +85 -0
  1238. package/python/lib/python3.12/unittest/__main__.py +18 -0
  1239. package/python/lib/python3.12/unittest/_log.py +86 -0
  1240. package/python/lib/python3.12/unittest/async_case.py +143 -0
  1241. package/python/lib/python3.12/unittest/case.py +1456 -0
  1242. package/python/lib/python3.12/unittest/loader.py +497 -0
  1243. package/python/lib/python3.12/unittest/main.py +291 -0
  1244. package/python/lib/python3.12/unittest/mock.py +3054 -0
  1245. package/python/lib/python3.12/unittest/result.py +256 -0
  1246. package/python/lib/python3.12/unittest/runner.py +292 -0
  1247. package/python/lib/python3.12/unittest/signals.py +71 -0
  1248. package/python/lib/python3.12/unittest/suite.py +379 -0
  1249. package/python/lib/python3.12/unittest/util.py +170 -0
  1250. package/python/lib/python3.12/urllib/__init__.py +0 -0
  1251. package/python/lib/python3.12/urllib/__pycache__/__init__.cpython-312.pyc +0 -0
  1252. package/python/lib/python3.12/urllib/__pycache__/error.cpython-312.pyc +0 -0
  1253. package/python/lib/python3.12/urllib/__pycache__/parse.cpython-312.pyc +0 -0
  1254. package/python/lib/python3.12/urllib/__pycache__/request.cpython-312.pyc +0 -0
  1255. package/python/lib/python3.12/urllib/__pycache__/response.cpython-312.pyc +0 -0
  1256. package/python/lib/python3.12/urllib/error.py +74 -0
  1257. package/python/lib/python3.12/urllib/parse.py +1262 -0
  1258. package/python/lib/python3.12/urllib/request.py +2816 -0
  1259. package/python/lib/python3.12/urllib/response.py +84 -0
  1260. package/python/lib/python3.12/urllib/robotparser.py +275 -0
  1261. package/python/lib/python3.12/uu.py +216 -0
  1262. package/python/lib/python3.12/uuid.py +793 -0
  1263. package/python/lib/python3.12/venv/__init__.py +608 -0
  1264. package/python/lib/python3.12/venv/__main__.py +10 -0
  1265. package/python/lib/python3.12/venv/scripts/common/Activate.ps1 +247 -0
  1266. package/python/lib/python3.12/venv/scripts/common/activate +76 -0
  1267. package/python/lib/python3.12/venv/scripts/posix/activate.csh +27 -0
  1268. package/python/lib/python3.12/venv/scripts/posix/activate.fish +69 -0
  1269. package/python/lib/python3.12/warnings.py +598 -0
  1270. package/python/lib/python3.12/wave.py +653 -0
  1271. package/python/lib/python3.12/weakref.py +674 -0
  1272. package/python/lib/python3.12/webbrowser.py +689 -0
  1273. package/python/lib/python3.12/wsgiref/__init__.py +25 -0
  1274. package/python/lib/python3.12/wsgiref/handlers.py +573 -0
  1275. package/python/lib/python3.12/wsgiref/headers.py +192 -0
  1276. package/python/lib/python3.12/wsgiref/simple_server.py +165 -0
  1277. package/python/lib/python3.12/wsgiref/types.py +54 -0
  1278. package/python/lib/python3.12/wsgiref/util.py +159 -0
  1279. package/python/lib/python3.12/wsgiref/validate.py +438 -0
  1280. package/python/lib/python3.12/xdrlib.py +242 -0
  1281. package/python/lib/python3.12/xml/__init__.py +20 -0
  1282. package/python/lib/python3.12/xml/__pycache__/__init__.cpython-312.pyc +0 -0
  1283. package/python/lib/python3.12/xml/dom/NodeFilter.py +27 -0
  1284. package/python/lib/python3.12/xml/dom/__init__.py +140 -0
  1285. package/python/lib/python3.12/xml/dom/domreg.py +99 -0
  1286. package/python/lib/python3.12/xml/dom/expatbuilder.py +962 -0
  1287. package/python/lib/python3.12/xml/dom/minicompat.py +109 -0
  1288. package/python/lib/python3.12/xml/dom/minidom.py +2008 -0
  1289. package/python/lib/python3.12/xml/dom/pulldom.py +336 -0
  1290. package/python/lib/python3.12/xml/dom/xmlbuilder.py +389 -0
  1291. package/python/lib/python3.12/xml/etree/ElementInclude.py +186 -0
  1292. package/python/lib/python3.12/xml/etree/ElementPath.py +423 -0
  1293. package/python/lib/python3.12/xml/etree/ElementTree.py +2085 -0
  1294. package/python/lib/python3.12/xml/etree/__init__.py +33 -0
  1295. package/python/lib/python3.12/xml/etree/cElementTree.py +3 -0
  1296. package/python/lib/python3.12/xml/parsers/__init__.py +8 -0
  1297. package/python/lib/python3.12/xml/parsers/__pycache__/__init__.cpython-312.pyc +0 -0
  1298. package/python/lib/python3.12/xml/parsers/__pycache__/expat.cpython-312.pyc +0 -0
  1299. package/python/lib/python3.12/xml/parsers/expat.py +8 -0
  1300. package/python/lib/python3.12/xml/sax/__init__.py +94 -0
  1301. package/python/lib/python3.12/xml/sax/_exceptions.py +127 -0
  1302. package/python/lib/python3.12/xml/sax/expatreader.py +454 -0
  1303. package/python/lib/python3.12/xml/sax/handler.py +387 -0
  1304. package/python/lib/python3.12/xml/sax/saxutils.py +369 -0
  1305. package/python/lib/python3.12/xml/sax/xmlreader.py +378 -0
  1306. package/python/lib/python3.12/xmlrpc/__init__.py +1 -0
  1307. package/python/lib/python3.12/xmlrpc/client.py +1529 -0
  1308. package/python/lib/python3.12/xmlrpc/server.py +1002 -0
  1309. package/python/lib/python3.12/zipapp.py +206 -0
  1310. package/python/lib/python3.12/zipfile/__init__.py +2340 -0
  1311. package/python/lib/python3.12/zipfile/__main__.py +4 -0
  1312. package/python/lib/python3.12/zipfile/_path/__init__.py +412 -0
  1313. package/python/lib/python3.12/zipfile/_path/glob.py +53 -0
  1314. package/python/lib/python3.12/zipimport.py +712 -0
  1315. package/python/lib/python3.12/zoneinfo/__init__.py +31 -0
  1316. package/python/lib/python3.12/zoneinfo/_common.py +164 -0
  1317. package/python/lib/python3.12/zoneinfo/_tzpath.py +181 -0
  1318. package/python/lib/python3.12/zoneinfo/_zoneinfo.py +772 -0
@@ -0,0 +1,3108 @@
1
+ """Header value parser implementing various email-related RFC parsing rules.
2
+
3
+ The parsing methods defined in this module implement various email related
4
+ parsing rules. Principal among them is RFC 5322, which is the followon
5
+ to RFC 2822 and primarily a clarification of the former. It also implements
6
+ RFC 2047 encoded word decoding.
7
+
8
+ RFC 5322 goes to considerable trouble to maintain backward compatibility with
9
+ RFC 822 in the parse phase, while cleaning up the structure on the generation
10
+ phase. This parser supports correct RFC 5322 generation by tagging white space
11
+ as folding white space only when folding is allowed in the non-obsolete rule
12
+ sets. Actually, the parser is even more generous when accepting input than RFC
13
+ 5322 mandates, following the spirit of Postel's Law, which RFC 5322 encourages.
14
+ Where possible deviations from the standard are annotated on the 'defects'
15
+ attribute of tokens that deviate.
16
+
17
+ The general structure of the parser follows RFC 5322, and uses its terminology
18
+ where there is a direct correspondence. Where the implementation requires a
19
+ somewhat different structure than that used by the formal grammar, new terms
20
+ that mimic the closest existing terms are used. Thus, it really helps to have
21
+ a copy of RFC 5322 handy when studying this code.
22
+
23
+ Input to the parser is a string that has already been unfolded according to
24
+ RFC 5322 rules. According to the RFC this unfolding is the very first step, and
25
+ this parser leaves the unfolding step to a higher level message parser, which
26
+ will have already detected the line breaks that need unfolding while
27
+ determining the beginning and end of each header.
28
+
29
+ The output of the parser is a TokenList object, which is a list subclass. A
30
+ TokenList is a recursive data structure. The terminal nodes of the structure
31
+ are Terminal objects, which are subclasses of str. These do not correspond
32
+ directly to terminal objects in the formal grammar, but are instead more
33
+ practical higher level combinations of true terminals.
34
+
35
+ All TokenList and Terminal objects have a 'value' attribute, which produces the
36
+ semantically meaningful value of that part of the parse subtree. The value of
37
+ all whitespace tokens (no matter how many sub-tokens they may contain) is a
38
+ single space, as per the RFC rules. This includes 'CFWS', which is herein
39
+ included in the general class of whitespace tokens. There is one exception to
40
+ the rule that whitespace tokens are collapsed into single spaces in values: in
41
+ the value of a 'bare-quoted-string' (a quoted-string with no leading or
42
+ trailing whitespace), any whitespace that appeared between the quotation marks
43
+ is preserved in the returned value. Note that in all Terminal strings quoted
44
+ pairs are turned into their unquoted values.
45
+
46
+ All TokenList and Terminal objects also have a string value, which attempts to
47
+ be a "canonical" representation of the RFC-compliant form of the substring that
48
+ produced the parsed subtree, including minimal use of quoted pair quoting.
49
+ Whitespace runs are not collapsed.
50
+
51
+ Comment tokens also have a 'content' attribute providing the string found
52
+ between the parens (including any nested comments) with whitespace preserved.
53
+
54
+ All TokenList and Terminal objects have a 'defects' attribute which is a
55
+ possibly empty list all of the defects found while creating the token. Defects
56
+ may appear on any token in the tree, and a composite list of all defects in the
57
+ subtree is available through the 'all_defects' attribute of any node. (For
58
+ Terminal notes x.defects == x.all_defects.)
59
+
60
+ Each object in a parse tree is called a 'token', and each has a 'token_type'
61
+ attribute that gives the name from the RFC 5322 grammar that it represents.
62
+ Not all RFC 5322 nodes are produced, and there is one non-RFC 5322 node that
63
+ may be produced: 'ptext'. A 'ptext' is a string of printable ascii characters.
64
+ It is returned in place of lists of (ctext/quoted-pair) and
65
+ (qtext/quoted-pair).
66
+
67
+ XXX: provide complete list of token types.
68
+ """
69
+
70
+ import re
71
+ import sys
72
+ import urllib # For urllib.parse.unquote
73
+ from string import hexdigits
74
+ from operator import itemgetter
75
+ from email import _encoded_words as _ew
76
+ from email import errors
77
+ from email import utils
78
+
79
+ #
80
+ # Useful constants and functions
81
+ #
82
+
83
+ WSP = set(' \t')
84
+ CFWS_LEADER = WSP | set('(')
85
+ SPECIALS = set(r'()<>@,:;.\"[]')
86
+ ATOM_ENDS = SPECIALS | WSP
87
+ DOT_ATOM_ENDS = ATOM_ENDS - set('.')
88
+ # '.', '"', and '(' do not end phrases in order to support obs-phrase
89
+ PHRASE_ENDS = SPECIALS - set('."(')
90
+ TSPECIALS = (SPECIALS | set('/?=')) - set('.')
91
+ TOKEN_ENDS = TSPECIALS | WSP
92
+ ASPECIALS = TSPECIALS | set("*'%")
93
+ ATTRIBUTE_ENDS = ASPECIALS | WSP
94
+ EXTENDED_ATTRIBUTE_ENDS = ATTRIBUTE_ENDS - set('%')
95
+ NLSET = {'\n', '\r'}
96
+ SPECIALSNL = SPECIALS | NLSET
97
+
98
+
99
+ def make_quoted_pairs(value):
100
+ """Escape dquote and backslash for use within a quoted-string."""
101
+ return str(value).replace('\\', '\\\\').replace('"', '\\"')
102
+
103
+
104
+ def make_parenthesis_pairs(value):
105
+ """Escape parenthesis and backslash for use within a comment."""
106
+ return str(value).replace('\\', '\\\\') \
107
+ .replace('(', '\\(').replace(')', '\\)')
108
+
109
+
110
+ def quote_string(value):
111
+ escaped = make_quoted_pairs(value)
112
+ return f'"{escaped}"'
113
+
114
+
115
+ # Match a RFC 2047 word, looks like =?utf-8?q?someword?=
116
+ rfc2047_matcher = re.compile(r'''
117
+ =\? # literal =?
118
+ [^?]* # charset
119
+ \? # literal ?
120
+ [qQbB] # literal 'q' or 'b', case insensitive
121
+ \? # literal ?
122
+ .*? # encoded word
123
+ \?= # literal ?=
124
+ ''', re.VERBOSE | re.MULTILINE)
125
+
126
+
127
+ #
128
+ # TokenList and its subclasses
129
+ #
130
+
131
+ class TokenList(list):
132
+
133
+ token_type = None
134
+ syntactic_break = True
135
+ ew_combine_allowed = True
136
+
137
+ def __init__(self, *args, **kw):
138
+ super().__init__(*args, **kw)
139
+ self.defects = []
140
+
141
+ def __str__(self):
142
+ return ''.join(str(x) for x in self)
143
+
144
+ def __repr__(self):
145
+ return '{}({})'.format(self.__class__.__name__,
146
+ super().__repr__())
147
+
148
+ @property
149
+ def value(self):
150
+ return ''.join(x.value for x in self if x.value)
151
+
152
+ @property
153
+ def all_defects(self):
154
+ return sum((x.all_defects for x in self), self.defects)
155
+
156
+ def startswith_fws(self):
157
+ return self[0].startswith_fws()
158
+
159
+ @property
160
+ def as_ew_allowed(self):
161
+ """True if all top level tokens of this part may be RFC2047 encoded."""
162
+ return all(part.as_ew_allowed for part in self)
163
+
164
+ @property
165
+ def comments(self):
166
+ comments = []
167
+ for token in self:
168
+ comments.extend(token.comments)
169
+ return comments
170
+
171
+ def fold(self, *, policy):
172
+ return _refold_parse_tree(self, policy=policy)
173
+
174
+ def pprint(self, indent=''):
175
+ print(self.ppstr(indent=indent))
176
+
177
+ def ppstr(self, indent=''):
178
+ return '\n'.join(self._pp(indent=indent))
179
+
180
+ def _pp(self, indent=''):
181
+ yield '{}{}/{}('.format(
182
+ indent,
183
+ self.__class__.__name__,
184
+ self.token_type)
185
+ for token in self:
186
+ if not hasattr(token, '_pp'):
187
+ yield (indent + ' !! invalid element in token '
188
+ 'list: {!r}'.format(token))
189
+ else:
190
+ yield from token._pp(indent+' ')
191
+ if self.defects:
192
+ extra = ' Defects: {}'.format(self.defects)
193
+ else:
194
+ extra = ''
195
+ yield '{}){}'.format(indent, extra)
196
+
197
+
198
+ class WhiteSpaceTokenList(TokenList):
199
+
200
+ @property
201
+ def value(self):
202
+ return ' '
203
+
204
+ @property
205
+ def comments(self):
206
+ return [x.content for x in self if x.token_type=='comment']
207
+
208
+
209
+ class UnstructuredTokenList(TokenList):
210
+ token_type = 'unstructured'
211
+
212
+
213
+ class Phrase(TokenList):
214
+ token_type = 'phrase'
215
+
216
+ class Word(TokenList):
217
+ token_type = 'word'
218
+
219
+
220
+ class CFWSList(WhiteSpaceTokenList):
221
+ token_type = 'cfws'
222
+
223
+
224
+ class Atom(TokenList):
225
+ token_type = 'atom'
226
+
227
+
228
+ class Token(TokenList):
229
+ token_type = 'token'
230
+ encode_as_ew = False
231
+
232
+
233
+ class EncodedWord(TokenList):
234
+ token_type = 'encoded-word'
235
+ cte = None
236
+ charset = None
237
+ lang = None
238
+
239
+
240
+ class QuotedString(TokenList):
241
+
242
+ token_type = 'quoted-string'
243
+
244
+ @property
245
+ def content(self):
246
+ for x in self:
247
+ if x.token_type == 'bare-quoted-string':
248
+ return x.value
249
+
250
+ @property
251
+ def quoted_value(self):
252
+ res = []
253
+ for x in self:
254
+ if x.token_type == 'bare-quoted-string':
255
+ res.append(str(x))
256
+ else:
257
+ res.append(x.value)
258
+ return ''.join(res)
259
+
260
+ @property
261
+ def stripped_value(self):
262
+ for token in self:
263
+ if token.token_type == 'bare-quoted-string':
264
+ return token.value
265
+
266
+
267
+ class BareQuotedString(QuotedString):
268
+
269
+ token_type = 'bare-quoted-string'
270
+
271
+ def __str__(self):
272
+ return quote_string(''.join(str(x) for x in self))
273
+
274
+ @property
275
+ def value(self):
276
+ return ''.join(str(x) for x in self)
277
+
278
+
279
+ class Comment(WhiteSpaceTokenList):
280
+
281
+ token_type = 'comment'
282
+
283
+ def __str__(self):
284
+ return ''.join(sum([
285
+ ["("],
286
+ [self.quote(x) for x in self],
287
+ [")"],
288
+ ], []))
289
+
290
+ def quote(self, value):
291
+ if value.token_type == 'comment':
292
+ return str(value)
293
+ return str(value).replace('\\', '\\\\').replace(
294
+ '(', r'\(').replace(
295
+ ')', r'\)')
296
+
297
+ @property
298
+ def content(self):
299
+ return ''.join(str(x) for x in self)
300
+
301
+ @property
302
+ def comments(self):
303
+ return [self.content]
304
+
305
+ class AddressList(TokenList):
306
+
307
+ token_type = 'address-list'
308
+
309
+ @property
310
+ def addresses(self):
311
+ return [x for x in self if x.token_type=='address']
312
+
313
+ @property
314
+ def mailboxes(self):
315
+ return sum((x.mailboxes
316
+ for x in self if x.token_type=='address'), [])
317
+
318
+ @property
319
+ def all_mailboxes(self):
320
+ return sum((x.all_mailboxes
321
+ for x in self if x.token_type=='address'), [])
322
+
323
+
324
+ class Address(TokenList):
325
+
326
+ token_type = 'address'
327
+
328
+ @property
329
+ def display_name(self):
330
+ if self[0].token_type == 'group':
331
+ return self[0].display_name
332
+
333
+ @property
334
+ def mailboxes(self):
335
+ if self[0].token_type == 'mailbox':
336
+ return [self[0]]
337
+ elif self[0].token_type == 'invalid-mailbox':
338
+ return []
339
+ return self[0].mailboxes
340
+
341
+ @property
342
+ def all_mailboxes(self):
343
+ if self[0].token_type == 'mailbox':
344
+ return [self[0]]
345
+ elif self[0].token_type == 'invalid-mailbox':
346
+ return [self[0]]
347
+ return self[0].all_mailboxes
348
+
349
+ class MailboxList(TokenList):
350
+
351
+ token_type = 'mailbox-list'
352
+
353
+ @property
354
+ def mailboxes(self):
355
+ return [x for x in self if x.token_type=='mailbox']
356
+
357
+ @property
358
+ def all_mailboxes(self):
359
+ return [x for x in self
360
+ if x.token_type in ('mailbox', 'invalid-mailbox')]
361
+
362
+
363
+ class GroupList(TokenList):
364
+
365
+ token_type = 'group-list'
366
+
367
+ @property
368
+ def mailboxes(self):
369
+ if not self or self[0].token_type != 'mailbox-list':
370
+ return []
371
+ return self[0].mailboxes
372
+
373
+ @property
374
+ def all_mailboxes(self):
375
+ if not self or self[0].token_type != 'mailbox-list':
376
+ return []
377
+ return self[0].all_mailboxes
378
+
379
+
380
+ class Group(TokenList):
381
+
382
+ token_type = "group"
383
+
384
+ @property
385
+ def mailboxes(self):
386
+ if self[2].token_type != 'group-list':
387
+ return []
388
+ return self[2].mailboxes
389
+
390
+ @property
391
+ def all_mailboxes(self):
392
+ if self[2].token_type != 'group-list':
393
+ return []
394
+ return self[2].all_mailboxes
395
+
396
+ @property
397
+ def display_name(self):
398
+ return self[0].display_name
399
+
400
+
401
+ class NameAddr(TokenList):
402
+
403
+ token_type = 'name-addr'
404
+
405
+ @property
406
+ def display_name(self):
407
+ if len(self) == 1:
408
+ return None
409
+ return self[0].display_name
410
+
411
+ @property
412
+ def local_part(self):
413
+ return self[-1].local_part
414
+
415
+ @property
416
+ def domain(self):
417
+ return self[-1].domain
418
+
419
+ @property
420
+ def route(self):
421
+ return self[-1].route
422
+
423
+ @property
424
+ def addr_spec(self):
425
+ return self[-1].addr_spec
426
+
427
+
428
+ class AngleAddr(TokenList):
429
+
430
+ token_type = 'angle-addr'
431
+
432
+ @property
433
+ def local_part(self):
434
+ for x in self:
435
+ if x.token_type == 'addr-spec':
436
+ return x.local_part
437
+
438
+ @property
439
+ def domain(self):
440
+ for x in self:
441
+ if x.token_type == 'addr-spec':
442
+ return x.domain
443
+
444
+ @property
445
+ def route(self):
446
+ for x in self:
447
+ if x.token_type == 'obs-route':
448
+ return x.domains
449
+
450
+ @property
451
+ def addr_spec(self):
452
+ for x in self:
453
+ if x.token_type == 'addr-spec':
454
+ if x.local_part:
455
+ return x.addr_spec
456
+ else:
457
+ return quote_string(x.local_part) + x.addr_spec
458
+ else:
459
+ return '<>'
460
+
461
+
462
+ class ObsRoute(TokenList):
463
+
464
+ token_type = 'obs-route'
465
+
466
+ @property
467
+ def domains(self):
468
+ return [x.domain for x in self if x.token_type == 'domain']
469
+
470
+
471
+ class Mailbox(TokenList):
472
+
473
+ token_type = 'mailbox'
474
+
475
+ @property
476
+ def display_name(self):
477
+ if self[0].token_type == 'name-addr':
478
+ return self[0].display_name
479
+
480
+ @property
481
+ def local_part(self):
482
+ return self[0].local_part
483
+
484
+ @property
485
+ def domain(self):
486
+ return self[0].domain
487
+
488
+ @property
489
+ def route(self):
490
+ if self[0].token_type == 'name-addr':
491
+ return self[0].route
492
+
493
+ @property
494
+ def addr_spec(self):
495
+ return self[0].addr_spec
496
+
497
+
498
+ class InvalidMailbox(TokenList):
499
+
500
+ token_type = 'invalid-mailbox'
501
+
502
+ @property
503
+ def display_name(self):
504
+ return None
505
+
506
+ local_part = domain = route = addr_spec = display_name
507
+
508
+
509
+ class Domain(TokenList):
510
+
511
+ token_type = 'domain'
512
+ as_ew_allowed = False
513
+
514
+ @property
515
+ def domain(self):
516
+ return ''.join(super().value.split())
517
+
518
+
519
+ class DotAtom(TokenList):
520
+ token_type = 'dot-atom'
521
+
522
+
523
+ class DotAtomText(TokenList):
524
+ token_type = 'dot-atom-text'
525
+ as_ew_allowed = True
526
+
527
+
528
+ class NoFoldLiteral(TokenList):
529
+ token_type = 'no-fold-literal'
530
+ as_ew_allowed = False
531
+
532
+
533
+ class AddrSpec(TokenList):
534
+
535
+ token_type = 'addr-spec'
536
+ as_ew_allowed = False
537
+
538
+ @property
539
+ def local_part(self):
540
+ return self[0].local_part
541
+
542
+ @property
543
+ def domain(self):
544
+ if len(self) < 3:
545
+ return None
546
+ return self[-1].domain
547
+
548
+ @property
549
+ def value(self):
550
+ if len(self) < 3:
551
+ return self[0].value
552
+ return self[0].value.rstrip()+self[1].value+self[2].value.lstrip()
553
+
554
+ @property
555
+ def addr_spec(self):
556
+ nameset = set(self.local_part)
557
+ if len(nameset) > len(nameset-DOT_ATOM_ENDS):
558
+ lp = quote_string(self.local_part)
559
+ else:
560
+ lp = self.local_part
561
+ if self.domain is not None:
562
+ return lp + '@' + self.domain
563
+ return lp
564
+
565
+
566
+ class ObsLocalPart(TokenList):
567
+
568
+ token_type = 'obs-local-part'
569
+ as_ew_allowed = False
570
+
571
+
572
+ class DisplayName(Phrase):
573
+
574
+ token_type = 'display-name'
575
+ ew_combine_allowed = False
576
+
577
+ @property
578
+ def display_name(self):
579
+ res = TokenList(self)
580
+ if len(res) == 0:
581
+ return res.value
582
+ if res[0].token_type == 'cfws':
583
+ res.pop(0)
584
+ else:
585
+ if (isinstance(res[0], TokenList) and
586
+ res[0][0].token_type == 'cfws'):
587
+ res[0] = TokenList(res[0][1:])
588
+ if res[-1].token_type == 'cfws':
589
+ res.pop()
590
+ else:
591
+ if (isinstance(res[-1], TokenList) and
592
+ res[-1][-1].token_type == 'cfws'):
593
+ res[-1] = TokenList(res[-1][:-1])
594
+ return res.value
595
+
596
+ @property
597
+ def value(self):
598
+ quote = False
599
+ if self.defects:
600
+ quote = True
601
+ else:
602
+ for x in self:
603
+ if x.token_type == 'quoted-string':
604
+ quote = True
605
+ if len(self) != 0 and quote:
606
+ pre = post = ''
607
+ if (self[0].token_type == 'cfws' or
608
+ isinstance(self[0], TokenList) and
609
+ self[0][0].token_type == 'cfws'):
610
+ pre = ' '
611
+ if (self[-1].token_type == 'cfws' or
612
+ isinstance(self[-1], TokenList) and
613
+ self[-1][-1].token_type == 'cfws'):
614
+ post = ' '
615
+ return pre+quote_string(self.display_name)+post
616
+ else:
617
+ return super().value
618
+
619
+
620
+ class LocalPart(TokenList):
621
+
622
+ token_type = 'local-part'
623
+ as_ew_allowed = False
624
+
625
+ @property
626
+ def value(self):
627
+ if self[0].token_type == "quoted-string":
628
+ return self[0].quoted_value
629
+ else:
630
+ return self[0].value
631
+
632
+ @property
633
+ def local_part(self):
634
+ # Strip whitespace from front, back, and around dots.
635
+ res = [DOT]
636
+ last = DOT
637
+ last_is_tl = False
638
+ for tok in self[0] + [DOT]:
639
+ if tok.token_type == 'cfws':
640
+ continue
641
+ if (last_is_tl and tok.token_type == 'dot' and
642
+ last[-1].token_type == 'cfws'):
643
+ res[-1] = TokenList(last[:-1])
644
+ is_tl = isinstance(tok, TokenList)
645
+ if (is_tl and last.token_type == 'dot' and
646
+ tok[0].token_type == 'cfws'):
647
+ res.append(TokenList(tok[1:]))
648
+ else:
649
+ res.append(tok)
650
+ last = res[-1]
651
+ last_is_tl = is_tl
652
+ res = TokenList(res[1:-1])
653
+ return res.value
654
+
655
+
656
+ class DomainLiteral(TokenList):
657
+
658
+ token_type = 'domain-literal'
659
+ as_ew_allowed = False
660
+
661
+ @property
662
+ def domain(self):
663
+ return ''.join(super().value.split())
664
+
665
+ @property
666
+ def ip(self):
667
+ for x in self:
668
+ if x.token_type == 'ptext':
669
+ return x.value
670
+
671
+
672
+ class MIMEVersion(TokenList):
673
+
674
+ token_type = 'mime-version'
675
+ major = None
676
+ minor = None
677
+
678
+
679
+ class Parameter(TokenList):
680
+
681
+ token_type = 'parameter'
682
+ sectioned = False
683
+ extended = False
684
+ charset = 'us-ascii'
685
+
686
+ @property
687
+ def section_number(self):
688
+ # Because the first token, the attribute (name) eats CFWS, the second
689
+ # token is always the section if there is one.
690
+ return self[1].number if self.sectioned else 0
691
+
692
+ @property
693
+ def param_value(self):
694
+ # This is part of the "handle quoted extended parameters" hack.
695
+ for token in self:
696
+ if token.token_type == 'value':
697
+ return token.stripped_value
698
+ if token.token_type == 'quoted-string':
699
+ for token in token:
700
+ if token.token_type == 'bare-quoted-string':
701
+ for token in token:
702
+ if token.token_type == 'value':
703
+ return token.stripped_value
704
+ return ''
705
+
706
+
707
+ class InvalidParameter(Parameter):
708
+
709
+ token_type = 'invalid-parameter'
710
+
711
+
712
+ class Attribute(TokenList):
713
+
714
+ token_type = 'attribute'
715
+
716
+ @property
717
+ def stripped_value(self):
718
+ for token in self:
719
+ if token.token_type.endswith('attrtext'):
720
+ return token.value
721
+
722
+ class Section(TokenList):
723
+
724
+ token_type = 'section'
725
+ number = None
726
+
727
+
728
+ class Value(TokenList):
729
+
730
+ token_type = 'value'
731
+
732
+ @property
733
+ def stripped_value(self):
734
+ token = self[0]
735
+ if token.token_type == 'cfws':
736
+ token = self[1]
737
+ if token.token_type.endswith(
738
+ ('quoted-string', 'attribute', 'extended-attribute')):
739
+ return token.stripped_value
740
+ return self.value
741
+
742
+
743
+ class MimeParameters(TokenList):
744
+
745
+ token_type = 'mime-parameters'
746
+ syntactic_break = False
747
+
748
+ @property
749
+ def params(self):
750
+ # The RFC specifically states that the ordering of parameters is not
751
+ # guaranteed and may be reordered by the transport layer. So we have
752
+ # to assume the RFC 2231 pieces can come in any order. However, we
753
+ # output them in the order that we first see a given name, which gives
754
+ # us a stable __str__.
755
+ params = {} # Using order preserving dict from Python 3.7+
756
+ for token in self:
757
+ if not token.token_type.endswith('parameter'):
758
+ continue
759
+ if token[0].token_type != 'attribute':
760
+ continue
761
+ name = token[0].value.strip()
762
+ if name not in params:
763
+ params[name] = []
764
+ params[name].append((token.section_number, token))
765
+ for name, parts in params.items():
766
+ parts = sorted(parts, key=itemgetter(0))
767
+ first_param = parts[0][1]
768
+ charset = first_param.charset
769
+ # Our arbitrary error recovery is to ignore duplicate parameters,
770
+ # to use appearance order if there are duplicate rfc 2231 parts,
771
+ # and to ignore gaps. This mimics the error recovery of get_param.
772
+ if not first_param.extended and len(parts) > 1:
773
+ if parts[1][0] == 0:
774
+ parts[1][1].defects.append(errors.InvalidHeaderDefect(
775
+ 'duplicate parameter name; duplicate(s) ignored'))
776
+ parts = parts[:1]
777
+ # Else assume the *0* was missing...note that this is different
778
+ # from get_param, but we registered a defect for this earlier.
779
+ value_parts = []
780
+ i = 0
781
+ for section_number, param in parts:
782
+ if section_number != i:
783
+ # We could get fancier here and look for a complete
784
+ # duplicate extended parameter and ignore the second one
785
+ # seen. But we're not doing that. The old code didn't.
786
+ if not param.extended:
787
+ param.defects.append(errors.InvalidHeaderDefect(
788
+ 'duplicate parameter name; duplicate ignored'))
789
+ continue
790
+ else:
791
+ param.defects.append(errors.InvalidHeaderDefect(
792
+ "inconsistent RFC2231 parameter numbering"))
793
+ i += 1
794
+ value = param.param_value
795
+ if param.extended:
796
+ try:
797
+ value = urllib.parse.unquote_to_bytes(value)
798
+ except UnicodeEncodeError:
799
+ # source had surrogate escaped bytes. What we do now
800
+ # is a bit of an open question. I'm not sure this is
801
+ # the best choice, but it is what the old algorithm did
802
+ value = urllib.parse.unquote(value, encoding='latin-1')
803
+ else:
804
+ try:
805
+ value = value.decode(charset, 'surrogateescape')
806
+ except (LookupError, UnicodeEncodeError):
807
+ # XXX: there should really be a custom defect for
808
+ # unknown character set to make it easy to find,
809
+ # because otherwise unknown charset is a silent
810
+ # failure.
811
+ value = value.decode('us-ascii', 'surrogateescape')
812
+ if utils._has_surrogates(value):
813
+ param.defects.append(errors.UndecodableBytesDefect())
814
+ value_parts.append(value)
815
+ value = ''.join(value_parts)
816
+ yield name, value
817
+
818
+ def __str__(self):
819
+ params = []
820
+ for name, value in self.params:
821
+ if value:
822
+ params.append('{}={}'.format(name, quote_string(value)))
823
+ else:
824
+ params.append(name)
825
+ params = '; '.join(params)
826
+ return ' ' + params if params else ''
827
+
828
+
829
+ class ParameterizedHeaderValue(TokenList):
830
+
831
+ # Set this false so that the value doesn't wind up on a new line even
832
+ # if it and the parameters would fit there but not on the first line.
833
+ syntactic_break = False
834
+
835
+ @property
836
+ def params(self):
837
+ for token in reversed(self):
838
+ if token.token_type == 'mime-parameters':
839
+ return token.params
840
+ return {}
841
+
842
+
843
+ class ContentType(ParameterizedHeaderValue):
844
+ token_type = 'content-type'
845
+ as_ew_allowed = False
846
+ maintype = 'text'
847
+ subtype = 'plain'
848
+
849
+
850
+ class ContentDisposition(ParameterizedHeaderValue):
851
+ token_type = 'content-disposition'
852
+ as_ew_allowed = False
853
+ content_disposition = None
854
+
855
+
856
+ class ContentTransferEncoding(TokenList):
857
+ token_type = 'content-transfer-encoding'
858
+ as_ew_allowed = False
859
+ cte = '7bit'
860
+
861
+
862
+ class HeaderLabel(TokenList):
863
+ token_type = 'header-label'
864
+ as_ew_allowed = False
865
+
866
+
867
+ class MsgID(TokenList):
868
+ token_type = 'msg-id'
869
+ as_ew_allowed = False
870
+
871
+ def fold(self, policy):
872
+ # message-id tokens may not be folded.
873
+ return str(self) + policy.linesep
874
+
875
+
876
+ class MessageID(MsgID):
877
+ token_type = 'message-id'
878
+
879
+
880
+ class InvalidMessageID(MessageID):
881
+ token_type = 'invalid-message-id'
882
+
883
+
884
+ class Header(TokenList):
885
+ token_type = 'header'
886
+
887
+
888
+ #
889
+ # Terminal classes and instances
890
+ #
891
+
892
+ class Terminal(str):
893
+
894
+ as_ew_allowed = True
895
+ ew_combine_allowed = True
896
+ syntactic_break = True
897
+
898
+ def __new__(cls, value, token_type):
899
+ self = super().__new__(cls, value)
900
+ self.token_type = token_type
901
+ self.defects = []
902
+ return self
903
+
904
+ def __repr__(self):
905
+ return "{}({})".format(self.__class__.__name__, super().__repr__())
906
+
907
+ def pprint(self):
908
+ print(self.__class__.__name__ + '/' + self.token_type)
909
+
910
+ @property
911
+ def all_defects(self):
912
+ return list(self.defects)
913
+
914
+ def _pp(self, indent=''):
915
+ return ["{}{}/{}({}){}".format(
916
+ indent,
917
+ self.__class__.__name__,
918
+ self.token_type,
919
+ super().__repr__(),
920
+ '' if not self.defects else ' {}'.format(self.defects),
921
+ )]
922
+
923
+ def pop_trailing_ws(self):
924
+ # This terminates the recursion.
925
+ return None
926
+
927
+ @property
928
+ def comments(self):
929
+ return []
930
+
931
+ def __getnewargs__(self):
932
+ return(str(self), self.token_type)
933
+
934
+
935
+ class WhiteSpaceTerminal(Terminal):
936
+
937
+ @property
938
+ def value(self):
939
+ return ' '
940
+
941
+ def startswith_fws(self):
942
+ return self and self[0] in WSP
943
+
944
+
945
+ class ValueTerminal(Terminal):
946
+
947
+ @property
948
+ def value(self):
949
+ return self
950
+
951
+ def startswith_fws(self):
952
+ return False
953
+
954
+
955
+ class EWWhiteSpaceTerminal(WhiteSpaceTerminal):
956
+
957
+ @property
958
+ def value(self):
959
+ return ''
960
+
961
+ def __str__(self):
962
+ return ''
963
+
964
+
965
+ class _InvalidEwError(errors.HeaderParseError):
966
+ """Invalid encoded word found while parsing headers."""
967
+
968
+
969
+ # XXX these need to become classes and used as instances so
970
+ # that a program can't change them in a parse tree and screw
971
+ # up other parse trees. Maybe should have tests for that, too.
972
+ DOT = ValueTerminal('.', 'dot')
973
+ ListSeparator = ValueTerminal(',', 'list-separator')
974
+ ListSeparator.as_ew_allowed = False
975
+ ListSeparator.syntactic_break = False
976
+ RouteComponentMarker = ValueTerminal('@', 'route-component-marker')
977
+
978
+ #
979
+ # Parser
980
+ #
981
+
982
+ # Parse strings according to RFC822/2047/2822/5322 rules.
983
+ #
984
+ # This is a stateless parser. Each get_XXX function accepts a string and
985
+ # returns either a Terminal or a TokenList representing the RFC object named
986
+ # by the method and a string containing the remaining unparsed characters
987
+ # from the input. Thus a parser method consumes the next syntactic construct
988
+ # of a given type and returns a token representing the construct plus the
989
+ # unparsed remainder of the input string.
990
+ #
991
+ # For example, if the first element of a structured header is a 'phrase',
992
+ # then:
993
+ #
994
+ # phrase, value = get_phrase(value)
995
+ #
996
+ # returns the complete phrase from the start of the string value, plus any
997
+ # characters left in the string after the phrase is removed.
998
+
999
+ _wsp_splitter = re.compile(r'([{}]+)'.format(''.join(WSP))).split
1000
+ _non_atom_end_matcher = re.compile(r"[^{}]+".format(
1001
+ re.escape(''.join(ATOM_ENDS)))).match
1002
+ _non_printable_finder = re.compile(r"[\x00-\x20\x7F]").findall
1003
+ _non_token_end_matcher = re.compile(r"[^{}]+".format(
1004
+ re.escape(''.join(TOKEN_ENDS)))).match
1005
+ _non_attribute_end_matcher = re.compile(r"[^{}]+".format(
1006
+ re.escape(''.join(ATTRIBUTE_ENDS)))).match
1007
+ _non_extended_attribute_end_matcher = re.compile(r"[^{}]+".format(
1008
+ re.escape(''.join(EXTENDED_ATTRIBUTE_ENDS)))).match
1009
+
1010
+ def _validate_xtext(xtext):
1011
+ """If input token contains ASCII non-printables, register a defect."""
1012
+
1013
+ non_printables = _non_printable_finder(xtext)
1014
+ if non_printables:
1015
+ xtext.defects.append(errors.NonPrintableDefect(non_printables))
1016
+ if utils._has_surrogates(xtext):
1017
+ xtext.defects.append(errors.UndecodableBytesDefect(
1018
+ "Non-ASCII characters found in header token"))
1019
+
1020
+ def _get_ptext_to_endchars(value, endchars):
1021
+ """Scan printables/quoted-pairs until endchars and return unquoted ptext.
1022
+
1023
+ This function turns a run of qcontent, ccontent-without-comments, or
1024
+ dtext-with-quoted-printables into a single string by unquoting any
1025
+ quoted printables. It returns the string, the remaining value, and
1026
+ a flag that is True iff there were any quoted printables decoded.
1027
+
1028
+ """
1029
+ fragment, *remainder = _wsp_splitter(value, 1)
1030
+ vchars = []
1031
+ escape = False
1032
+ had_qp = False
1033
+ for pos in range(len(fragment)):
1034
+ if fragment[pos] == '\\':
1035
+ if escape:
1036
+ escape = False
1037
+ had_qp = True
1038
+ else:
1039
+ escape = True
1040
+ continue
1041
+ if escape:
1042
+ escape = False
1043
+ elif fragment[pos] in endchars:
1044
+ break
1045
+ vchars.append(fragment[pos])
1046
+ else:
1047
+ pos = pos + 1
1048
+ return ''.join(vchars), ''.join([fragment[pos:]] + remainder), had_qp
1049
+
1050
+ def get_fws(value):
1051
+ """FWS = 1*WSP
1052
+
1053
+ This isn't the RFC definition. We're using fws to represent tokens where
1054
+ folding can be done, but when we are parsing the *un*folding has already
1055
+ been done so we don't need to watch out for CRLF.
1056
+
1057
+ """
1058
+ newvalue = value.lstrip()
1059
+ fws = WhiteSpaceTerminal(value[:len(value)-len(newvalue)], 'fws')
1060
+ return fws, newvalue
1061
+
1062
+ def get_encoded_word(value, terminal_type='vtext'):
1063
+ """ encoded-word = "=?" charset "?" encoding "?" encoded-text "?="
1064
+
1065
+ """
1066
+ ew = EncodedWord()
1067
+ if not value.startswith('=?'):
1068
+ raise errors.HeaderParseError(
1069
+ "expected encoded word but found {}".format(value))
1070
+ tok, *remainder = value[2:].split('?=', 1)
1071
+ if tok == value[2:]:
1072
+ raise errors.HeaderParseError(
1073
+ "expected encoded word but found {}".format(value))
1074
+ remstr = ''.join(remainder)
1075
+ if (len(remstr) > 1 and
1076
+ remstr[0] in hexdigits and
1077
+ remstr[1] in hexdigits and
1078
+ tok.count('?') < 2):
1079
+ # The ? after the CTE was followed by an encoded word escape (=XX).
1080
+ rest, *remainder = remstr.split('?=', 1)
1081
+ tok = tok + '?=' + rest
1082
+ if len(tok.split()) > 1:
1083
+ ew.defects.append(errors.InvalidHeaderDefect(
1084
+ "whitespace inside encoded word"))
1085
+ ew.cte = value
1086
+ value = ''.join(remainder)
1087
+ try:
1088
+ text, charset, lang, defects = _ew.decode('=?' + tok + '?=')
1089
+ except (ValueError, KeyError):
1090
+ raise _InvalidEwError(
1091
+ "encoded word format invalid: '{}'".format(ew.cte))
1092
+ ew.charset = charset
1093
+ ew.lang = lang
1094
+ ew.defects.extend(defects)
1095
+ while text:
1096
+ if text[0] in WSP:
1097
+ token, text = get_fws(text)
1098
+ ew.append(token)
1099
+ continue
1100
+ chars, *remainder = _wsp_splitter(text, 1)
1101
+ vtext = ValueTerminal(chars, terminal_type)
1102
+ _validate_xtext(vtext)
1103
+ ew.append(vtext)
1104
+ text = ''.join(remainder)
1105
+ # Encoded words should be followed by a WS
1106
+ if value and value[0] not in WSP:
1107
+ ew.defects.append(errors.InvalidHeaderDefect(
1108
+ "missing trailing whitespace after encoded-word"))
1109
+ return ew, value
1110
+
1111
+ def get_unstructured(value):
1112
+ """unstructured = (*([FWS] vchar) *WSP) / obs-unstruct
1113
+ obs-unstruct = *((*LF *CR *(obs-utext) *LF *CR)) / FWS)
1114
+ obs-utext = %d0 / obs-NO-WS-CTL / LF / CR
1115
+
1116
+ obs-NO-WS-CTL is control characters except WSP/CR/LF.
1117
+
1118
+ So, basically, we have printable runs, plus control characters or nulls in
1119
+ the obsolete syntax, separated by whitespace. Since RFC 2047 uses the
1120
+ obsolete syntax in its specification, but requires whitespace on either
1121
+ side of the encoded words, I can see no reason to need to separate the
1122
+ non-printable-non-whitespace from the printable runs if they occur, so we
1123
+ parse this into xtext tokens separated by WSP tokens.
1124
+
1125
+ Because an 'unstructured' value must by definition constitute the entire
1126
+ value, this 'get' routine does not return a remaining value, only the
1127
+ parsed TokenList.
1128
+
1129
+ """
1130
+ # XXX: but what about bare CR and LF? They might signal the start or
1131
+ # end of an encoded word. YAGNI for now, since our current parsers
1132
+ # will never send us strings with bare CR or LF.
1133
+
1134
+ unstructured = UnstructuredTokenList()
1135
+ while value:
1136
+ if value[0] in WSP:
1137
+ token, value = get_fws(value)
1138
+ unstructured.append(token)
1139
+ continue
1140
+ valid_ew = True
1141
+ if value.startswith('=?'):
1142
+ try:
1143
+ token, value = get_encoded_word(value, 'utext')
1144
+ except _InvalidEwError:
1145
+ valid_ew = False
1146
+ except errors.HeaderParseError:
1147
+ # XXX: Need to figure out how to register defects when
1148
+ # appropriate here.
1149
+ pass
1150
+ else:
1151
+ have_ws = True
1152
+ if len(unstructured) > 0:
1153
+ if unstructured[-1].token_type != 'fws':
1154
+ unstructured.defects.append(errors.InvalidHeaderDefect(
1155
+ "missing whitespace before encoded word"))
1156
+ have_ws = False
1157
+ if have_ws and len(unstructured) > 1:
1158
+ if unstructured[-2].token_type == 'encoded-word':
1159
+ unstructured[-1] = EWWhiteSpaceTerminal(
1160
+ unstructured[-1], 'fws')
1161
+ unstructured.append(token)
1162
+ continue
1163
+ tok, *remainder = _wsp_splitter(value, 1)
1164
+ # Split in the middle of an atom if there is a rfc2047 encoded word
1165
+ # which does not have WSP on both sides. The defect will be registered
1166
+ # the next time through the loop.
1167
+ # This needs to only be performed when the encoded word is valid;
1168
+ # otherwise, performing it on an invalid encoded word can cause
1169
+ # the parser to go in an infinite loop.
1170
+ if valid_ew and rfc2047_matcher.search(tok):
1171
+ tok, *remainder = value.partition('=?')
1172
+ vtext = ValueTerminal(tok, 'utext')
1173
+ _validate_xtext(vtext)
1174
+ unstructured.append(vtext)
1175
+ value = ''.join(remainder)
1176
+ return unstructured
1177
+
1178
+ def get_qp_ctext(value):
1179
+ r"""ctext = <printable ascii except \ ( )>
1180
+
1181
+ This is not the RFC ctext, since we are handling nested comments in comment
1182
+ and unquoting quoted-pairs here. We allow anything except the '()'
1183
+ characters, but if we find any ASCII other than the RFC defined printable
1184
+ ASCII, a NonPrintableDefect is added to the token's defects list. Since
1185
+ quoted pairs are converted to their unquoted values, what is returned is
1186
+ a 'ptext' token. In this case it is a WhiteSpaceTerminal, so it's value
1187
+ is ' '.
1188
+
1189
+ """
1190
+ ptext, value, _ = _get_ptext_to_endchars(value, '()')
1191
+ ptext = WhiteSpaceTerminal(ptext, 'ptext')
1192
+ _validate_xtext(ptext)
1193
+ return ptext, value
1194
+
1195
+ def get_qcontent(value):
1196
+ """qcontent = qtext / quoted-pair
1197
+
1198
+ We allow anything except the DQUOTE character, but if we find any ASCII
1199
+ other than the RFC defined printable ASCII, a NonPrintableDefect is
1200
+ added to the token's defects list. Any quoted pairs are converted to their
1201
+ unquoted values, so what is returned is a 'ptext' token. In this case it
1202
+ is a ValueTerminal.
1203
+
1204
+ """
1205
+ ptext, value, _ = _get_ptext_to_endchars(value, '"')
1206
+ ptext = ValueTerminal(ptext, 'ptext')
1207
+ _validate_xtext(ptext)
1208
+ return ptext, value
1209
+
1210
+ def get_atext(value):
1211
+ """atext = <matches _atext_matcher>
1212
+
1213
+ We allow any non-ATOM_ENDS in atext, but add an InvalidATextDefect to
1214
+ the token's defects list if we find non-atext characters.
1215
+ """
1216
+ m = _non_atom_end_matcher(value)
1217
+ if not m:
1218
+ raise errors.HeaderParseError(
1219
+ "expected atext but found '{}'".format(value))
1220
+ atext = m.group()
1221
+ value = value[len(atext):]
1222
+ atext = ValueTerminal(atext, 'atext')
1223
+ _validate_xtext(atext)
1224
+ return atext, value
1225
+
1226
+ def get_bare_quoted_string(value):
1227
+ """bare-quoted-string = DQUOTE *([FWS] qcontent) [FWS] DQUOTE
1228
+
1229
+ A quoted-string without the leading or trailing white space. Its
1230
+ value is the text between the quote marks, with whitespace
1231
+ preserved and quoted pairs decoded.
1232
+ """
1233
+ if not value or value[0] != '"':
1234
+ raise errors.HeaderParseError(
1235
+ "expected '\"' but found '{}'".format(value))
1236
+ bare_quoted_string = BareQuotedString()
1237
+ value = value[1:]
1238
+ if value and value[0] == '"':
1239
+ token, value = get_qcontent(value)
1240
+ bare_quoted_string.append(token)
1241
+ while value and value[0] != '"':
1242
+ if value[0] in WSP:
1243
+ token, value = get_fws(value)
1244
+ elif value[:2] == '=?':
1245
+ valid_ew = False
1246
+ try:
1247
+ token, value = get_encoded_word(value)
1248
+ bare_quoted_string.defects.append(errors.InvalidHeaderDefect(
1249
+ "encoded word inside quoted string"))
1250
+ valid_ew = True
1251
+ except errors.HeaderParseError:
1252
+ token, value = get_qcontent(value)
1253
+ # Collapse the whitespace between two encoded words that occur in a
1254
+ # bare-quoted-string.
1255
+ if valid_ew and len(bare_quoted_string) > 1:
1256
+ if (bare_quoted_string[-1].token_type == 'fws' and
1257
+ bare_quoted_string[-2].token_type == 'encoded-word'):
1258
+ bare_quoted_string[-1] = EWWhiteSpaceTerminal(
1259
+ bare_quoted_string[-1], 'fws')
1260
+ else:
1261
+ token, value = get_qcontent(value)
1262
+ bare_quoted_string.append(token)
1263
+ if not value:
1264
+ bare_quoted_string.defects.append(errors.InvalidHeaderDefect(
1265
+ "end of header inside quoted string"))
1266
+ return bare_quoted_string, value
1267
+ return bare_quoted_string, value[1:]
1268
+
1269
+ def get_comment(value):
1270
+ """comment = "(" *([FWS] ccontent) [FWS] ")"
1271
+ ccontent = ctext / quoted-pair / comment
1272
+
1273
+ We handle nested comments here, and quoted-pair in our qp-ctext routine.
1274
+ """
1275
+ if value and value[0] != '(':
1276
+ raise errors.HeaderParseError(
1277
+ "expected '(' but found '{}'".format(value))
1278
+ comment = Comment()
1279
+ value = value[1:]
1280
+ while value and value[0] != ")":
1281
+ if value[0] in WSP:
1282
+ token, value = get_fws(value)
1283
+ elif value[0] == '(':
1284
+ token, value = get_comment(value)
1285
+ else:
1286
+ token, value = get_qp_ctext(value)
1287
+ comment.append(token)
1288
+ if not value:
1289
+ comment.defects.append(errors.InvalidHeaderDefect(
1290
+ "end of header inside comment"))
1291
+ return comment, value
1292
+ return comment, value[1:]
1293
+
1294
+ def get_cfws(value):
1295
+ """CFWS = (1*([FWS] comment) [FWS]) / FWS
1296
+
1297
+ """
1298
+ cfws = CFWSList()
1299
+ while value and value[0] in CFWS_LEADER:
1300
+ if value[0] in WSP:
1301
+ token, value = get_fws(value)
1302
+ else:
1303
+ token, value = get_comment(value)
1304
+ cfws.append(token)
1305
+ return cfws, value
1306
+
1307
+ def get_quoted_string(value):
1308
+ """quoted-string = [CFWS] <bare-quoted-string> [CFWS]
1309
+
1310
+ 'bare-quoted-string' is an intermediate class defined by this
1311
+ parser and not by the RFC grammar. It is the quoted string
1312
+ without any attached CFWS.
1313
+ """
1314
+ quoted_string = QuotedString()
1315
+ if value and value[0] in CFWS_LEADER:
1316
+ token, value = get_cfws(value)
1317
+ quoted_string.append(token)
1318
+ token, value = get_bare_quoted_string(value)
1319
+ quoted_string.append(token)
1320
+ if value and value[0] in CFWS_LEADER:
1321
+ token, value = get_cfws(value)
1322
+ quoted_string.append(token)
1323
+ return quoted_string, value
1324
+
1325
+ def get_atom(value):
1326
+ """atom = [CFWS] 1*atext [CFWS]
1327
+
1328
+ An atom could be an rfc2047 encoded word.
1329
+ """
1330
+ atom = Atom()
1331
+ if value and value[0] in CFWS_LEADER:
1332
+ token, value = get_cfws(value)
1333
+ atom.append(token)
1334
+ if value and value[0] in ATOM_ENDS:
1335
+ raise errors.HeaderParseError(
1336
+ "expected atom but found '{}'".format(value))
1337
+ if value.startswith('=?'):
1338
+ try:
1339
+ token, value = get_encoded_word(value)
1340
+ except errors.HeaderParseError:
1341
+ # XXX: need to figure out how to register defects when
1342
+ # appropriate here.
1343
+ token, value = get_atext(value)
1344
+ else:
1345
+ token, value = get_atext(value)
1346
+ atom.append(token)
1347
+ if value and value[0] in CFWS_LEADER:
1348
+ token, value = get_cfws(value)
1349
+ atom.append(token)
1350
+ return atom, value
1351
+
1352
+ def get_dot_atom_text(value):
1353
+ """ dot-text = 1*atext *("." 1*atext)
1354
+
1355
+ """
1356
+ dot_atom_text = DotAtomText()
1357
+ if not value or value[0] in ATOM_ENDS:
1358
+ raise errors.HeaderParseError("expected atom at a start of "
1359
+ "dot-atom-text but found '{}'".format(value))
1360
+ while value and value[0] not in ATOM_ENDS:
1361
+ token, value = get_atext(value)
1362
+ dot_atom_text.append(token)
1363
+ if value and value[0] == '.':
1364
+ dot_atom_text.append(DOT)
1365
+ value = value[1:]
1366
+ if dot_atom_text[-1] is DOT:
1367
+ raise errors.HeaderParseError("expected atom at end of dot-atom-text "
1368
+ "but found '{}'".format('.'+value))
1369
+ return dot_atom_text, value
1370
+
1371
+ def get_dot_atom(value):
1372
+ """ dot-atom = [CFWS] dot-atom-text [CFWS]
1373
+
1374
+ Any place we can have a dot atom, we could instead have an rfc2047 encoded
1375
+ word.
1376
+ """
1377
+ dot_atom = DotAtom()
1378
+ if value[0] in CFWS_LEADER:
1379
+ token, value = get_cfws(value)
1380
+ dot_atom.append(token)
1381
+ if value.startswith('=?'):
1382
+ try:
1383
+ token, value = get_encoded_word(value)
1384
+ except errors.HeaderParseError:
1385
+ # XXX: need to figure out how to register defects when
1386
+ # appropriate here.
1387
+ token, value = get_dot_atom_text(value)
1388
+ else:
1389
+ token, value = get_dot_atom_text(value)
1390
+ dot_atom.append(token)
1391
+ if value and value[0] in CFWS_LEADER:
1392
+ token, value = get_cfws(value)
1393
+ dot_atom.append(token)
1394
+ return dot_atom, value
1395
+
1396
+ def get_word(value):
1397
+ """word = atom / quoted-string
1398
+
1399
+ Either atom or quoted-string may start with CFWS. We have to peel off this
1400
+ CFWS first to determine which type of word to parse. Afterward we splice
1401
+ the leading CFWS, if any, into the parsed sub-token.
1402
+
1403
+ If neither an atom or a quoted-string is found before the next special, a
1404
+ HeaderParseError is raised.
1405
+
1406
+ The token returned is either an Atom or a QuotedString, as appropriate.
1407
+ This means the 'word' level of the formal grammar is not represented in the
1408
+ parse tree; this is because having that extra layer when manipulating the
1409
+ parse tree is more confusing than it is helpful.
1410
+
1411
+ """
1412
+ if value[0] in CFWS_LEADER:
1413
+ leader, value = get_cfws(value)
1414
+ else:
1415
+ leader = None
1416
+ if not value:
1417
+ raise errors.HeaderParseError(
1418
+ "Expected 'atom' or 'quoted-string' but found nothing.")
1419
+ if value[0]=='"':
1420
+ token, value = get_quoted_string(value)
1421
+ elif value[0] in SPECIALS:
1422
+ raise errors.HeaderParseError("Expected 'atom' or 'quoted-string' "
1423
+ "but found '{}'".format(value))
1424
+ else:
1425
+ token, value = get_atom(value)
1426
+ if leader is not None:
1427
+ token[:0] = [leader]
1428
+ return token, value
1429
+
1430
+ def get_phrase(value):
1431
+ """ phrase = 1*word / obs-phrase
1432
+ obs-phrase = word *(word / "." / CFWS)
1433
+
1434
+ This means a phrase can be a sequence of words, periods, and CFWS in any
1435
+ order as long as it starts with at least one word. If anything other than
1436
+ words is detected, an ObsoleteHeaderDefect is added to the token's defect
1437
+ list. We also accept a phrase that starts with CFWS followed by a dot;
1438
+ this is registered as an InvalidHeaderDefect, since it is not supported by
1439
+ even the obsolete grammar.
1440
+
1441
+ """
1442
+ phrase = Phrase()
1443
+ try:
1444
+ token, value = get_word(value)
1445
+ phrase.append(token)
1446
+ except errors.HeaderParseError:
1447
+ phrase.defects.append(errors.InvalidHeaderDefect(
1448
+ "phrase does not start with word"))
1449
+ while value and value[0] not in PHRASE_ENDS:
1450
+ if value[0]=='.':
1451
+ phrase.append(DOT)
1452
+ phrase.defects.append(errors.ObsoleteHeaderDefect(
1453
+ "period in 'phrase'"))
1454
+ value = value[1:]
1455
+ else:
1456
+ try:
1457
+ token, value = get_word(value)
1458
+ except errors.HeaderParseError:
1459
+ if value[0] in CFWS_LEADER:
1460
+ token, value = get_cfws(value)
1461
+ phrase.defects.append(errors.ObsoleteHeaderDefect(
1462
+ "comment found without atom"))
1463
+ else:
1464
+ raise
1465
+ phrase.append(token)
1466
+ return phrase, value
1467
+
1468
+ def get_local_part(value):
1469
+ """ local-part = dot-atom / quoted-string / obs-local-part
1470
+
1471
+ """
1472
+ local_part = LocalPart()
1473
+ leader = None
1474
+ if value and value[0] in CFWS_LEADER:
1475
+ leader, value = get_cfws(value)
1476
+ if not value:
1477
+ raise errors.HeaderParseError(
1478
+ "expected local-part but found '{}'".format(value))
1479
+ try:
1480
+ token, value = get_dot_atom(value)
1481
+ except errors.HeaderParseError:
1482
+ try:
1483
+ token, value = get_word(value)
1484
+ except errors.HeaderParseError:
1485
+ if value[0] != '\\' and value[0] in PHRASE_ENDS:
1486
+ raise
1487
+ token = TokenList()
1488
+ if leader is not None:
1489
+ token[:0] = [leader]
1490
+ local_part.append(token)
1491
+ if value and (value[0]=='\\' or value[0] not in PHRASE_ENDS):
1492
+ obs_local_part, value = get_obs_local_part(str(local_part) + value)
1493
+ if obs_local_part.token_type == 'invalid-obs-local-part':
1494
+ local_part.defects.append(errors.InvalidHeaderDefect(
1495
+ "local-part is not dot-atom, quoted-string, or obs-local-part"))
1496
+ else:
1497
+ local_part.defects.append(errors.ObsoleteHeaderDefect(
1498
+ "local-part is not a dot-atom (contains CFWS)"))
1499
+ local_part[0] = obs_local_part
1500
+ try:
1501
+ local_part.value.encode('ascii')
1502
+ except UnicodeEncodeError:
1503
+ local_part.defects.append(errors.NonASCIILocalPartDefect(
1504
+ "local-part contains non-ASCII characters)"))
1505
+ return local_part, value
1506
+
1507
+ def get_obs_local_part(value):
1508
+ """ obs-local-part = word *("." word)
1509
+ """
1510
+ obs_local_part = ObsLocalPart()
1511
+ last_non_ws_was_dot = False
1512
+ while value and (value[0]=='\\' or value[0] not in PHRASE_ENDS):
1513
+ if value[0] == '.':
1514
+ if last_non_ws_was_dot:
1515
+ obs_local_part.defects.append(errors.InvalidHeaderDefect(
1516
+ "invalid repeated '.'"))
1517
+ obs_local_part.append(DOT)
1518
+ last_non_ws_was_dot = True
1519
+ value = value[1:]
1520
+ continue
1521
+ elif value[0]=='\\':
1522
+ obs_local_part.append(ValueTerminal(value[0],
1523
+ 'misplaced-special'))
1524
+ value = value[1:]
1525
+ obs_local_part.defects.append(errors.InvalidHeaderDefect(
1526
+ "'\\' character outside of quoted-string/ccontent"))
1527
+ last_non_ws_was_dot = False
1528
+ continue
1529
+ if obs_local_part and obs_local_part[-1].token_type != 'dot':
1530
+ obs_local_part.defects.append(errors.InvalidHeaderDefect(
1531
+ "missing '.' between words"))
1532
+ try:
1533
+ token, value = get_word(value)
1534
+ last_non_ws_was_dot = False
1535
+ except errors.HeaderParseError:
1536
+ if value[0] not in CFWS_LEADER:
1537
+ raise
1538
+ token, value = get_cfws(value)
1539
+ obs_local_part.append(token)
1540
+ if not obs_local_part:
1541
+ raise errors.HeaderParseError(
1542
+ "expected obs-local-part but found '{}'".format(value))
1543
+ if (obs_local_part[0].token_type == 'dot' or
1544
+ obs_local_part[0].token_type=='cfws' and
1545
+ len(obs_local_part) > 1 and
1546
+ obs_local_part[1].token_type=='dot'):
1547
+ obs_local_part.defects.append(errors.InvalidHeaderDefect(
1548
+ "Invalid leading '.' in local part"))
1549
+ if (obs_local_part[-1].token_type == 'dot' or
1550
+ obs_local_part[-1].token_type=='cfws' and
1551
+ len(obs_local_part) > 1 and
1552
+ obs_local_part[-2].token_type=='dot'):
1553
+ obs_local_part.defects.append(errors.InvalidHeaderDefect(
1554
+ "Invalid trailing '.' in local part"))
1555
+ if obs_local_part.defects:
1556
+ obs_local_part.token_type = 'invalid-obs-local-part'
1557
+ return obs_local_part, value
1558
+
1559
+ def get_dtext(value):
1560
+ r""" dtext = <printable ascii except \ [ ]> / obs-dtext
1561
+ obs-dtext = obs-NO-WS-CTL / quoted-pair
1562
+
1563
+ We allow anything except the excluded characters, but if we find any
1564
+ ASCII other than the RFC defined printable ASCII, a NonPrintableDefect is
1565
+ added to the token's defects list. Quoted pairs are converted to their
1566
+ unquoted values, so what is returned is a ptext token, in this case a
1567
+ ValueTerminal. If there were quoted-printables, an ObsoleteHeaderDefect is
1568
+ added to the returned token's defect list.
1569
+
1570
+ """
1571
+ ptext, value, had_qp = _get_ptext_to_endchars(value, '[]')
1572
+ ptext = ValueTerminal(ptext, 'ptext')
1573
+ if had_qp:
1574
+ ptext.defects.append(errors.ObsoleteHeaderDefect(
1575
+ "quoted printable found in domain-literal"))
1576
+ _validate_xtext(ptext)
1577
+ return ptext, value
1578
+
1579
+ def _check_for_early_dl_end(value, domain_literal):
1580
+ if value:
1581
+ return False
1582
+ domain_literal.append(errors.InvalidHeaderDefect(
1583
+ "end of input inside domain-literal"))
1584
+ domain_literal.append(ValueTerminal(']', 'domain-literal-end'))
1585
+ return True
1586
+
1587
+ def get_domain_literal(value):
1588
+ """ domain-literal = [CFWS] "[" *([FWS] dtext) [FWS] "]" [CFWS]
1589
+
1590
+ """
1591
+ domain_literal = DomainLiteral()
1592
+ if value[0] in CFWS_LEADER:
1593
+ token, value = get_cfws(value)
1594
+ domain_literal.append(token)
1595
+ if not value:
1596
+ raise errors.HeaderParseError("expected domain-literal")
1597
+ if value[0] != '[':
1598
+ raise errors.HeaderParseError("expected '[' at start of domain-literal "
1599
+ "but found '{}'".format(value))
1600
+ value = value[1:]
1601
+ if _check_for_early_dl_end(value, domain_literal):
1602
+ return domain_literal, value
1603
+ domain_literal.append(ValueTerminal('[', 'domain-literal-start'))
1604
+ if value[0] in WSP:
1605
+ token, value = get_fws(value)
1606
+ domain_literal.append(token)
1607
+ token, value = get_dtext(value)
1608
+ domain_literal.append(token)
1609
+ if _check_for_early_dl_end(value, domain_literal):
1610
+ return domain_literal, value
1611
+ if value[0] in WSP:
1612
+ token, value = get_fws(value)
1613
+ domain_literal.append(token)
1614
+ if _check_for_early_dl_end(value, domain_literal):
1615
+ return domain_literal, value
1616
+ if value[0] != ']':
1617
+ raise errors.HeaderParseError("expected ']' at end of domain-literal "
1618
+ "but found '{}'".format(value))
1619
+ domain_literal.append(ValueTerminal(']', 'domain-literal-end'))
1620
+ value = value[1:]
1621
+ if value and value[0] in CFWS_LEADER:
1622
+ token, value = get_cfws(value)
1623
+ domain_literal.append(token)
1624
+ return domain_literal, value
1625
+
1626
+ def get_domain(value):
1627
+ """ domain = dot-atom / domain-literal / obs-domain
1628
+ obs-domain = atom *("." atom))
1629
+
1630
+ """
1631
+ domain = Domain()
1632
+ leader = None
1633
+ if value and value[0] in CFWS_LEADER:
1634
+ leader, value = get_cfws(value)
1635
+ if not value:
1636
+ raise errors.HeaderParseError(
1637
+ "expected domain but found '{}'".format(value))
1638
+ if value[0] == '[':
1639
+ token, value = get_domain_literal(value)
1640
+ if leader is not None:
1641
+ token[:0] = [leader]
1642
+ domain.append(token)
1643
+ return domain, value
1644
+ try:
1645
+ token, value = get_dot_atom(value)
1646
+ except errors.HeaderParseError:
1647
+ token, value = get_atom(value)
1648
+ if value and value[0] == '@':
1649
+ raise errors.HeaderParseError('Invalid Domain')
1650
+ if leader is not None:
1651
+ token[:0] = [leader]
1652
+ domain.append(token)
1653
+ if value and value[0] == '.':
1654
+ domain.defects.append(errors.ObsoleteHeaderDefect(
1655
+ "domain is not a dot-atom (contains CFWS)"))
1656
+ if domain[0].token_type == 'dot-atom':
1657
+ domain[:] = domain[0]
1658
+ while value and value[0] == '.':
1659
+ domain.append(DOT)
1660
+ token, value = get_atom(value[1:])
1661
+ domain.append(token)
1662
+ return domain, value
1663
+
1664
+ def get_addr_spec(value):
1665
+ """ addr-spec = local-part "@" domain
1666
+
1667
+ """
1668
+ addr_spec = AddrSpec()
1669
+ token, value = get_local_part(value)
1670
+ addr_spec.append(token)
1671
+ if not value or value[0] != '@':
1672
+ addr_spec.defects.append(errors.InvalidHeaderDefect(
1673
+ "addr-spec local part with no domain"))
1674
+ return addr_spec, value
1675
+ addr_spec.append(ValueTerminal('@', 'address-at-symbol'))
1676
+ token, value = get_domain(value[1:])
1677
+ addr_spec.append(token)
1678
+ return addr_spec, value
1679
+
1680
+ def get_obs_route(value):
1681
+ """ obs-route = obs-domain-list ":"
1682
+ obs-domain-list = *(CFWS / ",") "@" domain *("," [CFWS] ["@" domain])
1683
+
1684
+ Returns an obs-route token with the appropriate sub-tokens (that is,
1685
+ there is no obs-domain-list in the parse tree).
1686
+ """
1687
+ obs_route = ObsRoute()
1688
+ while value and (value[0]==',' or value[0] in CFWS_LEADER):
1689
+ if value[0] in CFWS_LEADER:
1690
+ token, value = get_cfws(value)
1691
+ obs_route.append(token)
1692
+ elif value[0] == ',':
1693
+ obs_route.append(ListSeparator)
1694
+ value = value[1:]
1695
+ if not value or value[0] != '@':
1696
+ raise errors.HeaderParseError(
1697
+ "expected obs-route domain but found '{}'".format(value))
1698
+ obs_route.append(RouteComponentMarker)
1699
+ token, value = get_domain(value[1:])
1700
+ obs_route.append(token)
1701
+ while value and value[0]==',':
1702
+ obs_route.append(ListSeparator)
1703
+ value = value[1:]
1704
+ if not value:
1705
+ break
1706
+ if value[0] in CFWS_LEADER:
1707
+ token, value = get_cfws(value)
1708
+ obs_route.append(token)
1709
+ if not value:
1710
+ break
1711
+ if value[0] == '@':
1712
+ obs_route.append(RouteComponentMarker)
1713
+ token, value = get_domain(value[1:])
1714
+ obs_route.append(token)
1715
+ if not value:
1716
+ raise errors.HeaderParseError("end of header while parsing obs-route")
1717
+ if value[0] != ':':
1718
+ raise errors.HeaderParseError( "expected ':' marking end of "
1719
+ "obs-route but found '{}'".format(value))
1720
+ obs_route.append(ValueTerminal(':', 'end-of-obs-route-marker'))
1721
+ return obs_route, value[1:]
1722
+
1723
+ def get_angle_addr(value):
1724
+ """ angle-addr = [CFWS] "<" addr-spec ">" [CFWS] / obs-angle-addr
1725
+ obs-angle-addr = [CFWS] "<" obs-route addr-spec ">" [CFWS]
1726
+
1727
+ """
1728
+ angle_addr = AngleAddr()
1729
+ if value and value[0] in CFWS_LEADER:
1730
+ token, value = get_cfws(value)
1731
+ angle_addr.append(token)
1732
+ if not value or value[0] != '<':
1733
+ raise errors.HeaderParseError(
1734
+ "expected angle-addr but found '{}'".format(value))
1735
+ angle_addr.append(ValueTerminal('<', 'angle-addr-start'))
1736
+ value = value[1:]
1737
+ # Although it is not legal per RFC5322, SMTP uses '<>' in certain
1738
+ # circumstances.
1739
+ if value and value[0] == '>':
1740
+ angle_addr.append(ValueTerminal('>', 'angle-addr-end'))
1741
+ angle_addr.defects.append(errors.InvalidHeaderDefect(
1742
+ "null addr-spec in angle-addr"))
1743
+ value = value[1:]
1744
+ return angle_addr, value
1745
+ try:
1746
+ token, value = get_addr_spec(value)
1747
+ except errors.HeaderParseError:
1748
+ try:
1749
+ token, value = get_obs_route(value)
1750
+ angle_addr.defects.append(errors.ObsoleteHeaderDefect(
1751
+ "obsolete route specification in angle-addr"))
1752
+ except errors.HeaderParseError:
1753
+ raise errors.HeaderParseError(
1754
+ "expected addr-spec or obs-route but found '{}'".format(value))
1755
+ angle_addr.append(token)
1756
+ token, value = get_addr_spec(value)
1757
+ angle_addr.append(token)
1758
+ if value and value[0] == '>':
1759
+ value = value[1:]
1760
+ else:
1761
+ angle_addr.defects.append(errors.InvalidHeaderDefect(
1762
+ "missing trailing '>' on angle-addr"))
1763
+ angle_addr.append(ValueTerminal('>', 'angle-addr-end'))
1764
+ if value and value[0] in CFWS_LEADER:
1765
+ token, value = get_cfws(value)
1766
+ angle_addr.append(token)
1767
+ return angle_addr, value
1768
+
1769
+ def get_display_name(value):
1770
+ """ display-name = phrase
1771
+
1772
+ Because this is simply a name-rule, we don't return a display-name
1773
+ token containing a phrase, but rather a display-name token with
1774
+ the content of the phrase.
1775
+
1776
+ """
1777
+ display_name = DisplayName()
1778
+ token, value = get_phrase(value)
1779
+ display_name.extend(token[:])
1780
+ display_name.defects = token.defects[:]
1781
+ return display_name, value
1782
+
1783
+
1784
+ def get_name_addr(value):
1785
+ """ name-addr = [display-name] angle-addr
1786
+
1787
+ """
1788
+ name_addr = NameAddr()
1789
+ # Both the optional display name and the angle-addr can start with cfws.
1790
+ leader = None
1791
+ if not value:
1792
+ raise errors.HeaderParseError(
1793
+ "expected name-addr but found '{}'".format(value))
1794
+ if value[0] in CFWS_LEADER:
1795
+ leader, value = get_cfws(value)
1796
+ if not value:
1797
+ raise errors.HeaderParseError(
1798
+ "expected name-addr but found '{}'".format(leader))
1799
+ if value[0] != '<':
1800
+ if value[0] in PHRASE_ENDS:
1801
+ raise errors.HeaderParseError(
1802
+ "expected name-addr but found '{}'".format(value))
1803
+ token, value = get_display_name(value)
1804
+ if not value:
1805
+ raise errors.HeaderParseError(
1806
+ "expected name-addr but found '{}'".format(token))
1807
+ if leader is not None:
1808
+ if isinstance(token[0], TokenList):
1809
+ token[0][:0] = [leader]
1810
+ else:
1811
+ token[:0] = [leader]
1812
+ leader = None
1813
+ name_addr.append(token)
1814
+ token, value = get_angle_addr(value)
1815
+ if leader is not None:
1816
+ token[:0] = [leader]
1817
+ name_addr.append(token)
1818
+ return name_addr, value
1819
+
1820
+ def get_mailbox(value):
1821
+ """ mailbox = name-addr / addr-spec
1822
+
1823
+ """
1824
+ # The only way to figure out if we are dealing with a name-addr or an
1825
+ # addr-spec is to try parsing each one.
1826
+ mailbox = Mailbox()
1827
+ try:
1828
+ token, value = get_name_addr(value)
1829
+ except errors.HeaderParseError:
1830
+ try:
1831
+ token, value = get_addr_spec(value)
1832
+ except errors.HeaderParseError:
1833
+ raise errors.HeaderParseError(
1834
+ "expected mailbox but found '{}'".format(value))
1835
+ if any(isinstance(x, errors.InvalidHeaderDefect)
1836
+ for x in token.all_defects):
1837
+ mailbox.token_type = 'invalid-mailbox'
1838
+ mailbox.append(token)
1839
+ return mailbox, value
1840
+
1841
+ def get_invalid_mailbox(value, endchars):
1842
+ """ Read everything up to one of the chars in endchars.
1843
+
1844
+ This is outside the formal grammar. The InvalidMailbox TokenList that is
1845
+ returned acts like a Mailbox, but the data attributes are None.
1846
+
1847
+ """
1848
+ invalid_mailbox = InvalidMailbox()
1849
+ while value and value[0] not in endchars:
1850
+ if value[0] in PHRASE_ENDS:
1851
+ invalid_mailbox.append(ValueTerminal(value[0],
1852
+ 'misplaced-special'))
1853
+ value = value[1:]
1854
+ else:
1855
+ token, value = get_phrase(value)
1856
+ invalid_mailbox.append(token)
1857
+ return invalid_mailbox, value
1858
+
1859
+ def get_mailbox_list(value):
1860
+ """ mailbox-list = (mailbox *("," mailbox)) / obs-mbox-list
1861
+ obs-mbox-list = *([CFWS] ",") mailbox *("," [mailbox / CFWS])
1862
+
1863
+ For this routine we go outside the formal grammar in order to improve error
1864
+ handling. We recognize the end of the mailbox list only at the end of the
1865
+ value or at a ';' (the group terminator). This is so that we can turn
1866
+ invalid mailboxes into InvalidMailbox tokens and continue parsing any
1867
+ remaining valid mailboxes. We also allow all mailbox entries to be null,
1868
+ and this condition is handled appropriately at a higher level.
1869
+
1870
+ """
1871
+ mailbox_list = MailboxList()
1872
+ while value and value[0] != ';':
1873
+ try:
1874
+ token, value = get_mailbox(value)
1875
+ mailbox_list.append(token)
1876
+ except errors.HeaderParseError:
1877
+ leader = None
1878
+ if value[0] in CFWS_LEADER:
1879
+ leader, value = get_cfws(value)
1880
+ if not value or value[0] in ',;':
1881
+ mailbox_list.append(leader)
1882
+ mailbox_list.defects.append(errors.ObsoleteHeaderDefect(
1883
+ "empty element in mailbox-list"))
1884
+ else:
1885
+ token, value = get_invalid_mailbox(value, ',;')
1886
+ if leader is not None:
1887
+ token[:0] = [leader]
1888
+ mailbox_list.append(token)
1889
+ mailbox_list.defects.append(errors.InvalidHeaderDefect(
1890
+ "invalid mailbox in mailbox-list"))
1891
+ elif value[0] == ',':
1892
+ mailbox_list.defects.append(errors.ObsoleteHeaderDefect(
1893
+ "empty element in mailbox-list"))
1894
+ else:
1895
+ token, value = get_invalid_mailbox(value, ',;')
1896
+ if leader is not None:
1897
+ token[:0] = [leader]
1898
+ mailbox_list.append(token)
1899
+ mailbox_list.defects.append(errors.InvalidHeaderDefect(
1900
+ "invalid mailbox in mailbox-list"))
1901
+ if value and value[0] not in ',;':
1902
+ # Crap after mailbox; treat it as an invalid mailbox.
1903
+ # The mailbox info will still be available.
1904
+ mailbox = mailbox_list[-1]
1905
+ mailbox.token_type = 'invalid-mailbox'
1906
+ token, value = get_invalid_mailbox(value, ',;')
1907
+ mailbox.extend(token)
1908
+ mailbox_list.defects.append(errors.InvalidHeaderDefect(
1909
+ "invalid mailbox in mailbox-list"))
1910
+ if value and value[0] == ',':
1911
+ mailbox_list.append(ListSeparator)
1912
+ value = value[1:]
1913
+ return mailbox_list, value
1914
+
1915
+
1916
+ def get_group_list(value):
1917
+ """ group-list = mailbox-list / CFWS / obs-group-list
1918
+ obs-group-list = 1*([CFWS] ",") [CFWS]
1919
+
1920
+ """
1921
+ group_list = GroupList()
1922
+ if not value:
1923
+ group_list.defects.append(errors.InvalidHeaderDefect(
1924
+ "end of header before group-list"))
1925
+ return group_list, value
1926
+ leader = None
1927
+ if value and value[0] in CFWS_LEADER:
1928
+ leader, value = get_cfws(value)
1929
+ if not value:
1930
+ # This should never happen in email parsing, since CFWS-only is a
1931
+ # legal alternative to group-list in a group, which is the only
1932
+ # place group-list appears.
1933
+ group_list.defects.append(errors.InvalidHeaderDefect(
1934
+ "end of header in group-list"))
1935
+ group_list.append(leader)
1936
+ return group_list, value
1937
+ if value[0] == ';':
1938
+ group_list.append(leader)
1939
+ return group_list, value
1940
+ token, value = get_mailbox_list(value)
1941
+ if len(token.all_mailboxes)==0:
1942
+ if leader is not None:
1943
+ group_list.append(leader)
1944
+ group_list.extend(token)
1945
+ group_list.defects.append(errors.ObsoleteHeaderDefect(
1946
+ "group-list with empty entries"))
1947
+ return group_list, value
1948
+ if leader is not None:
1949
+ token[:0] = [leader]
1950
+ group_list.append(token)
1951
+ return group_list, value
1952
+
1953
+ def get_group(value):
1954
+ """ group = display-name ":" [group-list] ";" [CFWS]
1955
+
1956
+ """
1957
+ group = Group()
1958
+ token, value = get_display_name(value)
1959
+ if not value or value[0] != ':':
1960
+ raise errors.HeaderParseError("expected ':' at end of group "
1961
+ "display name but found '{}'".format(value))
1962
+ group.append(token)
1963
+ group.append(ValueTerminal(':', 'group-display-name-terminator'))
1964
+ value = value[1:]
1965
+ if value and value[0] == ';':
1966
+ group.append(ValueTerminal(';', 'group-terminator'))
1967
+ return group, value[1:]
1968
+ token, value = get_group_list(value)
1969
+ group.append(token)
1970
+ if not value:
1971
+ group.defects.append(errors.InvalidHeaderDefect(
1972
+ "end of header in group"))
1973
+ elif value[0] != ';':
1974
+ raise errors.HeaderParseError(
1975
+ "expected ';' at end of group but found {}".format(value))
1976
+ group.append(ValueTerminal(';', 'group-terminator'))
1977
+ value = value[1:]
1978
+ if value and value[0] in CFWS_LEADER:
1979
+ token, value = get_cfws(value)
1980
+ group.append(token)
1981
+ return group, value
1982
+
1983
+ def get_address(value):
1984
+ """ address = mailbox / group
1985
+
1986
+ Note that counter-intuitively, an address can be either a single address or
1987
+ a list of addresses (a group). This is why the returned Address object has
1988
+ a 'mailboxes' attribute which treats a single address as a list of length
1989
+ one. When you need to differentiate between to two cases, extract the single
1990
+ element, which is either a mailbox or a group token.
1991
+
1992
+ """
1993
+ # The formal grammar isn't very helpful when parsing an address. mailbox
1994
+ # and group, especially when allowing for obsolete forms, start off very
1995
+ # similarly. It is only when you reach one of @, <, or : that you know
1996
+ # what you've got. So, we try each one in turn, starting with the more
1997
+ # likely of the two. We could perhaps make this more efficient by looking
1998
+ # for a phrase and then branching based on the next character, but that
1999
+ # would be a premature optimization.
2000
+ address = Address()
2001
+ try:
2002
+ token, value = get_group(value)
2003
+ except errors.HeaderParseError:
2004
+ try:
2005
+ token, value = get_mailbox(value)
2006
+ except errors.HeaderParseError:
2007
+ raise errors.HeaderParseError(
2008
+ "expected address but found '{}'".format(value))
2009
+ address.append(token)
2010
+ return address, value
2011
+
2012
+ def get_address_list(value):
2013
+ """ address_list = (address *("," address)) / obs-addr-list
2014
+ obs-addr-list = *([CFWS] ",") address *("," [address / CFWS])
2015
+
2016
+ We depart from the formal grammar here by continuing to parse until the end
2017
+ of the input, assuming the input to be entirely composed of an
2018
+ address-list. This is always true in email parsing, and allows us
2019
+ to skip invalid addresses to parse additional valid ones.
2020
+
2021
+ """
2022
+ address_list = AddressList()
2023
+ while value:
2024
+ try:
2025
+ token, value = get_address(value)
2026
+ address_list.append(token)
2027
+ except errors.HeaderParseError:
2028
+ leader = None
2029
+ if value[0] in CFWS_LEADER:
2030
+ leader, value = get_cfws(value)
2031
+ if not value or value[0] == ',':
2032
+ address_list.append(leader)
2033
+ address_list.defects.append(errors.ObsoleteHeaderDefect(
2034
+ "address-list entry with no content"))
2035
+ else:
2036
+ token, value = get_invalid_mailbox(value, ',')
2037
+ if leader is not None:
2038
+ token[:0] = [leader]
2039
+ address_list.append(Address([token]))
2040
+ address_list.defects.append(errors.InvalidHeaderDefect(
2041
+ "invalid address in address-list"))
2042
+ elif value[0] == ',':
2043
+ address_list.defects.append(errors.ObsoleteHeaderDefect(
2044
+ "empty element in address-list"))
2045
+ else:
2046
+ token, value = get_invalid_mailbox(value, ',')
2047
+ if leader is not None:
2048
+ token[:0] = [leader]
2049
+ address_list.append(Address([token]))
2050
+ address_list.defects.append(errors.InvalidHeaderDefect(
2051
+ "invalid address in address-list"))
2052
+ if value and value[0] != ',':
2053
+ # Crap after address; treat it as an invalid mailbox.
2054
+ # The mailbox info will still be available.
2055
+ mailbox = address_list[-1][0]
2056
+ mailbox.token_type = 'invalid-mailbox'
2057
+ token, value = get_invalid_mailbox(value, ',')
2058
+ mailbox.extend(token)
2059
+ address_list.defects.append(errors.InvalidHeaderDefect(
2060
+ "invalid address in address-list"))
2061
+ if value: # Must be a , at this point.
2062
+ address_list.append(ListSeparator)
2063
+ value = value[1:]
2064
+ return address_list, value
2065
+
2066
+
2067
+ def get_no_fold_literal(value):
2068
+ """ no-fold-literal = "[" *dtext "]"
2069
+ """
2070
+ no_fold_literal = NoFoldLiteral()
2071
+ if not value:
2072
+ raise errors.HeaderParseError(
2073
+ "expected no-fold-literal but found '{}'".format(value))
2074
+ if value[0] != '[':
2075
+ raise errors.HeaderParseError(
2076
+ "expected '[' at the start of no-fold-literal "
2077
+ "but found '{}'".format(value))
2078
+ no_fold_literal.append(ValueTerminal('[', 'no-fold-literal-start'))
2079
+ value = value[1:]
2080
+ token, value = get_dtext(value)
2081
+ no_fold_literal.append(token)
2082
+ if not value or value[0] != ']':
2083
+ raise errors.HeaderParseError(
2084
+ "expected ']' at the end of no-fold-literal "
2085
+ "but found '{}'".format(value))
2086
+ no_fold_literal.append(ValueTerminal(']', 'no-fold-literal-end'))
2087
+ return no_fold_literal, value[1:]
2088
+
2089
+ def get_msg_id(value):
2090
+ """msg-id = [CFWS] "<" id-left '@' id-right ">" [CFWS]
2091
+ id-left = dot-atom-text / obs-id-left
2092
+ id-right = dot-atom-text / no-fold-literal / obs-id-right
2093
+ no-fold-literal = "[" *dtext "]"
2094
+ """
2095
+ msg_id = MsgID()
2096
+ if value and value[0] in CFWS_LEADER:
2097
+ token, value = get_cfws(value)
2098
+ msg_id.append(token)
2099
+ if not value or value[0] != '<':
2100
+ raise errors.HeaderParseError(
2101
+ "expected msg-id but found '{}'".format(value))
2102
+ msg_id.append(ValueTerminal('<', 'msg-id-start'))
2103
+ value = value[1:]
2104
+ # Parse id-left.
2105
+ try:
2106
+ token, value = get_dot_atom_text(value)
2107
+ except errors.HeaderParseError:
2108
+ try:
2109
+ # obs-id-left is same as local-part of add-spec.
2110
+ token, value = get_obs_local_part(value)
2111
+ msg_id.defects.append(errors.ObsoleteHeaderDefect(
2112
+ "obsolete id-left in msg-id"))
2113
+ except errors.HeaderParseError:
2114
+ raise errors.HeaderParseError(
2115
+ "expected dot-atom-text or obs-id-left"
2116
+ " but found '{}'".format(value))
2117
+ msg_id.append(token)
2118
+ if not value or value[0] != '@':
2119
+ msg_id.defects.append(errors.InvalidHeaderDefect(
2120
+ "msg-id with no id-right"))
2121
+ # Even though there is no id-right, if the local part
2122
+ # ends with `>` let's just parse it too and return
2123
+ # along with the defect.
2124
+ if value and value[0] == '>':
2125
+ msg_id.append(ValueTerminal('>', 'msg-id-end'))
2126
+ value = value[1:]
2127
+ return msg_id, value
2128
+ msg_id.append(ValueTerminal('@', 'address-at-symbol'))
2129
+ value = value[1:]
2130
+ # Parse id-right.
2131
+ try:
2132
+ token, value = get_dot_atom_text(value)
2133
+ except errors.HeaderParseError:
2134
+ try:
2135
+ token, value = get_no_fold_literal(value)
2136
+ except errors.HeaderParseError:
2137
+ try:
2138
+ token, value = get_domain(value)
2139
+ msg_id.defects.append(errors.ObsoleteHeaderDefect(
2140
+ "obsolete id-right in msg-id"))
2141
+ except errors.HeaderParseError:
2142
+ raise errors.HeaderParseError(
2143
+ "expected dot-atom-text, no-fold-literal or obs-id-right"
2144
+ " but found '{}'".format(value))
2145
+ msg_id.append(token)
2146
+ if value and value[0] == '>':
2147
+ value = value[1:]
2148
+ else:
2149
+ msg_id.defects.append(errors.InvalidHeaderDefect(
2150
+ "missing trailing '>' on msg-id"))
2151
+ msg_id.append(ValueTerminal('>', 'msg-id-end'))
2152
+ if value and value[0] in CFWS_LEADER:
2153
+ token, value = get_cfws(value)
2154
+ msg_id.append(token)
2155
+ return msg_id, value
2156
+
2157
+
2158
+ def parse_message_id(value):
2159
+ """message-id = "Message-ID:" msg-id CRLF
2160
+ """
2161
+ message_id = MessageID()
2162
+ try:
2163
+ token, value = get_msg_id(value)
2164
+ message_id.append(token)
2165
+ except errors.HeaderParseError as ex:
2166
+ token = get_unstructured(value)
2167
+ message_id = InvalidMessageID(token)
2168
+ message_id.defects.append(
2169
+ errors.InvalidHeaderDefect("Invalid msg-id: {!r}".format(ex)))
2170
+ else:
2171
+ # Value after parsing a valid msg_id should be None.
2172
+ if value:
2173
+ message_id.defects.append(errors.InvalidHeaderDefect(
2174
+ "Unexpected {!r}".format(value)))
2175
+
2176
+ return message_id
2177
+
2178
+ #
2179
+ # XXX: As I begin to add additional header parsers, I'm realizing we probably
2180
+ # have two level of parser routines: the get_XXX methods that get a token in
2181
+ # the grammar, and parse_XXX methods that parse an entire field value. So
2182
+ # get_address_list above should really be a parse_ method, as probably should
2183
+ # be get_unstructured.
2184
+ #
2185
+
2186
+ def parse_mime_version(value):
2187
+ """ mime-version = [CFWS] 1*digit [CFWS] "." [CFWS] 1*digit [CFWS]
2188
+
2189
+ """
2190
+ # The [CFWS] is implicit in the RFC 2045 BNF.
2191
+ # XXX: This routine is a bit verbose, should factor out a get_int method.
2192
+ mime_version = MIMEVersion()
2193
+ if not value:
2194
+ mime_version.defects.append(errors.HeaderMissingRequiredValue(
2195
+ "Missing MIME version number (eg: 1.0)"))
2196
+ return mime_version
2197
+ if value[0] in CFWS_LEADER:
2198
+ token, value = get_cfws(value)
2199
+ mime_version.append(token)
2200
+ if not value:
2201
+ mime_version.defects.append(errors.HeaderMissingRequiredValue(
2202
+ "Expected MIME version number but found only CFWS"))
2203
+ digits = ''
2204
+ while value and value[0] != '.' and value[0] not in CFWS_LEADER:
2205
+ digits += value[0]
2206
+ value = value[1:]
2207
+ if not digits.isdigit():
2208
+ mime_version.defects.append(errors.InvalidHeaderDefect(
2209
+ "Expected MIME major version number but found {!r}".format(digits)))
2210
+ mime_version.append(ValueTerminal(digits, 'xtext'))
2211
+ else:
2212
+ mime_version.major = int(digits)
2213
+ mime_version.append(ValueTerminal(digits, 'digits'))
2214
+ if value and value[0] in CFWS_LEADER:
2215
+ token, value = get_cfws(value)
2216
+ mime_version.append(token)
2217
+ if not value or value[0] != '.':
2218
+ if mime_version.major is not None:
2219
+ mime_version.defects.append(errors.InvalidHeaderDefect(
2220
+ "Incomplete MIME version; found only major number"))
2221
+ if value:
2222
+ mime_version.append(ValueTerminal(value, 'xtext'))
2223
+ return mime_version
2224
+ mime_version.append(ValueTerminal('.', 'version-separator'))
2225
+ value = value[1:]
2226
+ if value and value[0] in CFWS_LEADER:
2227
+ token, value = get_cfws(value)
2228
+ mime_version.append(token)
2229
+ if not value:
2230
+ if mime_version.major is not None:
2231
+ mime_version.defects.append(errors.InvalidHeaderDefect(
2232
+ "Incomplete MIME version; found only major number"))
2233
+ return mime_version
2234
+ digits = ''
2235
+ while value and value[0] not in CFWS_LEADER:
2236
+ digits += value[0]
2237
+ value = value[1:]
2238
+ if not digits.isdigit():
2239
+ mime_version.defects.append(errors.InvalidHeaderDefect(
2240
+ "Expected MIME minor version number but found {!r}".format(digits)))
2241
+ mime_version.append(ValueTerminal(digits, 'xtext'))
2242
+ else:
2243
+ mime_version.minor = int(digits)
2244
+ mime_version.append(ValueTerminal(digits, 'digits'))
2245
+ if value and value[0] in CFWS_LEADER:
2246
+ token, value = get_cfws(value)
2247
+ mime_version.append(token)
2248
+ if value:
2249
+ mime_version.defects.append(errors.InvalidHeaderDefect(
2250
+ "Excess non-CFWS text after MIME version"))
2251
+ mime_version.append(ValueTerminal(value, 'xtext'))
2252
+ return mime_version
2253
+
2254
+ def get_invalid_parameter(value):
2255
+ """ Read everything up to the next ';'.
2256
+
2257
+ This is outside the formal grammar. The InvalidParameter TokenList that is
2258
+ returned acts like a Parameter, but the data attributes are None.
2259
+
2260
+ """
2261
+ invalid_parameter = InvalidParameter()
2262
+ while value and value[0] != ';':
2263
+ if value[0] in PHRASE_ENDS:
2264
+ invalid_parameter.append(ValueTerminal(value[0],
2265
+ 'misplaced-special'))
2266
+ value = value[1:]
2267
+ else:
2268
+ token, value = get_phrase(value)
2269
+ invalid_parameter.append(token)
2270
+ return invalid_parameter, value
2271
+
2272
+ def get_ttext(value):
2273
+ """ttext = <matches _ttext_matcher>
2274
+
2275
+ We allow any non-TOKEN_ENDS in ttext, but add defects to the token's
2276
+ defects list if we find non-ttext characters. We also register defects for
2277
+ *any* non-printables even though the RFC doesn't exclude all of them,
2278
+ because we follow the spirit of RFC 5322.
2279
+
2280
+ """
2281
+ m = _non_token_end_matcher(value)
2282
+ if not m:
2283
+ raise errors.HeaderParseError(
2284
+ "expected ttext but found '{}'".format(value))
2285
+ ttext = m.group()
2286
+ value = value[len(ttext):]
2287
+ ttext = ValueTerminal(ttext, 'ttext')
2288
+ _validate_xtext(ttext)
2289
+ return ttext, value
2290
+
2291
+ def get_token(value):
2292
+ """token = [CFWS] 1*ttext [CFWS]
2293
+
2294
+ The RFC equivalent of ttext is any US-ASCII chars except space, ctls, or
2295
+ tspecials. We also exclude tabs even though the RFC doesn't.
2296
+
2297
+ The RFC implies the CFWS but is not explicit about it in the BNF.
2298
+
2299
+ """
2300
+ mtoken = Token()
2301
+ if value and value[0] in CFWS_LEADER:
2302
+ token, value = get_cfws(value)
2303
+ mtoken.append(token)
2304
+ if value and value[0] in TOKEN_ENDS:
2305
+ raise errors.HeaderParseError(
2306
+ "expected token but found '{}'".format(value))
2307
+ token, value = get_ttext(value)
2308
+ mtoken.append(token)
2309
+ if value and value[0] in CFWS_LEADER:
2310
+ token, value = get_cfws(value)
2311
+ mtoken.append(token)
2312
+ return mtoken, value
2313
+
2314
+ def get_attrtext(value):
2315
+ """attrtext = 1*(any non-ATTRIBUTE_ENDS character)
2316
+
2317
+ We allow any non-ATTRIBUTE_ENDS in attrtext, but add defects to the
2318
+ token's defects list if we find non-attrtext characters. We also register
2319
+ defects for *any* non-printables even though the RFC doesn't exclude all of
2320
+ them, because we follow the spirit of RFC 5322.
2321
+
2322
+ """
2323
+ m = _non_attribute_end_matcher(value)
2324
+ if not m:
2325
+ raise errors.HeaderParseError(
2326
+ "expected attrtext but found {!r}".format(value))
2327
+ attrtext = m.group()
2328
+ value = value[len(attrtext):]
2329
+ attrtext = ValueTerminal(attrtext, 'attrtext')
2330
+ _validate_xtext(attrtext)
2331
+ return attrtext, value
2332
+
2333
+ def get_attribute(value):
2334
+ """ [CFWS] 1*attrtext [CFWS]
2335
+
2336
+ This version of the BNF makes the CFWS explicit, and as usual we use a
2337
+ value terminal for the actual run of characters. The RFC equivalent of
2338
+ attrtext is the token characters, with the subtraction of '*', "'", and '%'.
2339
+ We include tab in the excluded set just as we do for token.
2340
+
2341
+ """
2342
+ attribute = Attribute()
2343
+ if value and value[0] in CFWS_LEADER:
2344
+ token, value = get_cfws(value)
2345
+ attribute.append(token)
2346
+ if value and value[0] in ATTRIBUTE_ENDS:
2347
+ raise errors.HeaderParseError(
2348
+ "expected token but found '{}'".format(value))
2349
+ token, value = get_attrtext(value)
2350
+ attribute.append(token)
2351
+ if value and value[0] in CFWS_LEADER:
2352
+ token, value = get_cfws(value)
2353
+ attribute.append(token)
2354
+ return attribute, value
2355
+
2356
+ def get_extended_attrtext(value):
2357
+ """attrtext = 1*(any non-ATTRIBUTE_ENDS character plus '%')
2358
+
2359
+ This is a special parsing routine so that we get a value that
2360
+ includes % escapes as a single string (which we decode as a single
2361
+ string later).
2362
+
2363
+ """
2364
+ m = _non_extended_attribute_end_matcher(value)
2365
+ if not m:
2366
+ raise errors.HeaderParseError(
2367
+ "expected extended attrtext but found {!r}".format(value))
2368
+ attrtext = m.group()
2369
+ value = value[len(attrtext):]
2370
+ attrtext = ValueTerminal(attrtext, 'extended-attrtext')
2371
+ _validate_xtext(attrtext)
2372
+ return attrtext, value
2373
+
2374
+ def get_extended_attribute(value):
2375
+ """ [CFWS] 1*extended_attrtext [CFWS]
2376
+
2377
+ This is like the non-extended version except we allow % characters, so that
2378
+ we can pick up an encoded value as a single string.
2379
+
2380
+ """
2381
+ # XXX: should we have an ExtendedAttribute TokenList?
2382
+ attribute = Attribute()
2383
+ if value and value[0] in CFWS_LEADER:
2384
+ token, value = get_cfws(value)
2385
+ attribute.append(token)
2386
+ if value and value[0] in EXTENDED_ATTRIBUTE_ENDS:
2387
+ raise errors.HeaderParseError(
2388
+ "expected token but found '{}'".format(value))
2389
+ token, value = get_extended_attrtext(value)
2390
+ attribute.append(token)
2391
+ if value and value[0] in CFWS_LEADER:
2392
+ token, value = get_cfws(value)
2393
+ attribute.append(token)
2394
+ return attribute, value
2395
+
2396
+ def get_section(value):
2397
+ """ '*' digits
2398
+
2399
+ The formal BNF is more complicated because leading 0s are not allowed. We
2400
+ check for that and add a defect. We also assume no CFWS is allowed between
2401
+ the '*' and the digits, though the RFC is not crystal clear on that.
2402
+ The caller should already have dealt with leading CFWS.
2403
+
2404
+ """
2405
+ section = Section()
2406
+ if not value or value[0] != '*':
2407
+ raise errors.HeaderParseError("Expected section but found {}".format(
2408
+ value))
2409
+ section.append(ValueTerminal('*', 'section-marker'))
2410
+ value = value[1:]
2411
+ if not value or not value[0].isdigit():
2412
+ raise errors.HeaderParseError("Expected section number but "
2413
+ "found {}".format(value))
2414
+ digits = ''
2415
+ while value and value[0].isdigit():
2416
+ digits += value[0]
2417
+ value = value[1:]
2418
+ if digits[0] == '0' and digits != '0':
2419
+ section.defects.append(errors.InvalidHeaderDefect(
2420
+ "section number has an invalid leading 0"))
2421
+ section.number = int(digits)
2422
+ section.append(ValueTerminal(digits, 'digits'))
2423
+ return section, value
2424
+
2425
+
2426
+ def get_value(value):
2427
+ """ quoted-string / attribute
2428
+
2429
+ """
2430
+ v = Value()
2431
+ if not value:
2432
+ raise errors.HeaderParseError("Expected value but found end of string")
2433
+ leader = None
2434
+ if value[0] in CFWS_LEADER:
2435
+ leader, value = get_cfws(value)
2436
+ if not value:
2437
+ raise errors.HeaderParseError("Expected value but found "
2438
+ "only {}".format(leader))
2439
+ if value[0] == '"':
2440
+ token, value = get_quoted_string(value)
2441
+ else:
2442
+ token, value = get_extended_attribute(value)
2443
+ if leader is not None:
2444
+ token[:0] = [leader]
2445
+ v.append(token)
2446
+ return v, value
2447
+
2448
+ def get_parameter(value):
2449
+ """ attribute [section] ["*"] [CFWS] "=" value
2450
+
2451
+ The CFWS is implied by the RFC but not made explicit in the BNF. This
2452
+ simplified form of the BNF from the RFC is made to conform with the RFC BNF
2453
+ through some extra checks. We do it this way because it makes both error
2454
+ recovery and working with the resulting parse tree easier.
2455
+ """
2456
+ # It is possible CFWS would also be implicitly allowed between the section
2457
+ # and the 'extended-attribute' marker (the '*') , but we've never seen that
2458
+ # in the wild and we will therefore ignore the possibility.
2459
+ param = Parameter()
2460
+ token, value = get_attribute(value)
2461
+ param.append(token)
2462
+ if not value or value[0] == ';':
2463
+ param.defects.append(errors.InvalidHeaderDefect("Parameter contains "
2464
+ "name ({}) but no value".format(token)))
2465
+ return param, value
2466
+ if value[0] == '*':
2467
+ try:
2468
+ token, value = get_section(value)
2469
+ param.sectioned = True
2470
+ param.append(token)
2471
+ except errors.HeaderParseError:
2472
+ pass
2473
+ if not value:
2474
+ raise errors.HeaderParseError("Incomplete parameter")
2475
+ if value[0] == '*':
2476
+ param.append(ValueTerminal('*', 'extended-parameter-marker'))
2477
+ value = value[1:]
2478
+ param.extended = True
2479
+ if value[0] != '=':
2480
+ raise errors.HeaderParseError("Parameter not followed by '='")
2481
+ param.append(ValueTerminal('=', 'parameter-separator'))
2482
+ value = value[1:]
2483
+ if value and value[0] in CFWS_LEADER:
2484
+ token, value = get_cfws(value)
2485
+ param.append(token)
2486
+ remainder = None
2487
+ appendto = param
2488
+ if param.extended and value and value[0] == '"':
2489
+ # Now for some serious hackery to handle the common invalid case of
2490
+ # double quotes around an extended value. We also accept (with defect)
2491
+ # a value marked as encoded that isn't really.
2492
+ qstring, remainder = get_quoted_string(value)
2493
+ inner_value = qstring.stripped_value
2494
+ semi_valid = False
2495
+ if param.section_number == 0:
2496
+ if inner_value and inner_value[0] == "'":
2497
+ semi_valid = True
2498
+ else:
2499
+ token, rest = get_attrtext(inner_value)
2500
+ if rest and rest[0] == "'":
2501
+ semi_valid = True
2502
+ else:
2503
+ try:
2504
+ token, rest = get_extended_attrtext(inner_value)
2505
+ except:
2506
+ pass
2507
+ else:
2508
+ if not rest:
2509
+ semi_valid = True
2510
+ if semi_valid:
2511
+ param.defects.append(errors.InvalidHeaderDefect(
2512
+ "Quoted string value for extended parameter is invalid"))
2513
+ param.append(qstring)
2514
+ for t in qstring:
2515
+ if t.token_type == 'bare-quoted-string':
2516
+ t[:] = []
2517
+ appendto = t
2518
+ break
2519
+ value = inner_value
2520
+ else:
2521
+ remainder = None
2522
+ param.defects.append(errors.InvalidHeaderDefect(
2523
+ "Parameter marked as extended but appears to have a "
2524
+ "quoted string value that is non-encoded"))
2525
+ if value and value[0] == "'":
2526
+ token = None
2527
+ else:
2528
+ token, value = get_value(value)
2529
+ if not param.extended or param.section_number > 0:
2530
+ if not value or value[0] != "'":
2531
+ appendto.append(token)
2532
+ if remainder is not None:
2533
+ assert not value, value
2534
+ value = remainder
2535
+ return param, value
2536
+ param.defects.append(errors.InvalidHeaderDefect(
2537
+ "Apparent initial-extended-value but attribute "
2538
+ "was not marked as extended or was not initial section"))
2539
+ if not value:
2540
+ # Assume the charset/lang is missing and the token is the value.
2541
+ param.defects.append(errors.InvalidHeaderDefect(
2542
+ "Missing required charset/lang delimiters"))
2543
+ appendto.append(token)
2544
+ if remainder is None:
2545
+ return param, value
2546
+ else:
2547
+ if token is not None:
2548
+ for t in token:
2549
+ if t.token_type == 'extended-attrtext':
2550
+ break
2551
+ t.token_type == 'attrtext'
2552
+ appendto.append(t)
2553
+ param.charset = t.value
2554
+ if value[0] != "'":
2555
+ raise errors.HeaderParseError("Expected RFC2231 char/lang encoding "
2556
+ "delimiter, but found {!r}".format(value))
2557
+ appendto.append(ValueTerminal("'", 'RFC2231-delimiter'))
2558
+ value = value[1:]
2559
+ if value and value[0] != "'":
2560
+ token, value = get_attrtext(value)
2561
+ appendto.append(token)
2562
+ param.lang = token.value
2563
+ if not value or value[0] != "'":
2564
+ raise errors.HeaderParseError("Expected RFC2231 char/lang encoding "
2565
+ "delimiter, but found {}".format(value))
2566
+ appendto.append(ValueTerminal("'", 'RFC2231-delimiter'))
2567
+ value = value[1:]
2568
+ if remainder is not None:
2569
+ # Treat the rest of value as bare quoted string content.
2570
+ v = Value()
2571
+ while value:
2572
+ if value[0] in WSP:
2573
+ token, value = get_fws(value)
2574
+ elif value[0] == '"':
2575
+ token = ValueTerminal('"', 'DQUOTE')
2576
+ value = value[1:]
2577
+ else:
2578
+ token, value = get_qcontent(value)
2579
+ v.append(token)
2580
+ token = v
2581
+ else:
2582
+ token, value = get_value(value)
2583
+ appendto.append(token)
2584
+ if remainder is not None:
2585
+ assert not value, value
2586
+ value = remainder
2587
+ return param, value
2588
+
2589
+ def parse_mime_parameters(value):
2590
+ """ parameter *( ";" parameter )
2591
+
2592
+ That BNF is meant to indicate this routine should only be called after
2593
+ finding and handling the leading ';'. There is no corresponding rule in
2594
+ the formal RFC grammar, but it is more convenient for us for the set of
2595
+ parameters to be treated as its own TokenList.
2596
+
2597
+ This is 'parse' routine because it consumes the remaining value, but it
2598
+ would never be called to parse a full header. Instead it is called to
2599
+ parse everything after the non-parameter value of a specific MIME header.
2600
+
2601
+ """
2602
+ mime_parameters = MimeParameters()
2603
+ while value:
2604
+ try:
2605
+ token, value = get_parameter(value)
2606
+ mime_parameters.append(token)
2607
+ except errors.HeaderParseError:
2608
+ leader = None
2609
+ if value[0] in CFWS_LEADER:
2610
+ leader, value = get_cfws(value)
2611
+ if not value:
2612
+ mime_parameters.append(leader)
2613
+ return mime_parameters
2614
+ if value[0] == ';':
2615
+ if leader is not None:
2616
+ mime_parameters.append(leader)
2617
+ mime_parameters.defects.append(errors.InvalidHeaderDefect(
2618
+ "parameter entry with no content"))
2619
+ else:
2620
+ token, value = get_invalid_parameter(value)
2621
+ if leader:
2622
+ token[:0] = [leader]
2623
+ mime_parameters.append(token)
2624
+ mime_parameters.defects.append(errors.InvalidHeaderDefect(
2625
+ "invalid parameter {!r}".format(token)))
2626
+ if value and value[0] != ';':
2627
+ # Junk after the otherwise valid parameter. Mark it as
2628
+ # invalid, but it will have a value.
2629
+ param = mime_parameters[-1]
2630
+ param.token_type = 'invalid-parameter'
2631
+ token, value = get_invalid_parameter(value)
2632
+ param.extend(token)
2633
+ mime_parameters.defects.append(errors.InvalidHeaderDefect(
2634
+ "parameter with invalid trailing text {!r}".format(token)))
2635
+ if value:
2636
+ # Must be a ';' at this point.
2637
+ mime_parameters.append(ValueTerminal(';', 'parameter-separator'))
2638
+ value = value[1:]
2639
+ return mime_parameters
2640
+
2641
+ def _find_mime_parameters(tokenlist, value):
2642
+ """Do our best to find the parameters in an invalid MIME header
2643
+
2644
+ """
2645
+ while value and value[0] != ';':
2646
+ if value[0] in PHRASE_ENDS:
2647
+ tokenlist.append(ValueTerminal(value[0], 'misplaced-special'))
2648
+ value = value[1:]
2649
+ else:
2650
+ token, value = get_phrase(value)
2651
+ tokenlist.append(token)
2652
+ if not value:
2653
+ return
2654
+ tokenlist.append(ValueTerminal(';', 'parameter-separator'))
2655
+ tokenlist.append(parse_mime_parameters(value[1:]))
2656
+
2657
+ def parse_content_type_header(value):
2658
+ """ maintype "/" subtype *( ";" parameter )
2659
+
2660
+ The maintype and substype are tokens. Theoretically they could
2661
+ be checked against the official IANA list + x-token, but we
2662
+ don't do that.
2663
+ """
2664
+ ctype = ContentType()
2665
+ if not value:
2666
+ ctype.defects.append(errors.HeaderMissingRequiredValue(
2667
+ "Missing content type specification"))
2668
+ return ctype
2669
+ try:
2670
+ token, value = get_token(value)
2671
+ except errors.HeaderParseError:
2672
+ ctype.defects.append(errors.InvalidHeaderDefect(
2673
+ "Expected content maintype but found {!r}".format(value)))
2674
+ _find_mime_parameters(ctype, value)
2675
+ return ctype
2676
+ ctype.append(token)
2677
+ # XXX: If we really want to follow the formal grammar we should make
2678
+ # mantype and subtype specialized TokenLists here. Probably not worth it.
2679
+ if not value or value[0] != '/':
2680
+ ctype.defects.append(errors.InvalidHeaderDefect(
2681
+ "Invalid content type"))
2682
+ if value:
2683
+ _find_mime_parameters(ctype, value)
2684
+ return ctype
2685
+ ctype.maintype = token.value.strip().lower()
2686
+ ctype.append(ValueTerminal('/', 'content-type-separator'))
2687
+ value = value[1:]
2688
+ try:
2689
+ token, value = get_token(value)
2690
+ except errors.HeaderParseError:
2691
+ ctype.defects.append(errors.InvalidHeaderDefect(
2692
+ "Expected content subtype but found {!r}".format(value)))
2693
+ _find_mime_parameters(ctype, value)
2694
+ return ctype
2695
+ ctype.append(token)
2696
+ ctype.subtype = token.value.strip().lower()
2697
+ if not value:
2698
+ return ctype
2699
+ if value[0] != ';':
2700
+ ctype.defects.append(errors.InvalidHeaderDefect(
2701
+ "Only parameters are valid after content type, but "
2702
+ "found {!r}".format(value)))
2703
+ # The RFC requires that a syntactically invalid content-type be treated
2704
+ # as text/plain. Perhaps we should postel this, but we should probably
2705
+ # only do that if we were checking the subtype value against IANA.
2706
+ del ctype.maintype, ctype.subtype
2707
+ _find_mime_parameters(ctype, value)
2708
+ return ctype
2709
+ ctype.append(ValueTerminal(';', 'parameter-separator'))
2710
+ ctype.append(parse_mime_parameters(value[1:]))
2711
+ return ctype
2712
+
2713
+ def parse_content_disposition_header(value):
2714
+ """ disposition-type *( ";" parameter )
2715
+
2716
+ """
2717
+ disp_header = ContentDisposition()
2718
+ if not value:
2719
+ disp_header.defects.append(errors.HeaderMissingRequiredValue(
2720
+ "Missing content disposition"))
2721
+ return disp_header
2722
+ try:
2723
+ token, value = get_token(value)
2724
+ except errors.HeaderParseError:
2725
+ disp_header.defects.append(errors.InvalidHeaderDefect(
2726
+ "Expected content disposition but found {!r}".format(value)))
2727
+ _find_mime_parameters(disp_header, value)
2728
+ return disp_header
2729
+ disp_header.append(token)
2730
+ disp_header.content_disposition = token.value.strip().lower()
2731
+ if not value:
2732
+ return disp_header
2733
+ if value[0] != ';':
2734
+ disp_header.defects.append(errors.InvalidHeaderDefect(
2735
+ "Only parameters are valid after content disposition, but "
2736
+ "found {!r}".format(value)))
2737
+ _find_mime_parameters(disp_header, value)
2738
+ return disp_header
2739
+ disp_header.append(ValueTerminal(';', 'parameter-separator'))
2740
+ disp_header.append(parse_mime_parameters(value[1:]))
2741
+ return disp_header
2742
+
2743
+ def parse_content_transfer_encoding_header(value):
2744
+ """ mechanism
2745
+
2746
+ """
2747
+ # We should probably validate the values, since the list is fixed.
2748
+ cte_header = ContentTransferEncoding()
2749
+ if not value:
2750
+ cte_header.defects.append(errors.HeaderMissingRequiredValue(
2751
+ "Missing content transfer encoding"))
2752
+ return cte_header
2753
+ try:
2754
+ token, value = get_token(value)
2755
+ except errors.HeaderParseError:
2756
+ cte_header.defects.append(errors.InvalidHeaderDefect(
2757
+ "Expected content transfer encoding but found {!r}".format(value)))
2758
+ else:
2759
+ cte_header.append(token)
2760
+ cte_header.cte = token.value.strip().lower()
2761
+ if not value:
2762
+ return cte_header
2763
+ while value:
2764
+ cte_header.defects.append(errors.InvalidHeaderDefect(
2765
+ "Extra text after content transfer encoding"))
2766
+ if value[0] in PHRASE_ENDS:
2767
+ cte_header.append(ValueTerminal(value[0], 'misplaced-special'))
2768
+ value = value[1:]
2769
+ else:
2770
+ token, value = get_phrase(value)
2771
+ cte_header.append(token)
2772
+ return cte_header
2773
+
2774
+
2775
+ #
2776
+ # Header folding
2777
+ #
2778
+ # Header folding is complex, with lots of rules and corner cases. The
2779
+ # following code does its best to obey the rules and handle the corner
2780
+ # cases, but you can be sure there are few bugs:)
2781
+ #
2782
+ # This folder generally canonicalizes as it goes, preferring the stringified
2783
+ # version of each token. The tokens contain information that supports the
2784
+ # folder, including which tokens can be encoded in which ways.
2785
+ #
2786
+ # Folded text is accumulated in a simple list of strings ('lines'), each
2787
+ # one of which should be less than policy.max_line_length ('maxlen').
2788
+ #
2789
+
2790
+ def _steal_trailing_WSP_if_exists(lines):
2791
+ wsp = ''
2792
+ if lines and lines[-1] and lines[-1][-1] in WSP:
2793
+ wsp = lines[-1][-1]
2794
+ lines[-1] = lines[-1][:-1]
2795
+ return wsp
2796
+
2797
+ def _refold_parse_tree(parse_tree, *, policy):
2798
+ """Return string of contents of parse_tree folded according to RFC rules.
2799
+
2800
+ """
2801
+ # max_line_length 0/None means no limit, ie: infinitely long.
2802
+ maxlen = policy.max_line_length or sys.maxsize
2803
+ encoding = 'utf-8' if policy.utf8 else 'us-ascii'
2804
+ lines = [''] # Folded lines to be output
2805
+ leading_whitespace = '' # When we have whitespace between two encoded
2806
+ # words, we may need to encode the whitespace
2807
+ # at the beginning of the second word.
2808
+ last_ew = None # Points to the last encoded character if there's an ew on
2809
+ # the line
2810
+ last_charset = None
2811
+ wrap_as_ew_blocked = 0
2812
+ want_encoding = False # This is set to True if we need to encode this part
2813
+ end_ew_not_allowed = Terminal('', 'wrap_as_ew_blocked')
2814
+ parts = list(parse_tree)
2815
+ while parts:
2816
+ part = parts.pop(0)
2817
+ if part is end_ew_not_allowed:
2818
+ wrap_as_ew_blocked -= 1
2819
+ continue
2820
+ tstr = str(part)
2821
+ if not want_encoding:
2822
+ if part.token_type in ('ptext', 'vtext'):
2823
+ # Encode if tstr contains special characters.
2824
+ want_encoding = not SPECIALSNL.isdisjoint(tstr)
2825
+ else:
2826
+ # Encode if tstr contains newlines.
2827
+ want_encoding = not NLSET.isdisjoint(tstr)
2828
+ try:
2829
+ tstr.encode(encoding)
2830
+ charset = encoding
2831
+ except UnicodeEncodeError:
2832
+ if any(isinstance(x, errors.UndecodableBytesDefect)
2833
+ for x in part.all_defects):
2834
+ charset = 'unknown-8bit'
2835
+ else:
2836
+ # If policy.utf8 is false this should really be taken from a
2837
+ # 'charset' property on the policy.
2838
+ charset = 'utf-8'
2839
+ want_encoding = True
2840
+
2841
+ if part.token_type == 'mime-parameters':
2842
+ # Mime parameter folding (using RFC2231) is extra special.
2843
+ _fold_mime_parameters(part, lines, maxlen, encoding)
2844
+ continue
2845
+
2846
+ if want_encoding and not wrap_as_ew_blocked:
2847
+ if not part.as_ew_allowed:
2848
+ want_encoding = False
2849
+ last_ew = None
2850
+ if part.syntactic_break:
2851
+ encoded_part = part.fold(policy=policy)[:-len(policy.linesep)]
2852
+ if policy.linesep not in encoded_part:
2853
+ # It fits on a single line
2854
+ if len(encoded_part) > maxlen - len(lines[-1]):
2855
+ # But not on this one, so start a new one.
2856
+ newline = _steal_trailing_WSP_if_exists(lines)
2857
+ # XXX what if encoded_part has no leading FWS?
2858
+ lines.append(newline)
2859
+ lines[-1] += encoded_part
2860
+ continue
2861
+ # Either this is not a major syntactic break, so we don't
2862
+ # want it on a line by itself even if it fits, or it
2863
+ # doesn't fit on a line by itself. Either way, fall through
2864
+ # to unpacking the subparts and wrapping them.
2865
+ if not hasattr(part, 'encode'):
2866
+ # It's not a Terminal, do each piece individually.
2867
+ parts = list(part) + parts
2868
+ want_encoding = False
2869
+ continue
2870
+ elif part.as_ew_allowed:
2871
+ # It's a terminal, wrap it as an encoded word, possibly
2872
+ # combining it with previously encoded words if allowed.
2873
+ if (last_ew is not None and
2874
+ charset != last_charset and
2875
+ (last_charset == 'unknown-8bit' or
2876
+ last_charset == 'utf-8' and charset != 'us-ascii')):
2877
+ last_ew = None
2878
+ last_ew = _fold_as_ew(tstr, lines, maxlen, last_ew,
2879
+ part.ew_combine_allowed, charset, leading_whitespace)
2880
+ # This whitespace has been added to the lines in _fold_as_ew()
2881
+ # so clear it now.
2882
+ leading_whitespace = ''
2883
+ last_charset = charset
2884
+ want_encoding = False
2885
+ continue
2886
+ else:
2887
+ # It's a terminal which should be kept non-encoded
2888
+ # (e.g. a ListSeparator).
2889
+ last_ew = None
2890
+ want_encoding = False
2891
+ # fall through
2892
+
2893
+ if len(tstr) <= maxlen - len(lines[-1]):
2894
+ lines[-1] += tstr
2895
+ continue
2896
+
2897
+ # This part is too long to fit. The RFC wants us to break at
2898
+ # "major syntactic breaks", so unless we don't consider this
2899
+ # to be one, check if it will fit on the next line by itself.
2900
+ leading_whitespace = ''
2901
+ if (part.syntactic_break and
2902
+ len(tstr) + 1 <= maxlen):
2903
+ newline = _steal_trailing_WSP_if_exists(lines)
2904
+ if newline or part.startswith_fws():
2905
+ # We're going to fold the data onto a new line here. Due to
2906
+ # the way encoded strings handle continuation lines, we need to
2907
+ # be prepared to encode any whitespace if the next line turns
2908
+ # out to start with an encoded word.
2909
+ lines.append(newline + tstr)
2910
+
2911
+ whitespace_accumulator = []
2912
+ for char in lines[-1]:
2913
+ if char not in WSP:
2914
+ break
2915
+ whitespace_accumulator.append(char)
2916
+ leading_whitespace = ''.join(whitespace_accumulator)
2917
+ last_ew = None
2918
+ continue
2919
+ if not hasattr(part, 'encode'):
2920
+ # It's not a terminal, try folding the subparts.
2921
+ newparts = list(part)
2922
+ if part.token_type == 'bare-quoted-string':
2923
+ # To fold a quoted string we need to create a list of terminal
2924
+ # tokens that will render the leading and trailing quotes
2925
+ # and use quoted pairs in the value as appropriate.
2926
+ newparts = (
2927
+ [ValueTerminal('"', 'ptext')] +
2928
+ [ValueTerminal(make_quoted_pairs(p), 'ptext')
2929
+ for p in newparts] +
2930
+ [ValueTerminal('"', 'ptext')])
2931
+ if part.token_type == 'comment':
2932
+ newparts = (
2933
+ [ValueTerminal('(', 'ptext')] +
2934
+ [ValueTerminal(make_parenthesis_pairs(p), 'ptext')
2935
+ if p.token_type == 'ptext' else p
2936
+ for p in newparts] +
2937
+ [ValueTerminal(')', 'ptext')])
2938
+ if not part.as_ew_allowed:
2939
+ wrap_as_ew_blocked += 1
2940
+ newparts.append(end_ew_not_allowed)
2941
+ parts = newparts + parts
2942
+ continue
2943
+ if part.as_ew_allowed and not wrap_as_ew_blocked:
2944
+ # It doesn't need CTE encoding, but encode it anyway so we can
2945
+ # wrap it.
2946
+ parts.insert(0, part)
2947
+ want_encoding = True
2948
+ continue
2949
+ # We can't figure out how to wrap, it, so give up.
2950
+ newline = _steal_trailing_WSP_if_exists(lines)
2951
+ if newline or part.startswith_fws():
2952
+ lines.append(newline + tstr)
2953
+ else:
2954
+ # We can't fold it onto the next line either...
2955
+ lines[-1] += tstr
2956
+
2957
+ return policy.linesep.join(lines) + policy.linesep
2958
+
2959
+ def _fold_as_ew(to_encode, lines, maxlen, last_ew, ew_combine_allowed, charset, leading_whitespace):
2960
+ """Fold string to_encode into lines as encoded word, combining if allowed.
2961
+ Return the new value for last_ew, or None if ew_combine_allowed is False.
2962
+
2963
+ If there is already an encoded word in the last line of lines (indicated by
2964
+ a non-None value for last_ew) and ew_combine_allowed is true, decode the
2965
+ existing ew, combine it with to_encode, and re-encode. Otherwise, encode
2966
+ to_encode. In either case, split to_encode as necessary so that the
2967
+ encoded segments fit within maxlen.
2968
+
2969
+ """
2970
+ if last_ew is not None and ew_combine_allowed:
2971
+ to_encode = str(
2972
+ get_unstructured(lines[-1][last_ew:] + to_encode))
2973
+ lines[-1] = lines[-1][:last_ew]
2974
+ elif to_encode[0] in WSP:
2975
+ # We're joining this to non-encoded text, so don't encode
2976
+ # the leading blank.
2977
+ leading_wsp = to_encode[0]
2978
+ to_encode = to_encode[1:]
2979
+ if (len(lines[-1]) == maxlen):
2980
+ lines.append(_steal_trailing_WSP_if_exists(lines))
2981
+ lines[-1] += leading_wsp
2982
+
2983
+ trailing_wsp = ''
2984
+ if to_encode[-1] in WSP:
2985
+ # Likewise for the trailing space.
2986
+ trailing_wsp = to_encode[-1]
2987
+ to_encode = to_encode[:-1]
2988
+ new_last_ew = len(lines[-1]) if last_ew is None else last_ew
2989
+
2990
+ encode_as = 'utf-8' if charset == 'us-ascii' else charset
2991
+
2992
+ # The RFC2047 chrome takes up 7 characters plus the length
2993
+ # of the charset name.
2994
+ chrome_len = len(encode_as) + 7
2995
+
2996
+ if (chrome_len + 1) >= maxlen:
2997
+ raise errors.HeaderParseError(
2998
+ "max_line_length is too small to fit an encoded word")
2999
+
3000
+ while to_encode:
3001
+ remaining_space = maxlen - len(lines[-1])
3002
+ text_space = remaining_space - chrome_len - len(leading_whitespace)
3003
+ if text_space <= 0:
3004
+ lines.append(' ')
3005
+ continue
3006
+
3007
+ # If we are at the start of a continuation line, prepend whitespace
3008
+ # (we only want to do this when the line starts with an encoded word
3009
+ # but if we're folding in this helper function, then we know that we
3010
+ # are going to be writing out an encoded word.)
3011
+ if len(lines) > 1 and len(lines[-1]) == 1 and leading_whitespace:
3012
+ encoded_word = _ew.encode(leading_whitespace, charset=encode_as)
3013
+ lines[-1] += encoded_word
3014
+ leading_whitespace = ''
3015
+
3016
+ to_encode_word = to_encode[:text_space]
3017
+ encoded_word = _ew.encode(to_encode_word, charset=encode_as)
3018
+ excess = len(encoded_word) - remaining_space
3019
+ while excess > 0:
3020
+ # Since the chunk to encode is guaranteed to fit into less than 100 characters,
3021
+ # shrinking it by one at a time shouldn't take long.
3022
+ to_encode_word = to_encode_word[:-1]
3023
+ encoded_word = _ew.encode(to_encode_word, charset=encode_as)
3024
+ excess = len(encoded_word) - remaining_space
3025
+ lines[-1] += encoded_word
3026
+ to_encode = to_encode[len(to_encode_word):]
3027
+ leading_whitespace = ''
3028
+
3029
+ if to_encode:
3030
+ lines.append(' ')
3031
+ new_last_ew = len(lines[-1])
3032
+ lines[-1] += trailing_wsp
3033
+ return new_last_ew if ew_combine_allowed else None
3034
+
3035
+ def _fold_mime_parameters(part, lines, maxlen, encoding):
3036
+ """Fold TokenList 'part' into the 'lines' list as mime parameters.
3037
+
3038
+ Using the decoded list of parameters and values, format them according to
3039
+ the RFC rules, including using RFC2231 encoding if the value cannot be
3040
+ expressed in 'encoding' and/or the parameter+value is too long to fit
3041
+ within 'maxlen'.
3042
+
3043
+ """
3044
+ # Special case for RFC2231 encoding: start from decoded values and use
3045
+ # RFC2231 encoding iff needed.
3046
+ #
3047
+ # Note that the 1 and 2s being added to the length calculations are
3048
+ # accounting for the possibly-needed spaces and semicolons we'll be adding.
3049
+ #
3050
+ for name, value in part.params:
3051
+ # XXX What if this ';' puts us over maxlen the first time through the
3052
+ # loop? We should split the header value onto a newline in that case,
3053
+ # but to do that we need to recognize the need earlier or reparse the
3054
+ # header, so I'm going to ignore that bug for now. It'll only put us
3055
+ # one character over.
3056
+ if not lines[-1].rstrip().endswith(';'):
3057
+ lines[-1] += ';'
3058
+ charset = encoding
3059
+ error_handler = 'strict'
3060
+ try:
3061
+ value.encode(encoding)
3062
+ encoding_required = False
3063
+ except UnicodeEncodeError:
3064
+ encoding_required = True
3065
+ if utils._has_surrogates(value):
3066
+ charset = 'unknown-8bit'
3067
+ error_handler = 'surrogateescape'
3068
+ else:
3069
+ charset = 'utf-8'
3070
+ if encoding_required:
3071
+ encoded_value = urllib.parse.quote(
3072
+ value, safe='', errors=error_handler)
3073
+ tstr = "{}*={}''{}".format(name, charset, encoded_value)
3074
+ else:
3075
+ tstr = '{}={}'.format(name, quote_string(value))
3076
+ if len(lines[-1]) + len(tstr) + 1 < maxlen:
3077
+ lines[-1] = lines[-1] + ' ' + tstr
3078
+ continue
3079
+ elif len(tstr) + 2 <= maxlen:
3080
+ lines.append(' ' + tstr)
3081
+ continue
3082
+ # We need multiple sections. We are allowed to mix encoded and
3083
+ # non-encoded sections, but we aren't going to. We'll encode them all.
3084
+ section = 0
3085
+ extra_chrome = charset + "''"
3086
+ while value:
3087
+ chrome_len = len(name) + len(str(section)) + 3 + len(extra_chrome)
3088
+ if maxlen <= chrome_len + 3:
3089
+ # We need room for the leading blank, the trailing semicolon,
3090
+ # and at least one character of the value. If we don't
3091
+ # have that, we'd be stuck, so in that case fall back to
3092
+ # the RFC standard width.
3093
+ maxlen = 78
3094
+ splitpoint = maxchars = maxlen - chrome_len - 2
3095
+ while True:
3096
+ partial = value[:splitpoint]
3097
+ encoded_value = urllib.parse.quote(
3098
+ partial, safe='', errors=error_handler)
3099
+ if len(encoded_value) <= maxchars:
3100
+ break
3101
+ splitpoint -= 1
3102
+ lines.append(" {}*{}*={}{}".format(
3103
+ name, section, extra_chrome, encoded_value))
3104
+ extra_chrome = ''
3105
+ section += 1
3106
+ value = value[splitpoint:]
3107
+ if value:
3108
+ lines[-1] += ';'