@rowstile/cli-linux-x64 0.1.0-alpha.2

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 (565) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +5 -0
  3. package/package.json +26 -0
  4. package/python/bin/python3.13 +0 -0
  5. package/python/bin/python3.13-config +122 -0
  6. package/python/lib/libpython3.13.so.1.0 +0 -0
  7. package/python/lib/libpython3.so +0 -0
  8. package/python/lib/python3.13/LICENSE.txt +277 -0
  9. package/python/lib/python3.13/__future__.py +147 -0
  10. package/python/lib/python3.13/__hello__.py +16 -0
  11. package/python/lib/python3.13/_aix_support.py +108 -0
  12. package/python/lib/python3.13/_android_support.py +192 -0
  13. package/python/lib/python3.13/_apple_support.py +66 -0
  14. package/python/lib/python3.13/_collections_abc.py +1187 -0
  15. package/python/lib/python3.13/_colorize.py +119 -0
  16. package/python/lib/python3.13/_compat_pickle.py +251 -0
  17. package/python/lib/python3.13/_compression.py +162 -0
  18. package/python/lib/python3.13/_ios_support.py +71 -0
  19. package/python/lib/python3.13/_markupbase.py +396 -0
  20. package/python/lib/python3.13/_opcode_metadata.py +343 -0
  21. package/python/lib/python3.13/_osx_support.py +579 -0
  22. package/python/lib/python3.13/_py_abc.py +147 -0
  23. package/python/lib/python3.13/_pydatetime.py +2640 -0
  24. package/python/lib/python3.13/_pydecimal.py +6356 -0
  25. package/python/lib/python3.13/_pyio.py +2714 -0
  26. package/python/lib/python3.13/_pylong.py +363 -0
  27. package/python/lib/python3.13/_pyrepl/__init__.py +19 -0
  28. package/python/lib/python3.13/_pyrepl/__main__.py +10 -0
  29. package/python/lib/python3.13/_pyrepl/_minimal_curses.py +68 -0
  30. package/python/lib/python3.13/_pyrepl/_threading_handler.py +74 -0
  31. package/python/lib/python3.13/_pyrepl/base_eventqueue.py +110 -0
  32. package/python/lib/python3.13/_pyrepl/commands.py +492 -0
  33. package/python/lib/python3.13/_pyrepl/completing_reader.py +295 -0
  34. package/python/lib/python3.13/_pyrepl/console.py +229 -0
  35. package/python/lib/python3.13/_pyrepl/curses.py +33 -0
  36. package/python/lib/python3.13/_pyrepl/fancy_termios.py +82 -0
  37. package/python/lib/python3.13/_pyrepl/historical_reader.py +419 -0
  38. package/python/lib/python3.13/_pyrepl/input.py +114 -0
  39. package/python/lib/python3.13/_pyrepl/keymap.py +213 -0
  40. package/python/lib/python3.13/_pyrepl/main.py +59 -0
  41. package/python/lib/python3.13/_pyrepl/mypy.ini +29 -0
  42. package/python/lib/python3.13/_pyrepl/pager.py +175 -0
  43. package/python/lib/python3.13/_pyrepl/reader.py +764 -0
  44. package/python/lib/python3.13/_pyrepl/readline.py +599 -0
  45. package/python/lib/python3.13/_pyrepl/simple_interact.py +180 -0
  46. package/python/lib/python3.13/_pyrepl/trace.py +21 -0
  47. package/python/lib/python3.13/_pyrepl/types.py +10 -0
  48. package/python/lib/python3.13/_pyrepl/unix_console.py +852 -0
  49. package/python/lib/python3.13/_pyrepl/unix_eventqueue.py +76 -0
  50. package/python/lib/python3.13/_pyrepl/utils.py +83 -0
  51. package/python/lib/python3.13/_pyrepl/windows_console.py +687 -0
  52. package/python/lib/python3.13/_pyrepl/windows_eventqueue.py +42 -0
  53. package/python/lib/python3.13/_sitebuiltins.py +91 -0
  54. package/python/lib/python3.13/_strptime.py +800 -0
  55. package/python/lib/python3.13/_sysconfigdata__linux_x86_64-linux-gnu.py +1079 -0
  56. package/python/lib/python3.13/_threading_local.py +120 -0
  57. package/python/lib/python3.13/_weakrefset.py +205 -0
  58. package/python/lib/python3.13/abc.py +188 -0
  59. package/python/lib/python3.13/antigravity.py +17 -0
  60. package/python/lib/python3.13/argparse.py +2690 -0
  61. package/python/lib/python3.13/ast.py +1865 -0
  62. package/python/lib/python3.13/asyncio/__init__.py +47 -0
  63. package/python/lib/python3.13/asyncio/__main__.py +211 -0
  64. package/python/lib/python3.13/asyncio/base_events.py +2086 -0
  65. package/python/lib/python3.13/asyncio/base_futures.py +67 -0
  66. package/python/lib/python3.13/asyncio/base_subprocess.py +312 -0
  67. package/python/lib/python3.13/asyncio/base_tasks.py +94 -0
  68. package/python/lib/python3.13/asyncio/constants.py +41 -0
  69. package/python/lib/python3.13/asyncio/coroutines.py +109 -0
  70. package/python/lib/python3.13/asyncio/events.py +885 -0
  71. package/python/lib/python3.13/asyncio/exceptions.py +62 -0
  72. package/python/lib/python3.13/asyncio/format_helpers.py +84 -0
  73. package/python/lib/python3.13/asyncio/futures.py +425 -0
  74. package/python/lib/python3.13/asyncio/locks.py +617 -0
  75. package/python/lib/python3.13/asyncio/log.py +7 -0
  76. package/python/lib/python3.13/asyncio/mixins.py +21 -0
  77. package/python/lib/python3.13/asyncio/proactor_events.py +891 -0
  78. package/python/lib/python3.13/asyncio/protocols.py +216 -0
  79. package/python/lib/python3.13/asyncio/queues.py +309 -0
  80. package/python/lib/python3.13/asyncio/runners.py +217 -0
  81. package/python/lib/python3.13/asyncio/selector_events.py +1328 -0
  82. package/python/lib/python3.13/asyncio/sslproto.py +929 -0
  83. package/python/lib/python3.13/asyncio/staggered.py +174 -0
  84. package/python/lib/python3.13/asyncio/streams.py +787 -0
  85. package/python/lib/python3.13/asyncio/subprocess.py +229 -0
  86. package/python/lib/python3.13/asyncio/taskgroups.py +278 -0
  87. package/python/lib/python3.13/asyncio/tasks.py +1121 -0
  88. package/python/lib/python3.13/asyncio/threads.py +26 -0
  89. package/python/lib/python3.13/asyncio/timeouts.py +185 -0
  90. package/python/lib/python3.13/asyncio/transports.py +337 -0
  91. package/python/lib/python3.13/asyncio/trsock.py +98 -0
  92. package/python/lib/python3.13/asyncio/unix_events.py +1550 -0
  93. package/python/lib/python3.13/asyncio/windows_events.py +906 -0
  94. package/python/lib/python3.13/asyncio/windows_utils.py +181 -0
  95. package/python/lib/python3.13/base64.py +628 -0
  96. package/python/lib/python3.13/bdb.py +973 -0
  97. package/python/lib/python3.13/bisect.py +118 -0
  98. package/python/lib/python3.13/bz2.py +352 -0
  99. package/python/lib/python3.13/cProfile.py +197 -0
  100. package/python/lib/python3.13/calendar.py +813 -0
  101. package/python/lib/python3.13/cmd.py +409 -0
  102. package/python/lib/python3.13/code.py +386 -0
  103. package/python/lib/python3.13/codecs.py +1132 -0
  104. package/python/lib/python3.13/codeop.py +155 -0
  105. package/python/lib/python3.13/collections/__init__.py +1603 -0
  106. package/python/lib/python3.13/colorsys.py +166 -0
  107. package/python/lib/python3.13/compileall.py +470 -0
  108. package/python/lib/python3.13/concurrent/__init__.py +1 -0
  109. package/python/lib/python3.13/concurrent/futures/__init__.py +54 -0
  110. package/python/lib/python3.13/concurrent/futures/_base.py +660 -0
  111. package/python/lib/python3.13/concurrent/futures/process.py +892 -0
  112. package/python/lib/python3.13/concurrent/futures/thread.py +240 -0
  113. package/python/lib/python3.13/configparser.py +1396 -0
  114. package/python/lib/python3.13/contextlib.py +814 -0
  115. package/python/lib/python3.13/contextvars.py +4 -0
  116. package/python/lib/python3.13/copy.py +306 -0
  117. package/python/lib/python3.13/copyreg.py +217 -0
  118. package/python/lib/python3.13/csv.py +527 -0
  119. package/python/lib/python3.13/ctypes/__init__.py +605 -0
  120. package/python/lib/python3.13/ctypes/_aix.py +327 -0
  121. package/python/lib/python3.13/ctypes/_endian.py +78 -0
  122. package/python/lib/python3.13/ctypes/macholib/README.ctypes +7 -0
  123. package/python/lib/python3.13/ctypes/macholib/__init__.py +9 -0
  124. package/python/lib/python3.13/ctypes/macholib/dyld.py +165 -0
  125. package/python/lib/python3.13/ctypes/macholib/dylib.py +42 -0
  126. package/python/lib/python3.13/ctypes/macholib/fetch_macholib +2 -0
  127. package/python/lib/python3.13/ctypes/macholib/fetch_macholib.bat +1 -0
  128. package/python/lib/python3.13/ctypes/macholib/framework.py +42 -0
  129. package/python/lib/python3.13/ctypes/util.py +387 -0
  130. package/python/lib/python3.13/ctypes/wintypes.py +202 -0
  131. package/python/lib/python3.13/curses/__init__.py +101 -0
  132. package/python/lib/python3.13/curses/ascii.py +99 -0
  133. package/python/lib/python3.13/curses/has_key.py +192 -0
  134. package/python/lib/python3.13/curses/panel.py +6 -0
  135. package/python/lib/python3.13/curses/textpad.py +236 -0
  136. package/python/lib/python3.13/dataclasses.py +1679 -0
  137. package/python/lib/python3.13/datetime.py +9 -0
  138. package/python/lib/python3.13/dbm/__init__.py +194 -0
  139. package/python/lib/python3.13/dbm/dumb.py +319 -0
  140. package/python/lib/python3.13/dbm/gnu.py +3 -0
  141. package/python/lib/python3.13/dbm/ndbm.py +3 -0
  142. package/python/lib/python3.13/dbm/sqlite3.py +144 -0
  143. package/python/lib/python3.13/decimal.py +109 -0
  144. package/python/lib/python3.13/difflib.py +2058 -0
  145. package/python/lib/python3.13/dis.py +1075 -0
  146. package/python/lib/python3.13/doctest.py +2919 -0
  147. package/python/lib/python3.13/email/__init__.py +61 -0
  148. package/python/lib/python3.13/email/_encoded_words.py +233 -0
  149. package/python/lib/python3.13/email/_header_value_parser.py +3153 -0
  150. package/python/lib/python3.13/email/_parseaddr.py +563 -0
  151. package/python/lib/python3.13/email/_policybase.py +382 -0
  152. package/python/lib/python3.13/email/architecture.rst +216 -0
  153. package/python/lib/python3.13/email/base64mime.py +115 -0
  154. package/python/lib/python3.13/email/charset.py +396 -0
  155. package/python/lib/python3.13/email/contentmanager.py +254 -0
  156. package/python/lib/python3.13/email/encoders.py +65 -0
  157. package/python/lib/python3.13/email/errors.py +117 -0
  158. package/python/lib/python3.13/email/feedparser.py +536 -0
  159. package/python/lib/python3.13/email/generator.py +530 -0
  160. package/python/lib/python3.13/email/header.py +582 -0
  161. package/python/lib/python3.13/email/headerregistry.py +618 -0
  162. package/python/lib/python3.13/email/iterators.py +68 -0
  163. package/python/lib/python3.13/email/message.py +1217 -0
  164. package/python/lib/python3.13/email/mime/__init__.py +0 -0
  165. package/python/lib/python3.13/email/mime/application.py +37 -0
  166. package/python/lib/python3.13/email/mime/audio.py +97 -0
  167. package/python/lib/python3.13/email/mime/base.py +29 -0
  168. package/python/lib/python3.13/email/mime/image.py +152 -0
  169. package/python/lib/python3.13/email/mime/message.py +33 -0
  170. package/python/lib/python3.13/email/mime/multipart.py +47 -0
  171. package/python/lib/python3.13/email/mime/nonmultipart.py +21 -0
  172. package/python/lib/python3.13/email/mime/text.py +40 -0
  173. package/python/lib/python3.13/email/parser.py +127 -0
  174. package/python/lib/python3.13/email/policy.py +232 -0
  175. package/python/lib/python3.13/email/quoprimime.py +300 -0
  176. package/python/lib/python3.13/email/utils.py +497 -0
  177. package/python/lib/python3.13/encodings/__init__.py +179 -0
  178. package/python/lib/python3.13/encodings/__pycache__/__init__.cpython-313.pyc +0 -0
  179. package/python/lib/python3.13/encodings/__pycache__/aliases.cpython-313.pyc +0 -0
  180. package/python/lib/python3.13/encodings/__pycache__/utf_8.cpython-313.pyc +0 -0
  181. package/python/lib/python3.13/encodings/aliases.py +560 -0
  182. package/python/lib/python3.13/encodings/ascii.py +50 -0
  183. package/python/lib/python3.13/encodings/base64_codec.py +55 -0
  184. package/python/lib/python3.13/encodings/big5.py +39 -0
  185. package/python/lib/python3.13/encodings/big5hkscs.py +39 -0
  186. package/python/lib/python3.13/encodings/bz2_codec.py +78 -0
  187. package/python/lib/python3.13/encodings/charmap.py +69 -0
  188. package/python/lib/python3.13/encodings/cp037.py +307 -0
  189. package/python/lib/python3.13/encodings/cp1006.py +307 -0
  190. package/python/lib/python3.13/encodings/cp1026.py +307 -0
  191. package/python/lib/python3.13/encodings/cp1125.py +698 -0
  192. package/python/lib/python3.13/encodings/cp1140.py +307 -0
  193. package/python/lib/python3.13/encodings/cp1250.py +307 -0
  194. package/python/lib/python3.13/encodings/cp1251.py +307 -0
  195. package/python/lib/python3.13/encodings/cp1252.py +307 -0
  196. package/python/lib/python3.13/encodings/cp1253.py +307 -0
  197. package/python/lib/python3.13/encodings/cp1254.py +307 -0
  198. package/python/lib/python3.13/encodings/cp1255.py +307 -0
  199. package/python/lib/python3.13/encodings/cp1256.py +307 -0
  200. package/python/lib/python3.13/encodings/cp1257.py +307 -0
  201. package/python/lib/python3.13/encodings/cp1258.py +307 -0
  202. package/python/lib/python3.13/encodings/cp273.py +307 -0
  203. package/python/lib/python3.13/encodings/cp424.py +307 -0
  204. package/python/lib/python3.13/encodings/cp437.py +698 -0
  205. package/python/lib/python3.13/encodings/cp500.py +307 -0
  206. package/python/lib/python3.13/encodings/cp720.py +309 -0
  207. package/python/lib/python3.13/encodings/cp737.py +698 -0
  208. package/python/lib/python3.13/encodings/cp775.py +697 -0
  209. package/python/lib/python3.13/encodings/cp850.py +698 -0
  210. package/python/lib/python3.13/encodings/cp852.py +698 -0
  211. package/python/lib/python3.13/encodings/cp855.py +698 -0
  212. package/python/lib/python3.13/encodings/cp856.py +307 -0
  213. package/python/lib/python3.13/encodings/cp857.py +694 -0
  214. package/python/lib/python3.13/encodings/cp858.py +698 -0
  215. package/python/lib/python3.13/encodings/cp860.py +698 -0
  216. package/python/lib/python3.13/encodings/cp861.py +698 -0
  217. package/python/lib/python3.13/encodings/cp862.py +698 -0
  218. package/python/lib/python3.13/encodings/cp863.py +698 -0
  219. package/python/lib/python3.13/encodings/cp864.py +690 -0
  220. package/python/lib/python3.13/encodings/cp865.py +698 -0
  221. package/python/lib/python3.13/encodings/cp866.py +698 -0
  222. package/python/lib/python3.13/encodings/cp869.py +689 -0
  223. package/python/lib/python3.13/encodings/cp874.py +307 -0
  224. package/python/lib/python3.13/encodings/cp875.py +307 -0
  225. package/python/lib/python3.13/encodings/cp932.py +39 -0
  226. package/python/lib/python3.13/encodings/cp949.py +39 -0
  227. package/python/lib/python3.13/encodings/cp950.py +39 -0
  228. package/python/lib/python3.13/encodings/euc_jis_2004.py +39 -0
  229. package/python/lib/python3.13/encodings/euc_jisx0213.py +39 -0
  230. package/python/lib/python3.13/encodings/euc_jp.py +39 -0
  231. package/python/lib/python3.13/encodings/euc_kr.py +39 -0
  232. package/python/lib/python3.13/encodings/gb18030.py +39 -0
  233. package/python/lib/python3.13/encodings/gb2312.py +39 -0
  234. package/python/lib/python3.13/encodings/gbk.py +39 -0
  235. package/python/lib/python3.13/encodings/hex_codec.py +55 -0
  236. package/python/lib/python3.13/encodings/hp_roman8.py +314 -0
  237. package/python/lib/python3.13/encodings/hz.py +39 -0
  238. package/python/lib/python3.13/encodings/idna.py +387 -0
  239. package/python/lib/python3.13/encodings/iso2022_jp.py +39 -0
  240. package/python/lib/python3.13/encodings/iso2022_jp_1.py +39 -0
  241. package/python/lib/python3.13/encodings/iso2022_jp_2.py +39 -0
  242. package/python/lib/python3.13/encodings/iso2022_jp_2004.py +39 -0
  243. package/python/lib/python3.13/encodings/iso2022_jp_3.py +39 -0
  244. package/python/lib/python3.13/encodings/iso2022_jp_ext.py +39 -0
  245. package/python/lib/python3.13/encodings/iso2022_kr.py +39 -0
  246. package/python/lib/python3.13/encodings/iso8859_1.py +307 -0
  247. package/python/lib/python3.13/encodings/iso8859_10.py +307 -0
  248. package/python/lib/python3.13/encodings/iso8859_11.py +307 -0
  249. package/python/lib/python3.13/encodings/iso8859_13.py +307 -0
  250. package/python/lib/python3.13/encodings/iso8859_14.py +307 -0
  251. package/python/lib/python3.13/encodings/iso8859_15.py +307 -0
  252. package/python/lib/python3.13/encodings/iso8859_16.py +307 -0
  253. package/python/lib/python3.13/encodings/iso8859_2.py +307 -0
  254. package/python/lib/python3.13/encodings/iso8859_3.py +307 -0
  255. package/python/lib/python3.13/encodings/iso8859_4.py +307 -0
  256. package/python/lib/python3.13/encodings/iso8859_5.py +307 -0
  257. package/python/lib/python3.13/encodings/iso8859_6.py +307 -0
  258. package/python/lib/python3.13/encodings/iso8859_7.py +307 -0
  259. package/python/lib/python3.13/encodings/iso8859_8.py +307 -0
  260. package/python/lib/python3.13/encodings/iso8859_9.py +307 -0
  261. package/python/lib/python3.13/encodings/johab.py +39 -0
  262. package/python/lib/python3.13/encodings/koi8_r.py +307 -0
  263. package/python/lib/python3.13/encodings/koi8_t.py +308 -0
  264. package/python/lib/python3.13/encodings/koi8_u.py +307 -0
  265. package/python/lib/python3.13/encodings/kz1048.py +307 -0
  266. package/python/lib/python3.13/encodings/latin_1.py +50 -0
  267. package/python/lib/python3.13/encodings/mac_arabic.py +698 -0
  268. package/python/lib/python3.13/encodings/mac_croatian.py +307 -0
  269. package/python/lib/python3.13/encodings/mac_cyrillic.py +307 -0
  270. package/python/lib/python3.13/encodings/mac_farsi.py +307 -0
  271. package/python/lib/python3.13/encodings/mac_greek.py +307 -0
  272. package/python/lib/python3.13/encodings/mac_iceland.py +307 -0
  273. package/python/lib/python3.13/encodings/mac_latin2.py +312 -0
  274. package/python/lib/python3.13/encodings/mac_roman.py +307 -0
  275. package/python/lib/python3.13/encodings/mac_romanian.py +307 -0
  276. package/python/lib/python3.13/encodings/mac_turkish.py +307 -0
  277. package/python/lib/python3.13/encodings/mbcs.py +47 -0
  278. package/python/lib/python3.13/encodings/oem.py +41 -0
  279. package/python/lib/python3.13/encodings/palmos.py +308 -0
  280. package/python/lib/python3.13/encodings/ptcp154.py +312 -0
  281. package/python/lib/python3.13/encodings/punycode.py +253 -0
  282. package/python/lib/python3.13/encodings/quopri_codec.py +56 -0
  283. package/python/lib/python3.13/encodings/raw_unicode_escape.py +46 -0
  284. package/python/lib/python3.13/encodings/rot_13.py +113 -0
  285. package/python/lib/python3.13/encodings/shift_jis.py +39 -0
  286. package/python/lib/python3.13/encodings/shift_jis_2004.py +39 -0
  287. package/python/lib/python3.13/encodings/shift_jisx0213.py +39 -0
  288. package/python/lib/python3.13/encodings/tis_620.py +307 -0
  289. package/python/lib/python3.13/encodings/undefined.py +49 -0
  290. package/python/lib/python3.13/encodings/unicode_escape.py +46 -0
  291. package/python/lib/python3.13/encodings/utf_16.py +155 -0
  292. package/python/lib/python3.13/encodings/utf_16_be.py +42 -0
  293. package/python/lib/python3.13/encodings/utf_16_le.py +42 -0
  294. package/python/lib/python3.13/encodings/utf_32.py +150 -0
  295. package/python/lib/python3.13/encodings/utf_32_be.py +37 -0
  296. package/python/lib/python3.13/encodings/utf_32_le.py +37 -0
  297. package/python/lib/python3.13/encodings/utf_7.py +38 -0
  298. package/python/lib/python3.13/encodings/utf_8.py +42 -0
  299. package/python/lib/python3.13/encodings/utf_8_sig.py +130 -0
  300. package/python/lib/python3.13/encodings/uu_codec.py +103 -0
  301. package/python/lib/python3.13/encodings/zlib_codec.py +77 -0
  302. package/python/lib/python3.13/enum.py +2183 -0
  303. package/python/lib/python3.13/filecmp.py +320 -0
  304. package/python/lib/python3.13/fileinput.py +442 -0
  305. package/python/lib/python3.13/fnmatch.py +192 -0
  306. package/python/lib/python3.13/fractions.py +1043 -0
  307. package/python/lib/python3.13/ftplib.py +975 -0
  308. package/python/lib/python3.13/functools.py +1036 -0
  309. package/python/lib/python3.13/genericpath.py +200 -0
  310. package/python/lib/python3.13/getopt.py +215 -0
  311. package/python/lib/python3.13/getpass.py +192 -0
  312. package/python/lib/python3.13/gettext.py +657 -0
  313. package/python/lib/python3.13/glob.py +572 -0
  314. package/python/lib/python3.13/graphlib.py +250 -0
  315. package/python/lib/python3.13/gzip.py +693 -0
  316. package/python/lib/python3.13/hashlib.py +255 -0
  317. package/python/lib/python3.13/heapq.py +603 -0
  318. package/python/lib/python3.13/hmac.py +220 -0
  319. package/python/lib/python3.13/html/__init__.py +132 -0
  320. package/python/lib/python3.13/html/entities.py +2513 -0
  321. package/python/lib/python3.13/html/parser.py +583 -0
  322. package/python/lib/python3.13/http/__init__.py +202 -0
  323. package/python/lib/python3.13/http/client.py +1598 -0
  324. package/python/lib/python3.13/http/cookiejar.py +2122 -0
  325. package/python/lib/python3.13/http/cookies.py +635 -0
  326. package/python/lib/python3.13/http/server.py +1355 -0
  327. package/python/lib/python3.13/imaplib.py +1769 -0
  328. package/python/lib/python3.13/importlib/__init__.py +136 -0
  329. package/python/lib/python3.13/importlib/_abc.py +39 -0
  330. package/python/lib/python3.13/importlib/_bootstrap.py +1559 -0
  331. package/python/lib/python3.13/importlib/_bootstrap_external.py +1826 -0
  332. package/python/lib/python3.13/importlib/abc.py +243 -0
  333. package/python/lib/python3.13/importlib/machinery.py +21 -0
  334. package/python/lib/python3.13/importlib/metadata/__init__.py +1093 -0
  335. package/python/lib/python3.13/importlib/metadata/_adapters.py +89 -0
  336. package/python/lib/python3.13/importlib/metadata/_collections.py +30 -0
  337. package/python/lib/python3.13/importlib/metadata/_functools.py +104 -0
  338. package/python/lib/python3.13/importlib/metadata/_itertools.py +73 -0
  339. package/python/lib/python3.13/importlib/metadata/_meta.py +67 -0
  340. package/python/lib/python3.13/importlib/metadata/_text.py +99 -0
  341. package/python/lib/python3.13/importlib/metadata/diagnose.py +21 -0
  342. package/python/lib/python3.13/importlib/readers.py +12 -0
  343. package/python/lib/python3.13/importlib/resources/__init__.py +43 -0
  344. package/python/lib/python3.13/importlib/resources/_adapters.py +168 -0
  345. package/python/lib/python3.13/importlib/resources/_common.py +211 -0
  346. package/python/lib/python3.13/importlib/resources/_functional.py +81 -0
  347. package/python/lib/python3.13/importlib/resources/_itertools.py +38 -0
  348. package/python/lib/python3.13/importlib/resources/abc.py +173 -0
  349. package/python/lib/python3.13/importlib/resources/readers.py +203 -0
  350. package/python/lib/python3.13/importlib/resources/simple.py +106 -0
  351. package/python/lib/python3.13/importlib/simple.py +14 -0
  352. package/python/lib/python3.13/importlib/util.py +274 -0
  353. package/python/lib/python3.13/inspect.py +3479 -0
  354. package/python/lib/python3.13/io.py +99 -0
  355. package/python/lib/python3.13/ipaddress.py +2440 -0
  356. package/python/lib/python3.13/json/__init__.py +365 -0
  357. package/python/lib/python3.13/json/decoder.py +364 -0
  358. package/python/lib/python3.13/json/encoder.py +446 -0
  359. package/python/lib/python3.13/json/scanner.py +73 -0
  360. package/python/lib/python3.13/json/tool.py +90 -0
  361. package/python/lib/python3.13/keyword.py +64 -0
  362. package/python/lib/python3.13/lib-dynload/.empty +0 -0
  363. package/python/lib/python3.13/lib-dynload/_dbm.cpython-313-x86_64-linux-gnu.so +0 -0
  364. package/python/lib/python3.13/linecache.py +236 -0
  365. package/python/lib/python3.13/locale.py +1987 -0
  366. package/python/lib/python3.13/logging/__init__.py +2330 -0
  367. package/python/lib/python3.13/logging/config.py +1080 -0
  368. package/python/lib/python3.13/logging/handlers.py +1629 -0
  369. package/python/lib/python3.13/lzma.py +364 -0
  370. package/python/lib/python3.13/mailbox.py +2219 -0
  371. package/python/lib/python3.13/mimetypes.py +679 -0
  372. package/python/lib/python3.13/modulefinder.py +671 -0
  373. package/python/lib/python3.13/multiprocessing/__init__.py +37 -0
  374. package/python/lib/python3.13/multiprocessing/connection.py +1216 -0
  375. package/python/lib/python3.13/multiprocessing/context.py +383 -0
  376. package/python/lib/python3.13/multiprocessing/dummy/__init__.py +126 -0
  377. package/python/lib/python3.13/multiprocessing/dummy/connection.py +75 -0
  378. package/python/lib/python3.13/multiprocessing/forkserver.py +373 -0
  379. package/python/lib/python3.13/multiprocessing/heap.py +337 -0
  380. package/python/lib/python3.13/multiprocessing/managers.py +1397 -0
  381. package/python/lib/python3.13/multiprocessing/pool.py +957 -0
  382. package/python/lib/python3.13/multiprocessing/popen_fork.py +97 -0
  383. package/python/lib/python3.13/multiprocessing/popen_forkserver.py +74 -0
  384. package/python/lib/python3.13/multiprocessing/popen_spawn_posix.py +76 -0
  385. package/python/lib/python3.13/multiprocessing/popen_spawn_win32.py +147 -0
  386. package/python/lib/python3.13/multiprocessing/process.py +436 -0
  387. package/python/lib/python3.13/multiprocessing/queues.py +399 -0
  388. package/python/lib/python3.13/multiprocessing/reduction.py +281 -0
  389. package/python/lib/python3.13/multiprocessing/resource_sharer.py +154 -0
  390. package/python/lib/python3.13/multiprocessing/resource_tracker.py +499 -0
  391. package/python/lib/python3.13/multiprocessing/shared_memory.py +544 -0
  392. package/python/lib/python3.13/multiprocessing/sharedctypes.py +240 -0
  393. package/python/lib/python3.13/multiprocessing/spawn.py +307 -0
  394. package/python/lib/python3.13/multiprocessing/synchronize.py +404 -0
  395. package/python/lib/python3.13/multiprocessing/util.py +562 -0
  396. package/python/lib/python3.13/netrc.py +199 -0
  397. package/python/lib/python3.13/ntpath.py +872 -0
  398. package/python/lib/python3.13/nturl2path.py +69 -0
  399. package/python/lib/python3.13/numbers.py +427 -0
  400. package/python/lib/python3.13/opcode.py +115 -0
  401. package/python/lib/python3.13/operator.py +467 -0
  402. package/python/lib/python3.13/optparse.py +1681 -0
  403. package/python/lib/python3.13/os.py +1184 -0
  404. package/python/lib/python3.13/pathlib/__init__.py +12 -0
  405. package/python/lib/python3.13/pathlib/_abc.py +930 -0
  406. package/python/lib/python3.13/pathlib/_local.py +861 -0
  407. package/python/lib/python3.13/pdb.py +2550 -0
  408. package/python/lib/python3.13/pickle.py +1860 -0
  409. package/python/lib/python3.13/pickletools.py +2904 -0
  410. package/python/lib/python3.13/pkgutil.py +529 -0
  411. package/python/lib/python3.13/platform.py +1454 -0
  412. package/python/lib/python3.13/plistlib.py +948 -0
  413. package/python/lib/python3.13/poplib.py +477 -0
  414. package/python/lib/python3.13/posixpath.py +578 -0
  415. package/python/lib/python3.13/pprint.py +658 -0
  416. package/python/lib/python3.13/profile.py +616 -0
  417. package/python/lib/python3.13/pstats.py +778 -0
  418. package/python/lib/python3.13/pty.py +211 -0
  419. package/python/lib/python3.13/py_compile.py +212 -0
  420. package/python/lib/python3.13/pyclbr.py +314 -0
  421. package/python/lib/python3.13/pydoc.py +2861 -0
  422. package/python/lib/python3.13/queue.py +383 -0
  423. package/python/lib/python3.13/quopri.py +237 -0
  424. package/python/lib/python3.13/random.py +1078 -0
  425. package/python/lib/python3.13/re/__init__.py +428 -0
  426. package/python/lib/python3.13/re/_casefix.py +106 -0
  427. package/python/lib/python3.13/re/_compiler.py +768 -0
  428. package/python/lib/python3.13/re/_constants.py +222 -0
  429. package/python/lib/python3.13/re/_parser.py +1081 -0
  430. package/python/lib/python3.13/reprlib.py +230 -0
  431. package/python/lib/python3.13/rlcompleter.py +222 -0
  432. package/python/lib/python3.13/runpy.py +326 -0
  433. package/python/lib/python3.13/sched.py +167 -0
  434. package/python/lib/python3.13/secrets.py +71 -0
  435. package/python/lib/python3.13/selectors.py +603 -0
  436. package/python/lib/python3.13/shelve.py +250 -0
  437. package/python/lib/python3.13/shlex.py +345 -0
  438. package/python/lib/python3.13/shutil.py +1569 -0
  439. package/python/lib/python3.13/signal.py +94 -0
  440. package/python/lib/python3.13/site.py +773 -0
  441. package/python/lib/python3.13/smtplib.py +1123 -0
  442. package/python/lib/python3.13/socket.py +988 -0
  443. package/python/lib/python3.13/socketserver.py +863 -0
  444. package/python/lib/python3.13/sqlite3/__init__.py +70 -0
  445. package/python/lib/python3.13/sqlite3/__main__.py +139 -0
  446. package/python/lib/python3.13/sqlite3/dbapi2.py +108 -0
  447. package/python/lib/python3.13/sqlite3/dump.py +118 -0
  448. package/python/lib/python3.13/sre_compile.py +7 -0
  449. package/python/lib/python3.13/sre_constants.py +7 -0
  450. package/python/lib/python3.13/sre_parse.py +7 -0
  451. package/python/lib/python3.13/ssl.py +1541 -0
  452. package/python/lib/python3.13/stat.py +212 -0
  453. package/python/lib/python3.13/statistics.py +1817 -0
  454. package/python/lib/python3.13/string.py +314 -0
  455. package/python/lib/python3.13/stringprep.py +272 -0
  456. package/python/lib/python3.13/struct.py +15 -0
  457. package/python/lib/python3.13/subprocess.py +2258 -0
  458. package/python/lib/python3.13/symtable.py +414 -0
  459. package/python/lib/python3.13/sysconfig/__init__.py +734 -0
  460. package/python/lib/python3.13/sysconfig/__main__.py +248 -0
  461. package/python/lib/python3.13/tabnanny.py +340 -0
  462. package/python/lib/python3.13/tarfile.py +3136 -0
  463. package/python/lib/python3.13/tempfile.py +958 -0
  464. package/python/lib/python3.13/textwrap.py +497 -0
  465. package/python/lib/python3.13/this.py +28 -0
  466. package/python/lib/python3.13/threading.py +1602 -0
  467. package/python/lib/python3.13/timeit.py +381 -0
  468. package/python/lib/python3.13/token.py +141 -0
  469. package/python/lib/python3.13/tokenize.py +592 -0
  470. package/python/lib/python3.13/tomllib/__init__.py +10 -0
  471. package/python/lib/python3.13/tomllib/_parser.py +703 -0
  472. package/python/lib/python3.13/tomllib/_re.py +107 -0
  473. package/python/lib/python3.13/tomllib/_types.py +10 -0
  474. package/python/lib/python3.13/tomllib/mypy.ini +15 -0
  475. package/python/lib/python3.13/trace.py +754 -0
  476. package/python/lib/python3.13/traceback.py +1639 -0
  477. package/python/lib/python3.13/tracemalloc.py +560 -0
  478. package/python/lib/python3.13/tty.py +73 -0
  479. package/python/lib/python3.13/types.py +346 -0
  480. package/python/lib/python3.13/typing.py +3846 -0
  481. package/python/lib/python3.13/unittest/__init__.py +80 -0
  482. package/python/lib/python3.13/unittest/__main__.py +18 -0
  483. package/python/lib/python3.13/unittest/_log.py +86 -0
  484. package/python/lib/python3.13/unittest/async_case.py +146 -0
  485. package/python/lib/python3.13/unittest/case.py +1478 -0
  486. package/python/lib/python3.13/unittest/loader.py +460 -0
  487. package/python/lib/python3.13/unittest/main.py +280 -0
  488. package/python/lib/python3.13/unittest/mock.py +3189 -0
  489. package/python/lib/python3.13/unittest/result.py +256 -0
  490. package/python/lib/python3.13/unittest/runner.py +292 -0
  491. package/python/lib/python3.13/unittest/signals.py +71 -0
  492. package/python/lib/python3.13/unittest/suite.py +379 -0
  493. package/python/lib/python3.13/unittest/util.py +170 -0
  494. package/python/lib/python3.13/urllib/__init__.py +0 -0
  495. package/python/lib/python3.13/urllib/error.py +74 -0
  496. package/python/lib/python3.13/urllib/parse.py +1264 -0
  497. package/python/lib/python3.13/urllib/request.py +2796 -0
  498. package/python/lib/python3.13/urllib/response.py +84 -0
  499. package/python/lib/python3.13/urllib/robotparser.py +363 -0
  500. package/python/lib/python3.13/uuid.py +784 -0
  501. package/python/lib/python3.13/warnings.py +735 -0
  502. package/python/lib/python3.13/wave.py +665 -0
  503. package/python/lib/python3.13/weakref.py +674 -0
  504. package/python/lib/python3.13/webbrowser.py +724 -0
  505. package/python/lib/python3.13/wsgiref/__init__.py +25 -0
  506. package/python/lib/python3.13/wsgiref/handlers.py +575 -0
  507. package/python/lib/python3.13/wsgiref/headers.py +192 -0
  508. package/python/lib/python3.13/wsgiref/simple_server.py +161 -0
  509. package/python/lib/python3.13/wsgiref/types.py +54 -0
  510. package/python/lib/python3.13/wsgiref/util.py +159 -0
  511. package/python/lib/python3.13/wsgiref/validate.py +438 -0
  512. package/python/lib/python3.13/xml/__init__.py +20 -0
  513. package/python/lib/python3.13/xml/dom/NodeFilter.py +27 -0
  514. package/python/lib/python3.13/xml/dom/__init__.py +140 -0
  515. package/python/lib/python3.13/xml/dom/domreg.py +99 -0
  516. package/python/lib/python3.13/xml/dom/expatbuilder.py +962 -0
  517. package/python/lib/python3.13/xml/dom/minicompat.py +109 -0
  518. package/python/lib/python3.13/xml/dom/minidom.py +2024 -0
  519. package/python/lib/python3.13/xml/dom/pulldom.py +336 -0
  520. package/python/lib/python3.13/xml/dom/xmlbuilder.py +389 -0
  521. package/python/lib/python3.13/xml/etree/ElementInclude.py +186 -0
  522. package/python/lib/python3.13/xml/etree/ElementPath.py +430 -0
  523. package/python/lib/python3.13/xml/etree/ElementTree.py +2116 -0
  524. package/python/lib/python3.13/xml/etree/__init__.py +33 -0
  525. package/python/lib/python3.13/xml/etree/cElementTree.py +3 -0
  526. package/python/lib/python3.13/xml/parsers/__init__.py +8 -0
  527. package/python/lib/python3.13/xml/parsers/expat.py +8 -0
  528. package/python/lib/python3.13/xml/sax/__init__.py +94 -0
  529. package/python/lib/python3.13/xml/sax/_exceptions.py +127 -0
  530. package/python/lib/python3.13/xml/sax/expatreader.py +454 -0
  531. package/python/lib/python3.13/xml/sax/handler.py +387 -0
  532. package/python/lib/python3.13/xml/sax/saxutils.py +369 -0
  533. package/python/lib/python3.13/xml/sax/xmlreader.py +378 -0
  534. package/python/lib/python3.13/xmlrpc/__init__.py +1 -0
  535. package/python/lib/python3.13/xmlrpc/client.py +1503 -0
  536. package/python/lib/python3.13/xmlrpc/server.py +1002 -0
  537. package/python/lib/python3.13/zipapp.py +229 -0
  538. package/python/lib/python3.13/zipfile/__init__.py +2391 -0
  539. package/python/lib/python3.13/zipfile/__main__.py +4 -0
  540. package/python/lib/python3.13/zipfile/_path/__init__.py +452 -0
  541. package/python/lib/python3.13/zipfile/_path/glob.py +113 -0
  542. package/python/lib/python3.13/zipimport.py +803 -0
  543. package/python/lib/python3.13/zoneinfo/__init__.py +34 -0
  544. package/python/lib/python3.13/zoneinfo/_common.py +172 -0
  545. package/python/lib/python3.13/zoneinfo/_tzpath.py +189 -0
  546. package/python/lib/python3.13/zoneinfo/_zoneinfo.py +779 -0
  547. package/python/licenses/LICENSE.bdb.txt +126 -0
  548. package/python/licenses/LICENSE.bzip2.txt +37 -0
  549. package/python/licenses/LICENSE.cpython.txt +771 -0
  550. package/python/licenses/LICENSE.expat.txt +21 -0
  551. package/python/licenses/LICENSE.libX11.txt +942 -0
  552. package/python/licenses/LICENSE.libXau.txt +21 -0
  553. package/python/licenses/LICENSE.libedit.txt +29 -0
  554. package/python/licenses/LICENSE.libffi.txt +21 -0
  555. package/python/licenses/LICENSE.liblzma.txt +13 -0
  556. package/python/licenses/LICENSE.libuuid.txt +27 -0
  557. package/python/licenses/LICENSE.libxcb.txt +30 -0
  558. package/python/licenses/LICENSE.mpdecimal.txt +24 -0
  559. package/python/licenses/LICENSE.ncurses.txt +29 -0
  560. package/python/licenses/LICENSE.openssl-1.1.txt +124 -0
  561. package/python/licenses/LICENSE.openssl-3.txt +177 -0
  562. package/python/licenses/LICENSE.sqlite.txt +23 -0
  563. package/python/licenses/LICENSE.tcl.txt +40 -0
  564. package/python/licenses/LICENSE.tix.txt +54 -0
  565. package/python/licenses/LICENSE.zlib.txt +21 -0
@@ -0,0 +1,779 @@
1
+ import bisect
2
+ import calendar
3
+ import collections
4
+ import functools
5
+ import re
6
+ import weakref
7
+ from datetime import datetime, timedelta, tzinfo
8
+
9
+ from . import _common, _tzpath
10
+
11
+ EPOCH = datetime(1970, 1, 1)
12
+ EPOCHORDINAL = datetime(1970, 1, 1).toordinal()
13
+
14
+ # It is relatively expensive to construct new timedelta objects, and in most
15
+ # cases we're looking at the same deltas, like integer numbers of hours, etc.
16
+ # To improve speed and memory use, we'll keep a dictionary with references
17
+ # to the ones we've already used so far.
18
+ #
19
+ # Loading every time zone in the 2020a version of the time zone database
20
+ # requires 447 timedeltas, which requires approximately the amount of space
21
+ # that ZoneInfo("America/New_York") with 236 transitions takes up, so we will
22
+ # set the cache size to 512 so that in the common case we always get cache
23
+ # hits, but specifically crafted ZoneInfo objects don't leak arbitrary amounts
24
+ # of memory.
25
+ @functools.lru_cache(maxsize=512)
26
+ def _load_timedelta(seconds):
27
+ return timedelta(seconds=seconds)
28
+
29
+
30
+ class ZoneInfo(tzinfo):
31
+ _strong_cache_size = 8
32
+ _strong_cache = collections.OrderedDict()
33
+ _weak_cache = weakref.WeakValueDictionary()
34
+ __module__ = "zoneinfo"
35
+
36
+ def __init_subclass__(cls):
37
+ cls._strong_cache = collections.OrderedDict()
38
+ cls._weak_cache = weakref.WeakValueDictionary()
39
+
40
+ def __new__(cls, key):
41
+ instance = cls._weak_cache.get(key, None)
42
+ if instance is None:
43
+ instance = cls._weak_cache.setdefault(key, cls._new_instance(key))
44
+ instance._from_cache = True
45
+
46
+ # Update the "strong" cache
47
+ cls._strong_cache[key] = cls._strong_cache.pop(key, instance)
48
+
49
+ if len(cls._strong_cache) > cls._strong_cache_size:
50
+ try:
51
+ cls._strong_cache.popitem(last=False)
52
+ except KeyError:
53
+ # another thread may have already emptied the cache
54
+ pass
55
+
56
+ return instance
57
+
58
+ @classmethod
59
+ def no_cache(cls, key):
60
+ obj = cls._new_instance(key)
61
+ obj._from_cache = False
62
+
63
+ return obj
64
+
65
+ @classmethod
66
+ def _new_instance(cls, key):
67
+ obj = super().__new__(cls)
68
+ obj._key = key
69
+ obj._file_path = obj._find_tzfile(key)
70
+
71
+ if obj._file_path is not None:
72
+ file_obj = open(obj._file_path, "rb")
73
+ else:
74
+ file_obj = _common.load_tzdata(key)
75
+
76
+ with file_obj as f:
77
+ obj._load_file(f)
78
+
79
+ return obj
80
+
81
+ @classmethod
82
+ def from_file(cls, file_obj, /, key=None):
83
+ obj = super().__new__(cls)
84
+ obj._key = key
85
+ obj._file_path = None
86
+ obj._load_file(file_obj)
87
+ obj._file_repr = repr(file_obj)
88
+
89
+ # Disable pickling for objects created from files
90
+ obj.__reduce__ = obj._file_reduce
91
+
92
+ return obj
93
+
94
+ @classmethod
95
+ def clear_cache(cls, *, only_keys=None):
96
+ if only_keys is not None:
97
+ for key in only_keys:
98
+ cls._weak_cache.pop(key, None)
99
+ cls._strong_cache.pop(key, None)
100
+
101
+ else:
102
+ cls._weak_cache.clear()
103
+ cls._strong_cache.clear()
104
+
105
+ @property
106
+ def key(self):
107
+ return self._key
108
+
109
+ def utcoffset(self, dt):
110
+ return self._find_trans(dt).utcoff
111
+
112
+ def dst(self, dt):
113
+ return self._find_trans(dt).dstoff
114
+
115
+ def tzname(self, dt):
116
+ return self._find_trans(dt).tzname
117
+
118
+ def fromutc(self, dt):
119
+ """Convert from datetime in UTC to datetime in local time"""
120
+
121
+ if not isinstance(dt, datetime):
122
+ raise TypeError("fromutc() requires a datetime argument")
123
+ if dt.tzinfo is not self:
124
+ raise ValueError("dt.tzinfo is not self")
125
+
126
+ timestamp = self._get_local_timestamp(dt)
127
+ num_trans = len(self._trans_utc)
128
+
129
+ if num_trans >= 1 and timestamp < self._trans_utc[0]:
130
+ tti = self._tti_before
131
+ fold = 0
132
+ elif (
133
+ num_trans == 0 or timestamp > self._trans_utc[-1]
134
+ ) and not isinstance(self._tz_after, _ttinfo):
135
+ tti, fold = self._tz_after.get_trans_info_fromutc(
136
+ timestamp, dt.year
137
+ )
138
+ elif num_trans == 0:
139
+ tti = self._tz_after
140
+ fold = 0
141
+ else:
142
+ idx = bisect.bisect_right(self._trans_utc, timestamp)
143
+
144
+ if num_trans > 1 and timestamp >= self._trans_utc[1]:
145
+ tti_prev, tti = self._ttinfos[idx - 2 : idx]
146
+ elif timestamp > self._trans_utc[-1]:
147
+ tti_prev = self._ttinfos[-1]
148
+ tti = self._tz_after
149
+ else:
150
+ tti_prev = self._tti_before
151
+ tti = self._ttinfos[0]
152
+
153
+ # Detect fold
154
+ shift = tti_prev.utcoff - tti.utcoff
155
+ fold = shift.total_seconds() > timestamp - self._trans_utc[idx - 1]
156
+ dt += tti.utcoff
157
+ if fold:
158
+ return dt.replace(fold=1)
159
+ else:
160
+ return dt
161
+
162
+ def _find_trans(self, dt):
163
+ if dt is None:
164
+ if self._fixed_offset:
165
+ return self._tz_after
166
+ else:
167
+ return _NO_TTINFO
168
+
169
+ ts = self._get_local_timestamp(dt)
170
+
171
+ lt = self._trans_local[dt.fold]
172
+
173
+ num_trans = len(lt)
174
+
175
+ if num_trans and ts < lt[0]:
176
+ return self._tti_before
177
+ elif not num_trans or ts > lt[-1]:
178
+ if isinstance(self._tz_after, _TZStr):
179
+ return self._tz_after.get_trans_info(ts, dt.year, dt.fold)
180
+ else:
181
+ return self._tz_after
182
+ else:
183
+ # idx is the transition that occurs after this timestamp, so we
184
+ # subtract off 1 to get the current ttinfo
185
+ idx = bisect.bisect_right(lt, ts) - 1
186
+ assert idx >= 0
187
+ return self._ttinfos[idx]
188
+
189
+ def _get_local_timestamp(self, dt):
190
+ return (
191
+ (dt.toordinal() - EPOCHORDINAL) * 86400
192
+ + dt.hour * 3600
193
+ + dt.minute * 60
194
+ + dt.second
195
+ )
196
+
197
+ def __str__(self):
198
+ if self._key is not None:
199
+ return f"{self._key}"
200
+ else:
201
+ return repr(self)
202
+
203
+ def __repr__(self):
204
+ if self._key is not None:
205
+ return f"{self.__class__.__name__}(key={self._key!r})"
206
+ else:
207
+ return f"{self.__class__.__name__}.from_file({self._file_repr})"
208
+
209
+ def __reduce__(self):
210
+ return (self.__class__._unpickle, (self._key, self._from_cache))
211
+
212
+ def _file_reduce(self):
213
+ import pickle
214
+
215
+ raise pickle.PicklingError(
216
+ "Cannot pickle a ZoneInfo file created from a file stream."
217
+ )
218
+
219
+ @classmethod
220
+ def _unpickle(cls, key, from_cache, /):
221
+ if from_cache:
222
+ return cls(key)
223
+ else:
224
+ return cls.no_cache(key)
225
+
226
+ def _find_tzfile(self, key):
227
+ return _tzpath.find_tzfile(key)
228
+
229
+ def _load_file(self, fobj):
230
+ # Retrieve all the data as it exists in the zoneinfo file
231
+ trans_idx, trans_utc, utcoff, isdst, abbr, tz_str = _common.load_data(
232
+ fobj
233
+ )
234
+
235
+ # Infer the DST offsets (needed for .dst()) from the data
236
+ dstoff = self._utcoff_to_dstoff(trans_idx, utcoff, isdst)
237
+
238
+ # Convert all the transition times (UTC) into "seconds since 1970-01-01 local time"
239
+ trans_local = self._ts_to_local(trans_idx, trans_utc, utcoff)
240
+
241
+ # Construct `_ttinfo` objects for each transition in the file
242
+ _ttinfo_list = [
243
+ _ttinfo(
244
+ _load_timedelta(utcoffset), _load_timedelta(dstoffset), tzname
245
+ )
246
+ for utcoffset, dstoffset, tzname in zip(utcoff, dstoff, abbr)
247
+ ]
248
+
249
+ self._trans_utc = trans_utc
250
+ self._trans_local = trans_local
251
+ self._ttinfos = [_ttinfo_list[idx] for idx in trans_idx]
252
+
253
+ # Find the first non-DST transition
254
+ for i in range(len(isdst)):
255
+ if not isdst[i]:
256
+ self._tti_before = _ttinfo_list[i]
257
+ break
258
+ else:
259
+ if self._ttinfos:
260
+ self._tti_before = self._ttinfos[0]
261
+ else:
262
+ self._tti_before = None
263
+
264
+ # Set the "fallback" time zone
265
+ if tz_str is not None and tz_str != b"":
266
+ self._tz_after = _parse_tz_str(tz_str.decode())
267
+ else:
268
+ if not self._ttinfos and not _ttinfo_list:
269
+ raise ValueError("No time zone information found.")
270
+
271
+ if self._ttinfos:
272
+ self._tz_after = self._ttinfos[-1]
273
+ else:
274
+ self._tz_after = _ttinfo_list[-1]
275
+
276
+ # Determine if this is a "fixed offset" zone, meaning that the output
277
+ # of the utcoffset, dst and tzname functions does not depend on the
278
+ # specific datetime passed.
279
+ #
280
+ # We make three simplifying assumptions here:
281
+ #
282
+ # 1. If _tz_after is not a _ttinfo, it has transitions that might
283
+ # actually occur (it is possible to construct TZ strings that
284
+ # specify STD and DST but no transitions ever occur, such as
285
+ # AAA0BBB,0/0,J365/25).
286
+ # 2. If _ttinfo_list contains more than one _ttinfo object, the objects
287
+ # represent different offsets.
288
+ # 3. _ttinfo_list contains no unused _ttinfos (in which case an
289
+ # otherwise fixed-offset zone with extra _ttinfos defined may
290
+ # appear to *not* be a fixed offset zone).
291
+ #
292
+ # Violations to these assumptions would be fairly exotic, and exotic
293
+ # zones should almost certainly not be used with datetime.time (the
294
+ # only thing that would be affected by this).
295
+ if len(_ttinfo_list) > 1 or not isinstance(self._tz_after, _ttinfo):
296
+ self._fixed_offset = False
297
+ elif not _ttinfo_list:
298
+ self._fixed_offset = True
299
+ else:
300
+ self._fixed_offset = _ttinfo_list[0] == self._tz_after
301
+
302
+ @staticmethod
303
+ def _utcoff_to_dstoff(trans_idx, utcoffsets, isdsts):
304
+ # Now we must transform our ttis and abbrs into `_ttinfo` objects,
305
+ # but there is an issue: .dst() must return a timedelta with the
306
+ # difference between utcoffset() and the "standard" offset, but
307
+ # the "base offset" and "DST offset" are not encoded in the file;
308
+ # we can infer what they are from the isdst flag, but it is not
309
+ # sufficient to just look at the last standard offset, because
310
+ # occasionally countries will shift both DST offset and base offset.
311
+
312
+ typecnt = len(isdsts)
313
+ dstoffs = [0] * typecnt # Provisionally assign all to 0.
314
+ dst_cnt = sum(isdsts)
315
+ dst_found = 0
316
+
317
+ for i in range(1, len(trans_idx)):
318
+ if dst_cnt == dst_found:
319
+ break
320
+
321
+ idx = trans_idx[i]
322
+
323
+ dst = isdsts[idx]
324
+
325
+ # We're only going to look at daylight saving time
326
+ if not dst:
327
+ continue
328
+
329
+ # Skip any offsets that have already been assigned
330
+ if dstoffs[idx] != 0:
331
+ continue
332
+
333
+ dstoff = 0
334
+ utcoff = utcoffsets[idx]
335
+
336
+ comp_idx = trans_idx[i - 1]
337
+
338
+ if not isdsts[comp_idx]:
339
+ dstoff = utcoff - utcoffsets[comp_idx]
340
+
341
+ if not dstoff and idx < (typecnt - 1) and i + 1 < len(trans_idx):
342
+ comp_idx = trans_idx[i + 1]
343
+
344
+ # If the following transition is also DST and we couldn't
345
+ # find the DST offset by this point, we're going to have to
346
+ # skip it and hope this transition gets assigned later
347
+ if isdsts[comp_idx]:
348
+ continue
349
+
350
+ dstoff = utcoff - utcoffsets[comp_idx]
351
+
352
+ if dstoff:
353
+ dst_found += 1
354
+ dstoffs[idx] = dstoff
355
+ else:
356
+ # If we didn't find a valid value for a given index, we'll end up
357
+ # with dstoff = 0 for something where `isdst=1`. This is obviously
358
+ # wrong - one hour will be a much better guess than 0
359
+ for idx in range(typecnt):
360
+ if not dstoffs[idx] and isdsts[idx]:
361
+ dstoffs[idx] = 3600
362
+
363
+ return dstoffs
364
+
365
+ @staticmethod
366
+ def _ts_to_local(trans_idx, trans_list_utc, utcoffsets):
367
+ """Generate number of seconds since 1970 *in the local time*.
368
+
369
+ This is necessary to easily find the transition times in local time"""
370
+ if not trans_list_utc:
371
+ return [[], []]
372
+
373
+ # Start with the timestamps and modify in-place
374
+ trans_list_wall = [list(trans_list_utc), list(trans_list_utc)]
375
+
376
+ if len(utcoffsets) > 1:
377
+ offset_0 = utcoffsets[0]
378
+ offset_1 = utcoffsets[trans_idx[0]]
379
+ if offset_1 > offset_0:
380
+ offset_1, offset_0 = offset_0, offset_1
381
+ else:
382
+ offset_0 = offset_1 = utcoffsets[0]
383
+
384
+ trans_list_wall[0][0] += offset_0
385
+ trans_list_wall[1][0] += offset_1
386
+
387
+ for i in range(1, len(trans_idx)):
388
+ offset_0 = utcoffsets[trans_idx[i - 1]]
389
+ offset_1 = utcoffsets[trans_idx[i]]
390
+
391
+ if offset_1 > offset_0:
392
+ offset_1, offset_0 = offset_0, offset_1
393
+
394
+ trans_list_wall[0][i] += offset_0
395
+ trans_list_wall[1][i] += offset_1
396
+
397
+ return trans_list_wall
398
+
399
+
400
+ class _ttinfo:
401
+ __slots__ = ["utcoff", "dstoff", "tzname"]
402
+
403
+ def __init__(self, utcoff, dstoff, tzname):
404
+ self.utcoff = utcoff
405
+ self.dstoff = dstoff
406
+ self.tzname = tzname
407
+
408
+ def __eq__(self, other):
409
+ return (
410
+ self.utcoff == other.utcoff
411
+ and self.dstoff == other.dstoff
412
+ and self.tzname == other.tzname
413
+ )
414
+
415
+ def __repr__(self): # pragma: nocover
416
+ return (
417
+ f"{self.__class__.__name__}"
418
+ + f"({self.utcoff}, {self.dstoff}, {self.tzname})"
419
+ )
420
+
421
+
422
+ _NO_TTINFO = _ttinfo(None, None, None)
423
+
424
+
425
+ class _TZStr:
426
+ __slots__ = (
427
+ "std",
428
+ "dst",
429
+ "start",
430
+ "end",
431
+ "get_trans_info",
432
+ "get_trans_info_fromutc",
433
+ "dst_diff",
434
+ )
435
+
436
+ def __init__(
437
+ self, std_abbr, std_offset, dst_abbr, dst_offset, start=None, end=None
438
+ ):
439
+ self.dst_diff = dst_offset - std_offset
440
+ std_offset = _load_timedelta(std_offset)
441
+ self.std = _ttinfo(
442
+ utcoff=std_offset, dstoff=_load_timedelta(0), tzname=std_abbr
443
+ )
444
+
445
+ self.start = start
446
+ self.end = end
447
+
448
+ dst_offset = _load_timedelta(dst_offset)
449
+ delta = _load_timedelta(self.dst_diff)
450
+ self.dst = _ttinfo(utcoff=dst_offset, dstoff=delta, tzname=dst_abbr)
451
+
452
+ # These are assertions because the constructor should only be called
453
+ # by functions that would fail before passing start or end
454
+ assert start is not None, "No transition start specified"
455
+ assert end is not None, "No transition end specified"
456
+
457
+ self.get_trans_info = self._get_trans_info
458
+ self.get_trans_info_fromutc = self._get_trans_info_fromutc
459
+
460
+ def transitions(self, year):
461
+ start = self.start.year_to_epoch(year)
462
+ end = self.end.year_to_epoch(year)
463
+ return start, end
464
+
465
+ def _get_trans_info(self, ts, year, fold):
466
+ """Get the information about the current transition - tti"""
467
+ start, end = self.transitions(year)
468
+
469
+ # With fold = 0, the period (denominated in local time) with the
470
+ # smaller offset starts at the end of the gap and ends at the end of
471
+ # the fold; with fold = 1, it runs from the start of the gap to the
472
+ # beginning of the fold.
473
+ #
474
+ # So in order to determine the DST boundaries we need to know both
475
+ # the fold and whether DST is positive or negative (rare), and it
476
+ # turns out that this boils down to fold XOR is_positive.
477
+ if fold == (self.dst_diff >= 0):
478
+ end -= self.dst_diff
479
+ else:
480
+ start += self.dst_diff
481
+
482
+ if start < end:
483
+ isdst = start <= ts < end
484
+ else:
485
+ isdst = not (end <= ts < start)
486
+
487
+ return self.dst if isdst else self.std
488
+
489
+ def _get_trans_info_fromutc(self, ts, year):
490
+ start, end = self.transitions(year)
491
+ start -= self.std.utcoff.total_seconds()
492
+ end -= self.dst.utcoff.total_seconds()
493
+
494
+ if start < end:
495
+ isdst = start <= ts < end
496
+ else:
497
+ isdst = not (end <= ts < start)
498
+
499
+ # For positive DST, the ambiguous period is one dst_diff after the end
500
+ # of DST; for negative DST, the ambiguous period is one dst_diff before
501
+ # the start of DST.
502
+ if self.dst_diff > 0:
503
+ ambig_start = end
504
+ ambig_end = end + self.dst_diff
505
+ else:
506
+ ambig_start = start
507
+ ambig_end = start - self.dst_diff
508
+
509
+ fold = ambig_start <= ts < ambig_end
510
+
511
+ return (self.dst if isdst else self.std, fold)
512
+
513
+
514
+ def _post_epoch_days_before_year(year):
515
+ """Get the number of days between 1970-01-01 and YEAR-01-01"""
516
+ y = year - 1
517
+ return y * 365 + y // 4 - y // 100 + y // 400 - EPOCHORDINAL
518
+
519
+
520
+ class _DayOffset:
521
+ __slots__ = ["d", "julian", "hour", "minute", "second"]
522
+
523
+ def __init__(self, d, julian, hour=2, minute=0, second=0):
524
+ min_day = 0 + julian # convert bool to int
525
+ if not min_day <= d <= 365:
526
+ raise ValueError(f"d must be in [{min_day}, 365], not: {d}")
527
+
528
+ self.d = d
529
+ self.julian = julian
530
+ self.hour = hour
531
+ self.minute = minute
532
+ self.second = second
533
+
534
+ def year_to_epoch(self, year):
535
+ days_before_year = _post_epoch_days_before_year(year)
536
+
537
+ d = self.d
538
+ if self.julian and d >= 59 and calendar.isleap(year):
539
+ d += 1
540
+
541
+ epoch = (days_before_year + d) * 86400
542
+ epoch += self.hour * 3600 + self.minute * 60 + self.second
543
+
544
+ return epoch
545
+
546
+
547
+ class _CalendarOffset:
548
+ __slots__ = ["m", "w", "d", "hour", "minute", "second"]
549
+
550
+ _DAYS_BEFORE_MONTH = (
551
+ -1,
552
+ 0,
553
+ 31,
554
+ 59,
555
+ 90,
556
+ 120,
557
+ 151,
558
+ 181,
559
+ 212,
560
+ 243,
561
+ 273,
562
+ 304,
563
+ 334,
564
+ )
565
+
566
+ def __init__(self, m, w, d, hour=2, minute=0, second=0):
567
+ if not 1 <= m <= 12:
568
+ raise ValueError("m must be in [1, 12]")
569
+
570
+ if not 1 <= w <= 5:
571
+ raise ValueError("w must be in [1, 5]")
572
+
573
+ if not 0 <= d <= 6:
574
+ raise ValueError("d must be in [0, 6]")
575
+
576
+ self.m = m
577
+ self.w = w
578
+ self.d = d
579
+ self.hour = hour
580
+ self.minute = minute
581
+ self.second = second
582
+
583
+ @classmethod
584
+ def _ymd2ord(cls, year, month, day):
585
+ return (
586
+ _post_epoch_days_before_year(year)
587
+ + cls._DAYS_BEFORE_MONTH[month]
588
+ + (month > 2 and calendar.isleap(year))
589
+ + day
590
+ )
591
+
592
+ # TODO: These are not actually epoch dates as they are expressed in local time
593
+ def year_to_epoch(self, year):
594
+ """Calculates the datetime of the occurrence from the year"""
595
+ # We know year and month, we need to convert w, d into day of month
596
+ #
597
+ # Week 1 is the first week in which day `d` (where 0 = Sunday) appears.
598
+ # Week 5 represents the last occurrence of day `d`, so we need to know
599
+ # the range of the month.
600
+ first_day, days_in_month = calendar.monthrange(year, self.m)
601
+
602
+ # This equation seems magical, so I'll break it down:
603
+ # 1. calendar says 0 = Monday, POSIX says 0 = Sunday
604
+ # so we need first_day + 1 to get 1 = Monday -> 7 = Sunday,
605
+ # which is still equivalent because this math is mod 7
606
+ # 2. Get first day - desired day mod 7: -1 % 7 = 6, so we don't need
607
+ # to do anything to adjust negative numbers.
608
+ # 3. Add 1 because month days are a 1-based index.
609
+ month_day = (self.d - (first_day + 1)) % 7 + 1
610
+
611
+ # Now use a 0-based index version of `w` to calculate the w-th
612
+ # occurrence of `d`
613
+ month_day += (self.w - 1) * 7
614
+
615
+ # month_day will only be > days_in_month if w was 5, and `w` means
616
+ # "last occurrence of `d`", so now we just check if we over-shot the
617
+ # end of the month and if so knock off 1 week.
618
+ if month_day > days_in_month:
619
+ month_day -= 7
620
+
621
+ ordinal = self._ymd2ord(year, self.m, month_day)
622
+ epoch = ordinal * 86400
623
+ epoch += self.hour * 3600 + self.minute * 60 + self.second
624
+ return epoch
625
+
626
+
627
+ def _parse_tz_str(tz_str):
628
+ # The tz string has the format:
629
+ #
630
+ # std[offset[dst[offset],start[/time],end[/time]]]
631
+ #
632
+ # std and dst must be 3 or more characters long and must not contain
633
+ # a leading colon, embedded digits, commas, nor a plus or minus signs;
634
+ # The spaces between "std" and "offset" are only for display and are
635
+ # not actually present in the string.
636
+ #
637
+ # The format of the offset is ``[+|-]hh[:mm[:ss]]``
638
+
639
+ offset_str, *start_end_str = tz_str.split(",", 1)
640
+
641
+ parser_re = re.compile(
642
+ r"""
643
+ (?P<std>[a-zA-Z]+|<[a-zA-Z0-9+-]+>)
644
+ (?:
645
+ (?P<stdoff>[+-]?\d{1,3}(?::\d{2}(?::\d{2})?)?)
646
+ (?:
647
+ (?P<dst>[a-zA-Z]+|<[a-zA-Z0-9+-]+>)
648
+ (?P<dstoff>[+-]?\d{1,3}(?::\d{2}(?::\d{2})?)?)?
649
+ )? # dst
650
+ )? # stdoff
651
+ """,
652
+ re.ASCII|re.VERBOSE
653
+ )
654
+
655
+ m = parser_re.fullmatch(offset_str)
656
+
657
+ if m is None:
658
+ raise ValueError(f"{tz_str} is not a valid TZ string")
659
+
660
+ std_abbr = m.group("std")
661
+ dst_abbr = m.group("dst")
662
+ dst_offset = None
663
+
664
+ std_abbr = std_abbr.strip("<>")
665
+
666
+ if dst_abbr:
667
+ dst_abbr = dst_abbr.strip("<>")
668
+
669
+ if std_offset := m.group("stdoff"):
670
+ try:
671
+ std_offset = _parse_tz_delta(std_offset)
672
+ except ValueError as e:
673
+ raise ValueError(f"Invalid STD offset in {tz_str}") from e
674
+ else:
675
+ # The STD offset is required
676
+ raise ValueError(f"Invalid STD offset in {tz_str}")
677
+
678
+ if dst_abbr is not None:
679
+ if dst_offset := m.group("dstoff"):
680
+ try:
681
+ dst_offset = _parse_tz_delta(dst_offset)
682
+ except ValueError as e:
683
+ raise ValueError(f"Invalid DST offset in {tz_str}") from e
684
+ else:
685
+ dst_offset = std_offset + 3600
686
+
687
+ if not start_end_str:
688
+ raise ValueError(f"Missing transition rules: {tz_str}")
689
+
690
+ start_end_strs = start_end_str[0].split(",", 1)
691
+ try:
692
+ start, end = (_parse_dst_start_end(x) for x in start_end_strs)
693
+ except ValueError as e:
694
+ raise ValueError(f"Invalid TZ string: {tz_str}") from e
695
+
696
+ return _TZStr(std_abbr, std_offset, dst_abbr, dst_offset, start, end)
697
+ elif start_end_str:
698
+ raise ValueError(f"Transition rule present without DST: {tz_str}")
699
+ else:
700
+ # This is a static ttinfo, don't return _TZStr
701
+ return _ttinfo(
702
+ _load_timedelta(std_offset), _load_timedelta(0), std_abbr
703
+ )
704
+
705
+
706
+ def _parse_dst_start_end(dststr):
707
+ date, *time = dststr.split("/", 1)
708
+ type = date[:1]
709
+ if type == "M":
710
+ n_is_julian = False
711
+ m = re.fullmatch(r"M(\d{1,2})\.(\d)\.(\d)", date, re.ASCII)
712
+ if m is None:
713
+ raise ValueError(f"Invalid dst start/end date: {dststr}")
714
+ date_offset = tuple(map(int, m.groups()))
715
+ offset = _CalendarOffset(*date_offset)
716
+ else:
717
+ if type == "J":
718
+ n_is_julian = True
719
+ date = date[1:]
720
+ else:
721
+ n_is_julian = False
722
+
723
+ if re.fullmatch(r"\d{1,3}", date, re.ASCII) is None:
724
+ raise ValueError(f"Invalid dst start/end date: {dststr}")
725
+ doy = int(date)
726
+ offset = _DayOffset(doy, n_is_julian)
727
+
728
+ if time:
729
+ offset.hour, offset.minute, offset.second = _parse_transition_time(time[0])
730
+
731
+ return offset
732
+
733
+
734
+ def _parse_transition_time(time_str):
735
+ match = re.fullmatch(
736
+ r"(?P<sign>[+-])?(?P<h>\d{1,3})(:(?P<m>\d{2})(:(?P<s>\d{2}))?)?",
737
+ time_str,
738
+ re.ASCII
739
+ )
740
+ if match is None:
741
+ raise ValueError(f"Invalid time: {time_str}")
742
+
743
+ h, m, s = (int(v or 0) for v in match.group("h", "m", "s"))
744
+
745
+ if h > 167:
746
+ raise ValueError(
747
+ f"Hour must be in [0, 167]: {time_str}"
748
+ )
749
+
750
+ if match.group("sign") == "-":
751
+ h, m, s = -h, -m, -s
752
+
753
+ return h, m, s
754
+
755
+
756
+ def _parse_tz_delta(tz_delta):
757
+ match = re.fullmatch(
758
+ r"(?P<sign>[+-])?(?P<h>\d{1,3})(:(?P<m>\d{2})(:(?P<s>\d{2}))?)?",
759
+ tz_delta,
760
+ re.ASCII
761
+ )
762
+ # Anything passed to this function should already have hit an equivalent
763
+ # regular expression to find the section to parse.
764
+ assert match is not None, tz_delta
765
+
766
+ h, m, s = (int(v or 0) for v in match.group("h", "m", "s"))
767
+
768
+ total = h * 3600 + m * 60 + s
769
+
770
+ if h > 24:
771
+ raise ValueError(
772
+ f"Offset hours must be in [0, 24]: {tz_delta}"
773
+ )
774
+
775
+ # Yes, +5 maps to an offset of -5h
776
+ if match.group("sign") != "-":
777
+ total = -total
778
+
779
+ return total