matplotlib-rs 0.0.8__cp315-cp315-win_amd64.whl

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 (352) hide show
  1. docs/releases/0.0.1.md +268 -0
  2. docs/releases/0.0.2.md +69 -0
  3. docs/releases/0.0.3.md +80 -0
  4. docs/releases/0.0.4.md +73 -0
  5. docs/releases/0.0.5.md +24 -0
  6. docs/releases/0.0.6.md +24 -0
  7. docs/releases/0.0.7.md +24 -0
  8. docs/releases/0.0.8.md +16 -0
  9. licenses/LICENSE_CONTOURPY +29 -0
  10. licenses/LICENSE_CYCLER +27 -0
  11. licenses/LICENSE_DATEUTIL +54 -0
  12. licenses/LICENSE_KIWISOLVER +71 -0
  13. licenses/LICENSE_LIBWEBP +56 -0
  14. licenses/LICENSE_MATPLOTLIB +1253 -0
  15. licenses/LICENSE_PYPARSING +20 -0
  16. licenses/LICENSE_QHULL +39 -0
  17. licenses/LICENSE_SIX +18 -0
  18. matplotlib_rs/__init__.py +1683 -0
  19. matplotlib_rs/__main__.py +27 -0
  20. matplotlib_rs/_afm.py +500 -0
  21. matplotlib_rs/_animation_data.py +263 -0
  22. matplotlib_rs/_api/__init__.py +495 -0
  23. matplotlib_rs/_api/deprecation.py +534 -0
  24. matplotlib_rs/_axis_py.py +2991 -0
  25. matplotlib_rs/_blocking_input.py +31 -0
  26. matplotlib_rs/_cm.py +1500 -0
  27. matplotlib_rs/_cm_bivar.py +1289 -0
  28. matplotlib_rs/_cm_listed.py +2848 -0
  29. matplotlib_rs/_cm_multivar.py +167 -0
  30. matplotlib_rs/_color_data.py +1142 -0
  31. matplotlib_rs/_colormap.py +132 -0
  32. matplotlib_rs/_constrained_layout.py +825 -0
  33. matplotlib_rs/_contour.py +108 -0
  34. matplotlib_rs/_doc_cache.py +12214 -0
  35. matplotlib_rs/_docstring.py +142 -0
  36. matplotlib_rs/_enums.py +178 -0
  37. matplotlib_rs/_figure_rs.py +294 -0
  38. matplotlib_rs/_fontconfig_pattern.py +129 -0
  39. matplotlib_rs/_foreign.py +220 -0
  40. matplotlib_rs/_hook.py +94 -0
  41. matplotlib_rs/_image.py +160 -0
  42. matplotlib_rs/_imageio.py +229 -0
  43. matplotlib_rs/_internal_utils.py +65 -0
  44. matplotlib_rs/_kiwi.py +484 -0
  45. matplotlib_rs/_layoutgrid.py +549 -0
  46. matplotlib_rs/_live.py +192 -0
  47. matplotlib_rs/_mathtext.py +3103 -0
  48. matplotlib_rs/_mathtext_data.py +1811 -0
  49. matplotlib_rs/_mplrs.cp315-win_amd64.pyd +0 -0
  50. matplotlib_rs/_path.py +25 -0
  51. matplotlib_rs/_png.py +162 -0
  52. matplotlib_rs/_pylab_helpers.py +137 -0
  53. matplotlib_rs/_qhull.py +66 -0
  54. matplotlib_rs/_rcpush.py +84 -0
  55. matplotlib_rs/_spines_rs.py +108 -0
  56. matplotlib_rs/_style_helpers.py +52 -0
  57. matplotlib_rs/_text_helpers.py +51 -0
  58. matplotlib_rs/_tight_bbox.py +85 -0
  59. matplotlib_rs/_tight_layout.py +302 -0
  60. matplotlib_rs/_tri.py +140 -0
  61. matplotlib_rs/_type1font.py +1228 -0
  62. matplotlib_rs/_vendor/__init__.py +8 -0
  63. matplotlib_rs/_vendor/cycler.py +574 -0
  64. matplotlib_rs/_vendor/dateutil/__init__.py +27 -0
  65. matplotlib_rs/_vendor/dateutil/_common.py +44 -0
  66. matplotlib_rs/_vendor/dateutil/_tzdata_impl.py +148 -0
  67. matplotlib_rs/_vendor/dateutil/_version.py +5 -0
  68. matplotlib_rs/_vendor/dateutil/easter.py +90 -0
  69. matplotlib_rs/_vendor/dateutil/parser/__init__.py +62 -0
  70. matplotlib_rs/_vendor/dateutil/parser/_parser.py +1614 -0
  71. matplotlib_rs/_vendor/dateutil/parser/isoparser.py +417 -0
  72. matplotlib_rs/_vendor/dateutil/relativedelta.py +597 -0
  73. matplotlib_rs/_vendor/dateutil/rrule.py +1765 -0
  74. matplotlib_rs/_vendor/dateutil/tz/__init__.py +61 -0
  75. matplotlib_rs/_vendor/dateutil/tz/_common.py +420 -0
  76. matplotlib_rs/_vendor/dateutil/tz/_factories.py +81 -0
  77. matplotlib_rs/_vendor/dateutil/tz/_tzfile.py +1429 -0
  78. matplotlib_rs/_vendor/dateutil/tz/_tzpath.py +105 -0
  79. matplotlib_rs/_vendor/dateutil/tz/tz.py +1473 -0
  80. matplotlib_rs/_vendor/dateutil/tz/win.py +371 -0
  81. matplotlib_rs/_vendor/dateutil/tzwin.py +3 -0
  82. matplotlib_rs/_vendor/dateutil/utils.py +72 -0
  83. matplotlib_rs/_vendor/dateutil/zoneinfo/__init__.py +234 -0
  84. matplotlib_rs/_vendor/pyparsing/__init__.py +414 -0
  85. matplotlib_rs/_vendor/pyparsing/actions.py +265 -0
  86. matplotlib_rs/_vendor/pyparsing/common.py +571 -0
  87. matplotlib_rs/_vendor/pyparsing/core.py +6973 -0
  88. matplotlib_rs/_vendor/pyparsing/exceptions.py +354 -0
  89. matplotlib_rs/_vendor/pyparsing/helpers.py +1770 -0
  90. matplotlib_rs/_vendor/pyparsing/results.py +929 -0
  91. matplotlib_rs/_vendor/pyparsing/testing.py +399 -0
  92. matplotlib_rs/_vendor/pyparsing/unicode.py +357 -0
  93. matplotlib_rs/_vendor/pyparsing/util.py +515 -0
  94. matplotlib_rs/_vendor/pyparsing/warnings.py +11 -0
  95. matplotlib_rs/_vendor/six.py +1004 -0
  96. matplotlib_rs/animation.py +1843 -0
  97. matplotlib_rs/artist.py +2302 -0
  98. matplotlib_rs/axes/__init__.py +19 -0
  99. matplotlib_rs/axes/_axes.py +9402 -0
  100. matplotlib_rs/axes/_bar.py +185 -0
  101. matplotlib_rs/axes/_base.py +5236 -0
  102. matplotlib_rs/axes/_base_rs.py +727 -0
  103. matplotlib_rs/axes/_boxplot.py +391 -0
  104. matplotlib_rs/axes/_hist.py +99 -0
  105. matplotlib_rs/axes/_secondary_axes.py +357 -0
  106. matplotlib_rs/axis.py +1963 -0
  107. matplotlib_rs/backend_bases.py +3760 -0
  108. matplotlib_rs/backend_managers.py +388 -0
  109. matplotlib_rs/backend_tools.py +1002 -0
  110. matplotlib_rs/backends/__init__.py +6 -0
  111. matplotlib_rs/backends/_backend_pdf_ps.py +451 -0
  112. matplotlib_rs/backends/backend_agg.py +552 -0
  113. matplotlib_rs/backends/backend_mixed.py +123 -0
  114. matplotlib_rs/backends/backend_pdf.py +2711 -0
  115. matplotlib_rs/backends/backend_pgf.py +1031 -0
  116. matplotlib_rs/backends/backend_ps.py +1491 -0
  117. matplotlib_rs/backends/backend_svg.py +1395 -0
  118. matplotlib_rs/backends/backend_template.py +214 -0
  119. matplotlib_rs/backends/registry.py +423 -0
  120. matplotlib_rs/bezier.py +691 -0
  121. matplotlib_rs/category.py +236 -0
  122. matplotlib_rs/cbook.py +2762 -0
  123. matplotlib_rs/cm.py +251 -0
  124. matplotlib_rs/collections.py +2711 -0
  125. matplotlib_rs/colorbar.py +1586 -0
  126. matplotlib_rs/colorizer.py +909 -0
  127. matplotlib_rs/colors.py +4278 -0
  128. matplotlib_rs/container.py +256 -0
  129. matplotlib_rs/contour.py +1756 -0
  130. matplotlib_rs/dates.py +1847 -0
  131. matplotlib_rs/dviread.py +1386 -0
  132. matplotlib_rs/figure.py +3815 -0
  133. matplotlib_rs/font_manager.py +1855 -0
  134. matplotlib_rs/ft2font.py +515 -0
  135. matplotlib_rs/gridspec.py +808 -0
  136. matplotlib_rs/hatch.py +244 -0
  137. matplotlib_rs/image.py +1863 -0
  138. matplotlib_rs/inset.py +291 -0
  139. matplotlib_rs/layout_engine.py +310 -0
  140. matplotlib_rs/legend.py +1480 -0
  141. matplotlib_rs/legend_handler.py +812 -0
  142. matplotlib_rs/lines.py +1886 -0
  143. matplotlib_rs/markers.py +908 -0
  144. matplotlib_rs/mathtext.py +141 -0
  145. matplotlib_rs/mlab.py +959 -0
  146. matplotlib_rs/mpl-data/fonts/ttf/DejaVuSans-Bold.ttf +0 -0
  147. matplotlib_rs/mpl-data/fonts/ttf/DejaVuSans-BoldOblique.ttf +0 -0
  148. matplotlib_rs/mpl-data/fonts/ttf/DejaVuSans-Oblique.ttf +0 -0
  149. matplotlib_rs/mpl-data/fonts/ttf/DejaVuSans.ttf +0 -0
  150. matplotlib_rs/mpl-data/fonts/ttf/DejaVuSansDisplay.ttf +0 -0
  151. matplotlib_rs/mpl-data/fonts/ttf/DejaVuSansMono-Bold.ttf +0 -0
  152. matplotlib_rs/mpl-data/fonts/ttf/DejaVuSansMono-BoldOblique.ttf +0 -0
  153. matplotlib_rs/mpl-data/fonts/ttf/DejaVuSansMono-Oblique.ttf +0 -0
  154. matplotlib_rs/mpl-data/fonts/ttf/DejaVuSansMono.ttf +0 -0
  155. matplotlib_rs/mpl-data/fonts/ttf/DejaVuSerif-Bold.ttf +0 -0
  156. matplotlib_rs/mpl-data/fonts/ttf/DejaVuSerif-BoldItalic.ttf +0 -0
  157. matplotlib_rs/mpl-data/fonts/ttf/DejaVuSerif-Italic.ttf +0 -0
  158. matplotlib_rs/mpl-data/fonts/ttf/DejaVuSerif.ttf +0 -0
  159. matplotlib_rs/mpl-data/fonts/ttf/DejaVuSerifDisplay.ttf +0 -0
  160. matplotlib_rs/mpl-data/fonts/ttf/LICENSE_DEJAVU +99 -0
  161. matplotlib_rs/mpl-data/fonts/ttf/LICENSE_STIX +124 -0
  162. matplotlib_rs/mpl-data/fonts/ttf/LastResortHE-Regular.ttf +0 -0
  163. matplotlib_rs/mpl-data/fonts/ttf/STIXGeneral.ttf +0 -0
  164. matplotlib_rs/mpl-data/fonts/ttf/STIXGeneralBol.ttf +0 -0
  165. matplotlib_rs/mpl-data/fonts/ttf/STIXGeneralBolIta.ttf +0 -0
  166. matplotlib_rs/mpl-data/fonts/ttf/STIXGeneralItalic.ttf +0 -0
  167. matplotlib_rs/mpl-data/fonts/ttf/STIXNonUni.ttf +0 -0
  168. matplotlib_rs/mpl-data/fonts/ttf/STIXNonUniBol.ttf +0 -0
  169. matplotlib_rs/mpl-data/fonts/ttf/STIXNonUniBolIta.ttf +0 -0
  170. matplotlib_rs/mpl-data/fonts/ttf/STIXNonUniIta.ttf +0 -0
  171. matplotlib_rs/mpl-data/fonts/ttf/STIXSizFiveSymReg.ttf +0 -0
  172. matplotlib_rs/mpl-data/fonts/ttf/STIXSizFourSymBol.ttf +0 -0
  173. matplotlib_rs/mpl-data/fonts/ttf/STIXSizFourSymReg.ttf +0 -0
  174. matplotlib_rs/mpl-data/fonts/ttf/STIXSizOneSymBol.ttf +0 -0
  175. matplotlib_rs/mpl-data/fonts/ttf/STIXSizOneSymReg.ttf +0 -0
  176. matplotlib_rs/mpl-data/fonts/ttf/STIXSizThreeSymBol.ttf +0 -0
  177. matplotlib_rs/mpl-data/fonts/ttf/STIXSizThreeSymReg.ttf +0 -0
  178. matplotlib_rs/mpl-data/fonts/ttf/STIXSizTwoSymBol.ttf +0 -0
  179. matplotlib_rs/mpl-data/fonts/ttf/STIXSizTwoSymReg.ttf +0 -0
  180. matplotlib_rs/mpl-data/fonts/ttf/cmb10.ttf +0 -0
  181. matplotlib_rs/mpl-data/fonts/ttf/cmex10.ttf +0 -0
  182. matplotlib_rs/mpl-data/fonts/ttf/cmmi10.ttf +0 -0
  183. matplotlib_rs/mpl-data/fonts/ttf/cmr10.ttf +0 -0
  184. matplotlib_rs/mpl-data/fonts/ttf/cmss10.ttf +0 -0
  185. matplotlib_rs/mpl-data/fonts/ttf/cmsy10.ttf +0 -0
  186. matplotlib_rs/mpl-data/fonts/ttf/cmti10.ttf +0 -0
  187. matplotlib_rs/mpl-data/fonts/ttf/cmtt10.ttf +0 -0
  188. matplotlib_rs/mpl-data/images/back-symbolic.svg +46 -0
  189. matplotlib_rs/mpl-data/images/back.pdf +0 -0
  190. matplotlib_rs/mpl-data/images/back.png +0 -0
  191. matplotlib_rs/mpl-data/images/back.svg +46 -0
  192. matplotlib_rs/mpl-data/images/back_large.png +0 -0
  193. matplotlib_rs/mpl-data/images/filesave-symbolic.svg +68 -0
  194. matplotlib_rs/mpl-data/images/filesave.pdf +72 -0
  195. matplotlib_rs/mpl-data/images/filesave.png +0 -0
  196. matplotlib_rs/mpl-data/images/filesave.svg +68 -0
  197. matplotlib_rs/mpl-data/images/filesave_large.png +0 -0
  198. matplotlib_rs/mpl-data/images/forward-symbolic.svg +46 -0
  199. matplotlib_rs/mpl-data/images/forward.pdf +0 -0
  200. matplotlib_rs/mpl-data/images/forward.png +0 -0
  201. matplotlib_rs/mpl-data/images/forward.svg +46 -0
  202. matplotlib_rs/mpl-data/images/forward_large.png +0 -0
  203. matplotlib_rs/mpl-data/images/hand.pdf +0 -0
  204. matplotlib_rs/mpl-data/images/hand.png +0 -0
  205. matplotlib_rs/mpl-data/images/hand.svg +130 -0
  206. matplotlib_rs/mpl-data/images/help-symbolic.svg +52 -0
  207. matplotlib_rs/mpl-data/images/help.pdf +71 -0
  208. matplotlib_rs/mpl-data/images/help.png +0 -0
  209. matplotlib_rs/mpl-data/images/help.svg +52 -0
  210. matplotlib_rs/mpl-data/images/help_large.png +0 -0
  211. matplotlib_rs/mpl-data/images/home-symbolic.svg +59 -0
  212. matplotlib_rs/mpl-data/images/home.pdf +0 -0
  213. matplotlib_rs/mpl-data/images/home.png +0 -0
  214. matplotlib_rs/mpl-data/images/home.svg +59 -0
  215. matplotlib_rs/mpl-data/images/home_large.png +0 -0
  216. matplotlib_rs/mpl-data/images/matplotlib.pdf +0 -0
  217. matplotlib_rs/mpl-data/images/matplotlib.png +0 -0
  218. matplotlib_rs/mpl-data/images/matplotlib.svg +3171 -0
  219. matplotlib_rs/mpl-data/images/matplotlib_large.png +0 -0
  220. matplotlib_rs/mpl-data/images/move-symbolic.svg +73 -0
  221. matplotlib_rs/mpl-data/images/move.pdf +0 -0
  222. matplotlib_rs/mpl-data/images/move.png +0 -0
  223. matplotlib_rs/mpl-data/images/move.svg +73 -0
  224. matplotlib_rs/mpl-data/images/move_large.png +0 -0
  225. matplotlib_rs/mpl-data/images/qt4_editor_options.pdf +0 -0
  226. matplotlib_rs/mpl-data/images/qt4_editor_options.png +0 -0
  227. matplotlib_rs/mpl-data/images/qt4_editor_options.svg +48 -0
  228. matplotlib_rs/mpl-data/images/qt4_editor_options_large.png +0 -0
  229. matplotlib_rs/mpl-data/images/subplots-symbolic.svg +81 -0
  230. matplotlib_rs/mpl-data/images/subplots.pdf +0 -0
  231. matplotlib_rs/mpl-data/images/subplots.png +0 -0
  232. matplotlib_rs/mpl-data/images/subplots.svg +81 -0
  233. matplotlib_rs/mpl-data/images/subplots_large.png +0 -0
  234. matplotlib_rs/mpl-data/images/zoom_to_rect-symbolic.svg +40 -0
  235. matplotlib_rs/mpl-data/images/zoom_to_rect.pdf +69 -0
  236. matplotlib_rs/mpl-data/images/zoom_to_rect.png +0 -0
  237. matplotlib_rs/mpl-data/images/zoom_to_rect.svg +40 -0
  238. matplotlib_rs/mpl-data/images/zoom_to_rect_large.png +0 -0
  239. matplotlib_rs/mpl-data/kpsewhich.lua +4 -0
  240. matplotlib_rs/mpl-data/matplotlibrc +849 -0
  241. matplotlib_rs/mpl-data/plot_directive/plot_directive.css +16 -0
  242. matplotlib_rs/mpl-data/sample_data/Minduka_Present_Blue_Pack.png +0 -0
  243. matplotlib_rs/mpl-data/sample_data/README.txt +2 -0
  244. matplotlib_rs/mpl-data/sample_data/Stocks.csv +526 -0
  245. matplotlib_rs/mpl-data/sample_data/axes_grid/bivariate_normal.npy +0 -0
  246. matplotlib_rs/mpl-data/sample_data/data_x_x2_x3.csv +11 -0
  247. matplotlib_rs/mpl-data/sample_data/eeg.dat +0 -0
  248. matplotlib_rs/mpl-data/sample_data/embedding_in_wx3.xrc +65 -0
  249. matplotlib_rs/mpl-data/sample_data/goog.npz +0 -0
  250. matplotlib_rs/mpl-data/sample_data/grace_hopper.jpg +0 -0
  251. matplotlib_rs/mpl-data/sample_data/jacksboro_fault_dem.npz +0 -0
  252. matplotlib_rs/mpl-data/sample_data/logo2.png +0 -0
  253. matplotlib_rs/mpl-data/sample_data/membrane.dat +0 -0
  254. matplotlib_rs/mpl-data/sample_data/msft.csv +66 -0
  255. matplotlib_rs/mpl-data/sample_data/s1045.ima.gz +0 -0
  256. matplotlib_rs/mpl-data/sample_data/topobathy.npz +0 -0
  257. matplotlib_rs/mpl-data/stylelib/Solarize_Light2.mplstyle +53 -0
  258. matplotlib_rs/mpl-data/stylelib/_classic_test_patch.mplstyle +8 -0
  259. matplotlib_rs/mpl-data/stylelib/_mpl-gallery-nogrid.mplstyle +19 -0
  260. matplotlib_rs/mpl-data/stylelib/_mpl-gallery.mplstyle +19 -0
  261. matplotlib_rs/mpl-data/stylelib/bmh.mplstyle +27 -0
  262. matplotlib_rs/mpl-data/stylelib/classic.mplstyle +491 -0
  263. matplotlib_rs/mpl-data/stylelib/dark_background.mplstyle +26 -0
  264. matplotlib_rs/mpl-data/stylelib/fast.mplstyle +11 -0
  265. matplotlib_rs/mpl-data/stylelib/fivethirtyeight.mplstyle +37 -0
  266. matplotlib_rs/mpl-data/stylelib/ggplot.mplstyle +39 -0
  267. matplotlib_rs/mpl-data/stylelib/grayscale.mplstyle +29 -0
  268. matplotlib_rs/mpl-data/stylelib/petroff10.mplstyle +5 -0
  269. matplotlib_rs/mpl-data/stylelib/petroff6.mplstyle +5 -0
  270. matplotlib_rs/mpl-data/stylelib/petroff8.mplstyle +5 -0
  271. matplotlib_rs/mpl-data/stylelib/seaborn-v0_8-bright.mplstyle +3 -0
  272. matplotlib_rs/mpl-data/stylelib/seaborn-v0_8-colorblind.mplstyle +3 -0
  273. matplotlib_rs/mpl-data/stylelib/seaborn-v0_8-dark-palette.mplstyle +3 -0
  274. matplotlib_rs/mpl-data/stylelib/seaborn-v0_8-dark.mplstyle +30 -0
  275. matplotlib_rs/mpl-data/stylelib/seaborn-v0_8-darkgrid.mplstyle +30 -0
  276. matplotlib_rs/mpl-data/stylelib/seaborn-v0_8-deep.mplstyle +3 -0
  277. matplotlib_rs/mpl-data/stylelib/seaborn-v0_8-muted.mplstyle +3 -0
  278. matplotlib_rs/mpl-data/stylelib/seaborn-v0_8-notebook.mplstyle +21 -0
  279. matplotlib_rs/mpl-data/stylelib/seaborn-v0_8-paper.mplstyle +21 -0
  280. matplotlib_rs/mpl-data/stylelib/seaborn-v0_8-pastel.mplstyle +3 -0
  281. matplotlib_rs/mpl-data/stylelib/seaborn-v0_8-poster.mplstyle +21 -0
  282. matplotlib_rs/mpl-data/stylelib/seaborn-v0_8-talk.mplstyle +21 -0
  283. matplotlib_rs/mpl-data/stylelib/seaborn-v0_8-ticks.mplstyle +30 -0
  284. matplotlib_rs/mpl-data/stylelib/seaborn-v0_8-white.mplstyle +30 -0
  285. matplotlib_rs/mpl-data/stylelib/seaborn-v0_8-whitegrid.mplstyle +30 -0
  286. matplotlib_rs/mpl-data/stylelib/seaborn-v0_8.mplstyle +57 -0
  287. matplotlib_rs/mpl-data/stylelib/tableau-colorblind10.mplstyle +3 -0
  288. matplotlib_rs/mpl_toolkits/__init__.py +3 -0
  289. matplotlib_rs/mpl_toolkits/axes_grid1/__init__.py +11 -0
  290. matplotlib_rs/mpl_toolkits/axes_grid1/anchored_artists.py +415 -0
  291. matplotlib_rs/mpl_toolkits/axes_grid1/axes_divider.py +619 -0
  292. matplotlib_rs/mpl_toolkits/axes_grid1/axes_grid.py +565 -0
  293. matplotlib_rs/mpl_toolkits/axes_grid1/axes_rgb.py +158 -0
  294. matplotlib_rs/mpl_toolkits/axes_grid1/axes_size.py +272 -0
  295. matplotlib_rs/mpl_toolkits/axes_grid1/inset_locator.py +525 -0
  296. matplotlib_rs/mpl_toolkits/axes_grid1/mpl_axes.py +129 -0
  297. matplotlib_rs/mpl_toolkits/axes_grid1/parasite_axes.py +261 -0
  298. matplotlib_rs/mpl_toolkits/axisartist/__init__.py +15 -0
  299. matplotlib_rs/mpl_toolkits/axisartist/angle_helper.py +396 -0
  300. matplotlib_rs/mpl_toolkits/axisartist/axes_divider.py +3 -0
  301. matplotlib_rs/mpl_toolkits/axisartist/axis_artist.py +1148 -0
  302. matplotlib_rs/mpl_toolkits/axisartist/axisline_style.py +193 -0
  303. matplotlib_rs/mpl_toolkits/axisartist/axislines.py +475 -0
  304. matplotlib_rs/mpl_toolkits/axisartist/floating_axes.py +265 -0
  305. matplotlib_rs/mpl_toolkits/axisartist/grid_finder.py +329 -0
  306. matplotlib_rs/mpl_toolkits/axisartist/grid_helper_curvelinear.py +353 -0
  307. matplotlib_rs/mpl_toolkits/axisartist/parasite_axes.py +8 -0
  308. matplotlib_rs/mpl_toolkits/mplot3d/__init__.py +4 -0
  309. matplotlib_rs/mpl_toolkits/mplot3d/art3d.py +1758 -0
  310. matplotlib_rs/mpl_toolkits/mplot3d/axes3d.py +4462 -0
  311. matplotlib_rs/mpl_toolkits/mplot3d/axis3d.py +807 -0
  312. matplotlib_rs/mpl_toolkits/mplot3d/proj3d.py +270 -0
  313. matplotlib_rs/offsetbox.py +1726 -0
  314. matplotlib_rs/patches.py +5049 -0
  315. matplotlib_rs/path.py +1147 -0
  316. matplotlib_rs/patheffects.py +512 -0
  317. matplotlib_rs/projections/__init__.py +126 -0
  318. matplotlib_rs/projections/geo.py +512 -0
  319. matplotlib_rs/projections/polar.py +1518 -0
  320. matplotlib_rs/pylab.py +68 -0
  321. matplotlib_rs/pyplot.py +4834 -0
  322. matplotlib_rs/quiver.py +1236 -0
  323. matplotlib_rs/rcsetup.py +3435 -0
  324. matplotlib_rs/sankey.py +815 -0
  325. matplotlib_rs/scale.py +1002 -0
  326. matplotlib_rs/spines.py +618 -0
  327. matplotlib_rs/stackplot.py +144 -0
  328. matplotlib_rs/streamplot.py +768 -0
  329. matplotlib_rs/style/__init__.py +269 -0
  330. matplotlib_rs/style/core.py +28 -0
  331. matplotlib_rs/table.py +860 -0
  332. matplotlib_rs/texmanager.py +375 -0
  333. matplotlib_rs/text.py +2412 -0
  334. matplotlib_rs/textpath.py +377 -0
  335. matplotlib_rs/ticker.py +3111 -0
  336. matplotlib_rs/transforms.py +3069 -0
  337. matplotlib_rs/tri/__init__.py +24 -0
  338. matplotlib_rs/tri/_triangulation.py +248 -0
  339. matplotlib_rs/tri/_tricontour.py +271 -0
  340. matplotlib_rs/tri/_trifinder.py +97 -0
  341. matplotlib_rs/tri/_triinterpolate.py +1575 -0
  342. matplotlib_rs/tri/_tripcolor.py +170 -0
  343. matplotlib_rs/tri/_triplot.py +87 -0
  344. matplotlib_rs/tri/_trirefine.py +308 -0
  345. matplotlib_rs/tri/_tritools.py +264 -0
  346. matplotlib_rs/typing.py +597 -0
  347. matplotlib_rs/units.py +196 -0
  348. matplotlib_rs/widgets.py +4455 -0
  349. matplotlib_rs-0.0.8.dist-info/METADATA +392 -0
  350. matplotlib_rs-0.0.8.dist-info/RECORD +352 -0
  351. matplotlib_rs-0.0.8.dist-info/WHEEL +4 -0
  352. matplotlib_rs-0.0.8.dist-info/sboms/matplotlib-rs.cyclonedx.json +4390 -0
@@ -0,0 +1,1473 @@
1
+ # Vendored by tools/vendor_deps.py from python-dateutil 3.0.0 (see licenses/LICENSE_DATEUTIL).
2
+ # -*- coding: utf-8 -*-
3
+ """
4
+ This module offers timezone implementations subclassing the abstract
5
+ :py:class:`datetime.tzinfo` type. There are classes to handle tzfile format
6
+ files (usually are in :file:`/etc/localtime`, :file:`/usr/share/zoneinfo`,
7
+ etc), TZ environment string (in all known formats), given ranges (with help
8
+ from relative deltas), local machine timezone, fixed offset timezone, and UTC
9
+ timezone.
10
+ """
11
+
12
+ import bisect
13
+ import datetime
14
+ import os
15
+ import struct
16
+ import sys
17
+ import time
18
+ import warnings
19
+ import weakref
20
+ from collections import OrderedDict
21
+
22
+ from matplotlib_rs._vendor import six
23
+ from matplotlib_rs._vendor.six import string_types
24
+ from matplotlib_rs._vendor.six.moves import _thread
25
+
26
+ from .. import _tzdata_impl
27
+ from . import _tzpath
28
+ from ._common import (
29
+ _tzinfo,
30
+ _validate_fromutc_inputs,
31
+ enfold,
32
+ tzname_in_python2,
33
+ tzrangebase,
34
+ )
35
+ from ._factories import _TzOffsetFactory, _TzSingleton, _TzStrFactory
36
+ from ._tzfile import tzfile
37
+
38
+ try:
39
+ from .win import tzwin, tzwinlocal
40
+ except ImportError:
41
+ tzwin = tzwinlocal = None
42
+
43
+ # For warning about rounding tzinfo
44
+ from warnings import warn
45
+
46
+ ZERO = datetime.timedelta(0)
47
+ EPOCH = datetime.datetime(1970, 1, 1, 0, 0)
48
+
49
+
50
+ @six.add_metaclass(_TzSingleton)
51
+ class tzutc(datetime.tzinfo):
52
+ """
53
+ This is a tzinfo object that represents the UTC time zone.
54
+
55
+ **Examples:**
56
+
57
+ .. doctest::
58
+
59
+ >>> from datetime import *
60
+ >>> from dateutil.tz import *
61
+
62
+ >>> datetime.now()
63
+ datetime.datetime(2003, 9, 27, 9, 40, 1, 521290)
64
+
65
+ >>> datetime.now(tzutc())
66
+ datetime.datetime(2003, 9, 27, 12, 40, 12, 156379, tzinfo=tzutc())
67
+
68
+ >>> datetime.now(tzutc()).tzname()
69
+ 'UTC'
70
+
71
+ .. versionchanged:: 2.7.0
72
+ ``tzutc()`` is now a singleton, so the result of ``tzutc()`` will
73
+ always return the same object.
74
+
75
+ .. doctest::
76
+
77
+ >>> from dateutil.tz import tzutc, UTC
78
+ >>> tzutc() is tzutc()
79
+ True
80
+ >>> tzutc() is UTC
81
+ True
82
+ """
83
+ def utcoffset(self, dt):
84
+ return ZERO
85
+
86
+ def dst(self, dt):
87
+ return ZERO
88
+
89
+ @tzname_in_python2
90
+ def tzname(self, dt):
91
+ return "UTC"
92
+
93
+ def is_ambiguous(self, dt):
94
+ """
95
+ Whether or not the "wall time" of a given datetime is ambiguous in this
96
+ zone.
97
+
98
+ :param dt:
99
+ A :py:class:`datetime.datetime`, naive or time zone aware.
100
+
101
+
102
+ :return:
103
+ Returns ``True`` if ambiguous, ``False`` otherwise.
104
+
105
+ .. versionadded:: 2.6.0
106
+ """
107
+ return False
108
+
109
+ @_validate_fromutc_inputs
110
+ def fromutc(self, dt):
111
+ """
112
+ Fast track version of fromutc() returns the original ``dt`` object for
113
+ any valid :py:class:`datetime.datetime` object.
114
+ """
115
+ return dt
116
+
117
+ def __eq__(self, other):
118
+ if not isinstance(other, (tzutc, tzoffset)):
119
+ return NotImplemented
120
+
121
+ return (isinstance(other, tzutc) or
122
+ (isinstance(other, tzoffset) and other._offset == ZERO))
123
+
124
+ __hash__ = None
125
+
126
+ def __ne__(self, other):
127
+ return not (self == other)
128
+
129
+ def __repr__(self):
130
+ return "%s()" % self.__class__.__name__
131
+
132
+ __reduce__ = object.__reduce__
133
+
134
+
135
+ #: Convenience constant providing a :class:`tzutc()` instance
136
+ #:
137
+ #: .. versionadded:: 2.7.0
138
+ UTC = tzutc()
139
+
140
+
141
+ @six.add_metaclass(_TzOffsetFactory)
142
+ class tzoffset(datetime.tzinfo):
143
+ """
144
+ A simple class for representing a fixed offset from UTC.
145
+
146
+ :param name:
147
+ The timezone name, to be returned when ``tzname()`` is called.
148
+ :param offset:
149
+ The time zone offset in seconds, or (since version 2.6.0, represented
150
+ as a :py:class:`datetime.timedelta` object).
151
+ """
152
+ def __init__(self, name, offset):
153
+ self._name = name
154
+
155
+ try:
156
+ # Allow a timedelta
157
+ offset = offset.total_seconds()
158
+ except (TypeError, AttributeError):
159
+ pass
160
+
161
+ self._offset = datetime.timedelta(seconds=_get_supported_offset(offset))
162
+
163
+ def utcoffset(self, dt):
164
+ return self._offset
165
+
166
+ def dst(self, dt):
167
+ return ZERO
168
+
169
+ @tzname_in_python2
170
+ def tzname(self, dt):
171
+ return self._name
172
+
173
+ @_validate_fromutc_inputs
174
+ def fromutc(self, dt):
175
+ return dt + self._offset
176
+
177
+ def is_ambiguous(self, dt):
178
+ """
179
+ Whether or not the "wall time" of a given datetime is ambiguous in this
180
+ zone.
181
+
182
+ :param dt:
183
+ A :py:class:`datetime.datetime`, naive or time zone aware.
184
+ :return:
185
+ Returns ``True`` if ambiguous, ``False`` otherwise.
186
+
187
+ .. versionadded:: 2.6.0
188
+ """
189
+ return False
190
+
191
+ def __eq__(self, other):
192
+ if not isinstance(other, tzoffset):
193
+ return NotImplemented
194
+
195
+ return self._offset == other._offset
196
+
197
+ __hash__ = None
198
+
199
+ def __ne__(self, other):
200
+ return not (self == other)
201
+
202
+ def __repr__(self):
203
+ return "%s(%s, %s)" % (self.__class__.__name__,
204
+ repr(self._name),
205
+ int(self._offset.total_seconds()))
206
+
207
+ __reduce__ = object.__reduce__
208
+
209
+
210
+ class tzlocal(_tzinfo):
211
+ """
212
+ A :class:`tzinfo` subclass built around the ``time`` timezone functions.
213
+ """
214
+ def __init__(self):
215
+ super(tzlocal, self).__init__()
216
+
217
+ self._std_offset = datetime.timedelta(seconds=-time.timezone)
218
+ if time.daylight:
219
+ self._dst_offset = datetime.timedelta(seconds=-time.altzone)
220
+ else:
221
+ self._dst_offset = self._std_offset
222
+
223
+ self._dst_saved = self._dst_offset - self._std_offset
224
+ self._hasdst = bool(self._dst_saved)
225
+ self._tznames = tuple(time.tzname)
226
+
227
+ def utcoffset(self, dt):
228
+ if dt is None and self._hasdst:
229
+ return None
230
+
231
+ if self._isdst(dt):
232
+ return self._dst_offset
233
+ else:
234
+ return self._std_offset
235
+
236
+ def dst(self, dt):
237
+ if dt is None and self._hasdst:
238
+ return None
239
+
240
+ if self._isdst(dt):
241
+ return self._dst_offset - self._std_offset
242
+ else:
243
+ return ZERO
244
+
245
+ @tzname_in_python2
246
+ def tzname(self, dt):
247
+ return self._tznames[self._isdst(dt)]
248
+
249
+ def is_ambiguous(self, dt):
250
+ """
251
+ Whether or not the "wall time" of a given datetime is ambiguous in this
252
+ zone.
253
+
254
+ :param dt:
255
+ A :py:class:`datetime.datetime`, naive or time zone aware.
256
+
257
+
258
+ :return:
259
+ Returns ``True`` if ambiguous, ``False`` otherwise.
260
+
261
+ .. versionadded:: 2.6.0
262
+ """
263
+ naive_dst = self._naive_is_dst(dt)
264
+ return (not naive_dst and
265
+ (naive_dst != self._naive_is_dst(dt - self._dst_saved)))
266
+
267
+ def _naive_is_dst(self, dt):
268
+ timestamp = _datetime_to_timestamp(dt)
269
+ return time.localtime(timestamp + time.timezone).tm_isdst
270
+
271
+ def _isdst(self, dt, fold_naive=True):
272
+ # We can't use mktime here. It is unstable when deciding if
273
+ # the hour near to a change is DST or not.
274
+ #
275
+ # timestamp = time.mktime((dt.year, dt.month, dt.day, dt.hour,
276
+ # dt.minute, dt.second, dt.weekday(), 0, -1))
277
+ # return time.localtime(timestamp).tm_isdst
278
+ #
279
+ # The code above yields the following result:
280
+ #
281
+ # >>> import tz, datetime
282
+ # >>> t = tz.tzlocal()
283
+ # >>> datetime.datetime(2003,2,15,23,tzinfo=t).tzname()
284
+ # 'BRDT'
285
+ # >>> datetime.datetime(2003,2,16,0,tzinfo=t).tzname()
286
+ # 'BRST'
287
+ # >>> datetime.datetime(2003,2,15,23,tzinfo=t).tzname()
288
+ # 'BRST'
289
+ # >>> datetime.datetime(2003,2,15,22,tzinfo=t).tzname()
290
+ # 'BRDT'
291
+ # >>> datetime.datetime(2003,2,15,23,tzinfo=t).tzname()
292
+ # 'BRDT'
293
+ #
294
+ # Here is a more stable implementation:
295
+ #
296
+ if not self._hasdst:
297
+ return False
298
+
299
+ # Check for ambiguous times:
300
+ dstval = self._naive_is_dst(dt)
301
+ fold = getattr(dt, 'fold', None)
302
+
303
+ if self.is_ambiguous(dt):
304
+ if fold is not None:
305
+ return not self._fold(dt)
306
+ else:
307
+ return True
308
+
309
+ return dstval
310
+
311
+ def __eq__(self, other):
312
+ if isinstance(other, tzlocal):
313
+ return (self._std_offset == other._std_offset and
314
+ self._dst_offset == other._dst_offset)
315
+ elif isinstance(other, tzutc):
316
+ return (not self._hasdst and
317
+ self._tznames[0] in {'UTC', 'GMT'} and
318
+ self._std_offset == ZERO)
319
+ elif isinstance(other, tzoffset):
320
+ return (not self._hasdst and
321
+ self._tznames[0] == other._name and
322
+ self._std_offset == other._offset)
323
+ else:
324
+ return NotImplemented
325
+
326
+ __hash__ = None
327
+
328
+ def __ne__(self, other):
329
+ return not (self == other)
330
+
331
+ def __repr__(self):
332
+ return "%s()" % self.__class__.__name__
333
+
334
+ __reduce__ = object.__reduce__
335
+
336
+
337
+ class tzrange(tzrangebase):
338
+ """
339
+ The ``tzrange`` object is a time zone specified by a set of offsets and
340
+ abbreviations, equivalent to the way the ``TZ`` variable can be specified
341
+ in POSIX-like systems, but using Python delta objects to specify DST
342
+ start, end and offsets.
343
+
344
+ :param stdabbr:
345
+ The abbreviation for standard time (e.g. ``'EST'``).
346
+
347
+ :param stdoffset:
348
+ An integer or :class:`datetime.timedelta` object or equivalent
349
+ specifying the base offset from UTC.
350
+
351
+ If unspecified, +00:00 is used.
352
+
353
+ :param dstabbr:
354
+ The abbreviation for DST / "Summer" time (e.g. ``'EDT'``).
355
+
356
+ If specified, with no other DST information, DST is assumed to occur
357
+ and the default behavior or ``dstoffset``, ``start`` and ``end`` is
358
+ used. If unspecified and no other DST information is specified, it
359
+ is assumed that this zone has no DST.
360
+
361
+ If this is unspecified and other DST information is *is* specified,
362
+ DST occurs in the zone but the time zone abbreviation is left
363
+ unchanged.
364
+
365
+ :param dstoffset:
366
+ A an integer or :class:`datetime.timedelta` object or equivalent
367
+ specifying the UTC offset during DST. If unspecified and any other DST
368
+ information is specified, it is assumed to be the STD offset +1 hour.
369
+
370
+ :param start:
371
+ A :class:`relativedelta.relativedelta` object or equivalent specifying
372
+ the time and time of year that daylight savings time starts. To
373
+ specify, for example, that DST starts at 2AM on the 2nd Sunday in
374
+ March, pass:
375
+
376
+ ``relativedelta(hours=2, month=3, day=1, weekday=SU(+2))``
377
+
378
+ If unspecified and any other DST information is specified, the default
379
+ value is 2 AM on the first Sunday in April.
380
+
381
+ :param end:
382
+ A :class:`relativedelta.relativedelta` object or equivalent
383
+ representing the time and time of year that daylight savings time
384
+ ends, with the same specification method as in ``start``. One note is
385
+ that this should point to the first time in the *standard* zone, so if
386
+ a transition occurs at 2AM in the DST zone and the clocks are set back
387
+ 1 hour to 1AM, set the ``hours`` parameter to +1.
388
+
389
+
390
+ **Examples:**
391
+
392
+ .. testsetup:: tzrange
393
+
394
+ from matplotlib_rs._vendor.dateutil.tz import tzrange, tzstr
395
+
396
+ .. doctest:: tzrange
397
+
398
+ >>> tzstr('EST5EDT') == tzrange("EST", -18000, "EDT")
399
+ True
400
+
401
+ >>> from dateutil.relativedelta import *
402
+ >>> range1 = tzrange("EST", -18000, "EDT")
403
+ >>> range2 = tzrange("EST", -18000, "EDT", -14400,
404
+ ... relativedelta(hours=+2, month=4, day=1,
405
+ ... weekday=SU(+1)),
406
+ ... relativedelta(hours=+1, month=10, day=31,
407
+ ... weekday=SU(-1)))
408
+ >>> tzstr('EST5EDT') == range1 == range2
409
+ True
410
+
411
+ """
412
+ def __init__(self, stdabbr, stdoffset=None,
413
+ dstabbr=None, dstoffset=None,
414
+ start=None, end=None):
415
+
416
+ global relativedelta
417
+ from matplotlib_rs._vendor.dateutil import relativedelta
418
+
419
+ self._std_abbr = stdabbr
420
+ self._dst_abbr = dstabbr
421
+
422
+ try:
423
+ stdoffset = stdoffset.total_seconds()
424
+ except (TypeError, AttributeError):
425
+ pass
426
+
427
+ try:
428
+ dstoffset = dstoffset.total_seconds()
429
+ except (TypeError, AttributeError):
430
+ pass
431
+
432
+ if stdoffset is not None:
433
+ self._std_offset = datetime.timedelta(seconds=stdoffset)
434
+ else:
435
+ self._std_offset = ZERO
436
+
437
+ if dstoffset is not None:
438
+ self._dst_offset = datetime.timedelta(seconds=dstoffset)
439
+ elif dstabbr and stdoffset is not None:
440
+ self._dst_offset = self._std_offset + datetime.timedelta(hours=+1)
441
+ else:
442
+ self._dst_offset = ZERO
443
+
444
+ if dstabbr and start is None:
445
+ self._start_delta = relativedelta.relativedelta(
446
+ hours=+2, month=4, day=1, weekday=relativedelta.SU(+1))
447
+ else:
448
+ self._start_delta = start
449
+
450
+ if dstabbr and end is None:
451
+ self._end_delta = relativedelta.relativedelta(
452
+ hours=+1, month=10, day=31, weekday=relativedelta.SU(-1))
453
+ else:
454
+ self._end_delta = end
455
+
456
+ self._dst_base_offset_ = self._dst_offset - self._std_offset
457
+ self.hasdst = bool(self._start_delta)
458
+
459
+ def transitions(self, year):
460
+ """
461
+ For a given year, get the DST on and off transition times, expressed
462
+ always on the standard time side. For zones with no transitions, this
463
+ function returns ``None``.
464
+
465
+ :param year:
466
+ The year whose transitions you would like to query.
467
+
468
+ :return:
469
+ Returns a :class:`tuple` of :class:`datetime.datetime` objects,
470
+ ``(dston, dstoff)`` for zones with an annual DST transition, or
471
+ ``None`` for fixed offset zones.
472
+ """
473
+ if not self.hasdst:
474
+ return None
475
+
476
+ base_year = datetime.datetime(year, 1, 1)
477
+
478
+ start = base_year + self._start_delta
479
+ end = base_year + self._end_delta
480
+
481
+ return (start, end)
482
+
483
+ def __eq__(self, other):
484
+ if not isinstance(other, tzrange):
485
+ return NotImplemented
486
+
487
+ return (self._std_abbr == other._std_abbr and
488
+ self._dst_abbr == other._dst_abbr and
489
+ self._std_offset == other._std_offset and
490
+ self._dst_offset == other._dst_offset and
491
+ self._start_delta == other._start_delta and
492
+ self._end_delta == other._end_delta)
493
+
494
+ @property
495
+ def _dst_base_offset(self):
496
+ return self._dst_base_offset_
497
+
498
+
499
+ @six.add_metaclass(_TzStrFactory)
500
+ class tzstr(tzrange):
501
+ """
502
+ ``tzstr`` objects are time zone objects specified by a time-zone string as
503
+ it would be passed to a ``TZ`` variable on POSIX-style systems (see
504
+ the `GNU C Library: TZ Variable`_ for more details).
505
+
506
+ There is one notable exception, which is that POSIX-style time zones use an
507
+ inverted offset format, so normally ``GMT+3`` would be parsed as an offset
508
+ 3 hours *behind* GMT. The ``tzstr`` time zone object will parse this as an
509
+ offset 3 hours *ahead* of GMT. If you would like to maintain the POSIX
510
+ behavior, pass a ``True`` value to ``posix_offset``.
511
+
512
+ The :class:`tzrange` object provides the same functionality, but is
513
+ specified using :class:`relativedelta.relativedelta` objects. rather than
514
+ strings.
515
+
516
+ :param s:
517
+ A time zone string in ``TZ`` variable format. This can be a
518
+ :class:`bytes` (2.x: :class:`str`), :class:`str` (2.x:
519
+ :class:`unicode`) or a stream emitting unicode characters
520
+ (e.g. :class:`StringIO`).
521
+
522
+ :param posix_offset:
523
+ Optional. If set to ``True``, interpret strings such as ``GMT+3`` or
524
+ ``UTC+3`` as being 3 hours *behind* UTC rather than ahead, per the
525
+ POSIX standard.
526
+
527
+ .. caution::
528
+
529
+ Prior to version 2.7.0, this function also supported time zones
530
+ in the format:
531
+
532
+ * ``EST5EDT,4,0,6,7200,10,0,26,7200,3600``
533
+ * ``EST5EDT,4,1,0,7200,10,-1,0,7200,3600``
534
+
535
+ This format is non-standard and has been deprecated; this function
536
+ will raise a :class:`DeprecatedTZFormatWarning` until
537
+ support is removed in a future version.
538
+
539
+ .. _`GNU C Library: TZ Variable`:
540
+ https://www.gnu.org/software/libc/manual/html_node/TZ-Variable.html
541
+ """
542
+ def __init__(self, s, posix_offset=False):
543
+ global parser
544
+ from matplotlib_rs._vendor.dateutil.parser import _parser as parser
545
+
546
+ self._s = s
547
+
548
+ res = parser._parsetz(s)
549
+ if res is None or res.any_unused_tokens:
550
+ raise ValueError("unknown string format")
551
+
552
+ # Here we break the compatibility with the TZ variable handling.
553
+ # GMT-3 actually *means* the timezone -3.
554
+ if res.stdabbr in ("GMT", "UTC") and not posix_offset:
555
+ res.stdoffset *= -1
556
+
557
+ # We must initialize it first, since _delta() needs
558
+ # _std_offset and _dst_offset set. Use False in start/end
559
+ # to avoid building it two times.
560
+ tzrange.__init__(self, res.stdabbr, res.stdoffset,
561
+ res.dstabbr, res.dstoffset,
562
+ start=False, end=False)
563
+
564
+ if not res.dstabbr:
565
+ self._start_delta = None
566
+ self._end_delta = None
567
+ else:
568
+ self._start_delta = self._delta(res.start)
569
+ if self._start_delta:
570
+ self._end_delta = self._delta(res.end, isend=1)
571
+
572
+ self.hasdst = bool(self._start_delta)
573
+
574
+ def _delta(self, x, isend=0):
575
+ from matplotlib_rs._vendor.dateutil import relativedelta
576
+ kwargs = {}
577
+ if x.month is not None:
578
+ kwargs["month"] = x.month
579
+ if x.weekday is not None:
580
+ kwargs["weekday"] = relativedelta.weekday(x.weekday, x.week)
581
+ if x.week > 0:
582
+ kwargs["day"] = 1
583
+ else:
584
+ kwargs["day"] = 31
585
+ elif x.day:
586
+ kwargs["day"] = x.day
587
+ elif x.yday is not None:
588
+ kwargs["yearday"] = x.yday
589
+ elif x.jyday is not None:
590
+ kwargs["nlyearday"] = x.jyday
591
+ if not kwargs:
592
+ # Default is to start on first sunday of april, and end
593
+ # on last sunday of october.
594
+ if not isend:
595
+ kwargs["month"] = 4
596
+ kwargs["day"] = 1
597
+ kwargs["weekday"] = relativedelta.SU(+1)
598
+ else:
599
+ kwargs["month"] = 10
600
+ kwargs["day"] = 31
601
+ kwargs["weekday"] = relativedelta.SU(-1)
602
+ if x.time is not None:
603
+ kwargs["seconds"] = x.time
604
+ else:
605
+ # Default is 2AM.
606
+ kwargs["seconds"] = 7200
607
+ if isend:
608
+ # Convert to standard time, to follow the documented way
609
+ # of working with the extra hour. See the documentation
610
+ # of the tzinfo class.
611
+ delta = self._dst_offset - self._std_offset
612
+ kwargs["seconds"] -= delta.seconds + delta.days * 86400
613
+ return relativedelta.relativedelta(**kwargs)
614
+
615
+ def __repr__(self):
616
+ return "%s(%s)" % (self.__class__.__name__, repr(self._s))
617
+
618
+
619
+ class _tzicalvtzcomp(object):
620
+ def __init__(self, tzoffsetfrom, tzoffsetto, isdst,
621
+ tzname=None, rrule=None):
622
+ self.tzoffsetfrom = datetime.timedelta(seconds=tzoffsetfrom)
623
+ self.tzoffsetto = datetime.timedelta(seconds=tzoffsetto)
624
+ self.tzoffsetdiff = self.tzoffsetto - self.tzoffsetfrom
625
+ self.isdst = isdst
626
+ self.tzname = tzname
627
+ self.rrule = rrule
628
+
629
+
630
+ class _tzicalvtz(_tzinfo):
631
+ def __init__(self, tzid, comps=[]):
632
+ super(_tzicalvtz, self).__init__()
633
+
634
+ self._tzid = tzid
635
+ self._comps = comps
636
+ self._cachedate = []
637
+ self._cachecomp = []
638
+ self._cache_lock = _thread.allocate_lock()
639
+
640
+ def _find_comp(self, dt):
641
+ if len(self._comps) == 1:
642
+ return self._comps[0]
643
+
644
+ dt = dt.replace(tzinfo=None)
645
+
646
+ try:
647
+ with self._cache_lock:
648
+ return self._cachecomp[self._cachedate.index(
649
+ (dt, self._fold(dt)))]
650
+ except ValueError:
651
+ pass
652
+
653
+ lastcompdt = None
654
+ lastcomp = None
655
+
656
+ for comp in self._comps:
657
+ compdt = self._find_compdt(comp, dt)
658
+
659
+ if compdt and (not lastcompdt or lastcompdt < compdt):
660
+ lastcompdt = compdt
661
+ lastcomp = comp
662
+
663
+ if not lastcomp:
664
+ # RFC says nothing about what to do when a given
665
+ # time is before the first onset date. We'll look for the
666
+ # first standard component, or the first component, if
667
+ # none is found.
668
+ for comp in self._comps:
669
+ if not comp.isdst:
670
+ lastcomp = comp
671
+ break
672
+ else:
673
+ lastcomp = comp[0]
674
+
675
+ with self._cache_lock:
676
+ self._cachedate.insert(0, (dt, self._fold(dt)))
677
+ self._cachecomp.insert(0, lastcomp)
678
+
679
+ if len(self._cachedate) > 10:
680
+ self._cachedate.pop()
681
+ self._cachecomp.pop()
682
+
683
+ return lastcomp
684
+
685
+ def _find_compdt(self, comp, dt):
686
+ if comp.tzoffsetdiff < ZERO and self._fold(dt):
687
+ dt -= comp.tzoffsetdiff
688
+
689
+ compdt = comp.rrule.before(dt, inc=True)
690
+
691
+ return compdt
692
+
693
+ def utcoffset(self, dt):
694
+ if dt is None:
695
+ return None
696
+
697
+ return self._find_comp(dt).tzoffsetto
698
+
699
+ def dst(self, dt):
700
+ comp = self._find_comp(dt)
701
+ if comp.isdst:
702
+ return comp.tzoffsetdiff
703
+ else:
704
+ return ZERO
705
+
706
+ @tzname_in_python2
707
+ def tzname(self, dt):
708
+ return self._find_comp(dt).tzname
709
+
710
+ def __repr__(self):
711
+ return "<tzicalvtz %s>" % repr(self._tzid)
712
+
713
+ __reduce__ = object.__reduce__
714
+
715
+
716
+ class tzical(object):
717
+ """
718
+ This object is designed to parse an iCalendar-style ``VTIMEZONE`` structure
719
+ as set out in `RFC 5545`_ Section 4.6.5 into one or more `tzinfo` objects.
720
+
721
+ :param `fileobj`:
722
+ A file or stream in iCalendar format, which should be UTF-8 encoded
723
+ with CRLF endings.
724
+
725
+ .. _`RFC 5545`: https://tools.ietf.org/html/rfc5545
726
+ """
727
+ def __init__(self, fileobj):
728
+ global rrule
729
+ from matplotlib_rs._vendor.dateutil import rrule
730
+
731
+ if isinstance(fileobj, string_types):
732
+ self._s = fileobj
733
+ # ical should be encoded in UTF-8 with CRLF
734
+ fileobj = open(fileobj, 'r')
735
+ else:
736
+ self._s = getattr(fileobj, 'name', repr(fileobj))
737
+ fileobj = _nullcontext(fileobj)
738
+
739
+ self._vtz = {}
740
+
741
+ with fileobj as fobj:
742
+ self._parse_rfc(fobj.read())
743
+
744
+ def keys(self):
745
+ """
746
+ Retrieves the available time zones as a list.
747
+ """
748
+ return list(self._vtz.keys())
749
+
750
+ def get(self, tzid=None):
751
+ """
752
+ Retrieve a :py:class:`datetime.tzinfo` object by its ``tzid``.
753
+
754
+ :param tzid:
755
+ If there is exactly one time zone available, omitting ``tzid``
756
+ or passing :py:const:`None` value returns it. Otherwise a valid
757
+ key (which can be retrieved from :func:`keys`) is required.
758
+
759
+ :raises ValueError:
760
+ Raised if ``tzid`` is not specified but there are either more
761
+ or fewer than 1 zone defined.
762
+
763
+ :returns:
764
+ Returns either a :py:class:`datetime.tzinfo` object representing
765
+ the relevant time zone or :py:const:`None` if the ``tzid`` was
766
+ not found.
767
+ """
768
+ if tzid is None:
769
+ if len(self._vtz) == 0:
770
+ raise ValueError("no timezones defined")
771
+ elif len(self._vtz) > 1:
772
+ raise ValueError("more than one timezone available")
773
+ tzid = next(iter(self._vtz))
774
+
775
+ return self._vtz.get(tzid)
776
+
777
+ def _parse_offset(self, s):
778
+ s = s.strip()
779
+ if not s:
780
+ raise ValueError("empty offset")
781
+ if s[0] in ('+', '-'):
782
+ signal = (-1, +1)[s[0] == '+']
783
+ s = s[1:]
784
+ else:
785
+ signal = +1
786
+ if len(s) == 4:
787
+ return (int(s[:2]) * 3600 + int(s[2:]) * 60) * signal
788
+ elif len(s) == 6:
789
+ return (int(s[:2]) * 3600 + int(s[2:4]) * 60 + int(s[4:])) * signal
790
+ else:
791
+ raise ValueError("invalid offset: " + s)
792
+
793
+ def _parse_rfc(self, s):
794
+ lines = s.splitlines()
795
+ if not lines:
796
+ raise ValueError("empty string")
797
+
798
+ # Unfold
799
+ i = 0
800
+ while i < len(lines):
801
+ line = lines[i].rstrip()
802
+ if not line:
803
+ del lines[i]
804
+ elif i > 0 and line[0] == " ":
805
+ lines[i-1] += line[1:]
806
+ del lines[i]
807
+ else:
808
+ i += 1
809
+
810
+ tzid = None
811
+ comps = []
812
+ invtz = False
813
+ comptype = None
814
+ for line in lines:
815
+ if not line:
816
+ continue
817
+ name, value = line.split(':', 1)
818
+ parms = name.split(';')
819
+ if not parms:
820
+ raise ValueError("empty property name")
821
+ name = parms[0].upper()
822
+ parms = parms[1:]
823
+ if invtz:
824
+ if name == "BEGIN":
825
+ if value in ("STANDARD", "DAYLIGHT"):
826
+ # Process component
827
+ pass
828
+ else:
829
+ raise ValueError("unknown component: "+value)
830
+ comptype = value
831
+ founddtstart = False
832
+ tzoffsetfrom = None
833
+ tzoffsetto = None
834
+ rrulelines = []
835
+ tzname = None
836
+ elif name == "END":
837
+ if value == "VTIMEZONE":
838
+ if comptype:
839
+ raise ValueError("component not closed: "+comptype)
840
+ if not tzid:
841
+ raise ValueError("mandatory TZID not found")
842
+ if not comps:
843
+ raise ValueError(
844
+ "at least one component is needed")
845
+ # Process vtimezone
846
+ self._vtz[tzid] = _tzicalvtz(tzid, comps)
847
+ invtz = False
848
+ elif value == comptype:
849
+ if not founddtstart:
850
+ raise ValueError("mandatory DTSTART not found")
851
+ if tzoffsetfrom is None:
852
+ raise ValueError(
853
+ "mandatory TZOFFSETFROM not found")
854
+ if tzoffsetto is None:
855
+ raise ValueError(
856
+ "mandatory TZOFFSETFROM not found")
857
+ # Process component
858
+ rr = None
859
+ if rrulelines:
860
+ rr = rrule.rrulestr("\n".join(rrulelines),
861
+ compatible=True,
862
+ ignoretz=True,
863
+ cache=True)
864
+ comp = _tzicalvtzcomp(tzoffsetfrom, tzoffsetto,
865
+ (comptype == "DAYLIGHT"),
866
+ tzname, rr)
867
+ comps.append(comp)
868
+ comptype = None
869
+ else:
870
+ raise ValueError("invalid component end: "+value)
871
+ elif comptype:
872
+ if name == "DTSTART":
873
+ # DTSTART in VTIMEZONE takes a subset of valid RRULE
874
+ # values under RFC 5545.
875
+ for parm in parms:
876
+ if parm != 'VALUE=DATE-TIME':
877
+ msg = ('Unsupported DTSTART param in ' +
878
+ 'VTIMEZONE: ' + parm)
879
+ raise ValueError(msg)
880
+ rrulelines.append(line)
881
+ founddtstart = True
882
+ elif name in ("RRULE", "RDATE", "EXRULE", "EXDATE"):
883
+ rrulelines.append(line)
884
+ elif name == "TZOFFSETFROM":
885
+ if parms:
886
+ raise ValueError(
887
+ "unsupported %s parm: %s " % (name, parms[0]))
888
+ tzoffsetfrom = self._parse_offset(value)
889
+ elif name == "TZOFFSETTO":
890
+ if parms:
891
+ raise ValueError(
892
+ "unsupported TZOFFSETTO parm: "+parms[0])
893
+ tzoffsetto = self._parse_offset(value)
894
+ elif name == "TZNAME":
895
+ if parms:
896
+ raise ValueError(
897
+ "unsupported TZNAME parm: "+parms[0])
898
+ tzname = value
899
+ elif name == "COMMENT":
900
+ pass
901
+ else:
902
+ raise ValueError("unsupported property: "+name)
903
+ else:
904
+ if name == "TZID":
905
+ if parms:
906
+ raise ValueError(
907
+ "unsupported TZID parm: "+parms[0])
908
+ tzid = value
909
+ elif name in ("TZURL", "LAST-MODIFIED", "COMMENT"):
910
+ pass
911
+ else:
912
+ raise ValueError("unsupported property: "+name)
913
+ elif name == "BEGIN" and value == "VTIMEZONE":
914
+ tzid = None
915
+ comps = []
916
+ invtz = True
917
+
918
+ def __repr__(self):
919
+ return "%s(%s)" % (self.__class__.__name__, repr(self._s))
920
+
921
+
922
+ TZFILES = ["/etc/localtime", "localtime"]
923
+
924
+ def __get_gettz():
925
+ tzlocal_classes = (tzlocal,)
926
+ if tzwinlocal is not None:
927
+ tzlocal_classes += (tzwinlocal,)
928
+
929
+ class GettzFunc(object):
930
+ """
931
+ Retrieve a time zone object from a string representation
932
+
933
+ This function is intended to retrieve the :py:class:`tzinfo` subclass
934
+ that best represents the time zone that would be used if a POSIX
935
+ `TZ variable`_ were set to the same value.
936
+
937
+ If no argument or an empty string is passed to ``gettz``, local time
938
+ is returned:
939
+
940
+ .. code-block:: python3
941
+
942
+ >>> gettz()
943
+ tzfile('/etc/localtime')
944
+
945
+ This function is also the preferred way to map IANA tz database keys
946
+ to :class:`tzfile` objects. It searches for these keys in the
947
+ following order:
948
+
949
+ 1. On the search path defined in :data:`TZPATH`.
950
+ 2. In the `tzdata <https://pypi.org/project/tzdata/>`_ Python package.
951
+ 3. Using the system-specific mechanisms (e.g. the Windows registry).
952
+
953
+ .. code-block:: python3
954
+
955
+ >>> gettz('Pacific/Kiritimati')
956
+ tzfile('/usr/share/zoneinfo/Pacific/Kiritimati')
957
+
958
+ On Windows, the standard is extended to include the Windows-specific
959
+ zone names provided by the operating system:
960
+
961
+ .. code-block:: python3
962
+
963
+ >>> gettz('Egypt Standard Time')
964
+ tzwin('Egypt Standard Time')
965
+
966
+ Passing a GNU ``TZ`` style string time zone specification returns a
967
+ :class:`tzstr` object:
968
+
969
+ .. code-block:: python3
970
+
971
+ >>> gettz('AEST-10AEDT-11,M10.1.0/2,M4.1.0/3')
972
+ tzstr('AEST-10AEDT-11,M10.1.0/2,M4.1.0/3')
973
+
974
+ :param name:
975
+ A time zone name (IANA, or, on Windows, Windows keys), location of
976
+ a ``tzfile(5)`` zoneinfo file or ``TZ`` variable style time zone
977
+ specifier. An empty string, no argument or ``None`` is interpreted
978
+ as local time.
979
+
980
+ :return:
981
+ Returns an instance of one of ``dateutil``'s :py:class:`tzinfo`
982
+ subclasses.
983
+
984
+ .. versionchanged:: 2.7.0
985
+
986
+ After version 2.7.0, any two calls to ``gettz`` using the same
987
+ input strings will return the same object:
988
+
989
+ .. code-block:: python3
990
+
991
+ >>> tz.gettz('America/Chicago') is tz.gettz('America/Chicago')
992
+ True
993
+
994
+ In addition to improving performance, this ensures that
995
+ `"same zone" semantics`_ are used for datetimes in the same zone.
996
+
997
+
998
+ .. _`TZ variable`:
999
+ https://www.gnu.org/software/libc/manual/html_node/TZ-Variable.html
1000
+
1001
+ .. _`"same zone" semantics`:
1002
+ https://blog.ganssle.io/articles/2018/02/aware-datetime-arithmetic.html
1003
+ """
1004
+ def __init__(self):
1005
+
1006
+ self.__instances = weakref.WeakValueDictionary()
1007
+ self.__strong_cache_size = 8
1008
+ self.__strong_cache = OrderedDict()
1009
+ self._cache_lock = _thread.allocate_lock()
1010
+
1011
+ def __call__(self, name=None):
1012
+ with self._cache_lock:
1013
+ rv = self.__instances.get(name, None)
1014
+
1015
+ if rv is None:
1016
+ # TODO: This holds the cache lock while nocache() reads
1017
+ # the file, so a slow lookup (e.g. walking TZPATH on a
1018
+ # network file system) blocks every other gettz call,
1019
+ # including cache hits for unrelated keys.
1020
+ rv = self.nocache(name=name)
1021
+ if not (name is None
1022
+ or isinstance(rv, tzlocal_classes)
1023
+ or rv is None):
1024
+ # tzlocal is slightly more complicated than the other
1025
+ # time zone providers because it depends on environment
1026
+ # at construction time, so don't cache that.
1027
+ #
1028
+ # We also cannot store weak references to None, so we
1029
+ # will also not store that.
1030
+ self.__instances[name] = rv
1031
+ else:
1032
+ # No need for strong caching, return immediately
1033
+ return rv
1034
+
1035
+ self.__strong_cache[name] = self.__strong_cache.pop(name, rv)
1036
+
1037
+ if len(self.__strong_cache) > self.__strong_cache_size:
1038
+ self.__strong_cache.popitem(last=False)
1039
+
1040
+ return rv
1041
+
1042
+ def set_cache_size(self, size):
1043
+ with self._cache_lock:
1044
+ self.__strong_cache_size = size
1045
+ while len(self.__strong_cache) > size:
1046
+ self.__strong_cache.popitem(last=False)
1047
+
1048
+ def cache_clear(self):
1049
+ with self._cache_lock:
1050
+ self.__instances = weakref.WeakValueDictionary()
1051
+ self.__strong_cache.clear()
1052
+
1053
+ @staticmethod
1054
+ def nocache(name=None):
1055
+ """A non-cached version of gettz"""
1056
+ tz = None
1057
+ if not name:
1058
+ try:
1059
+ name = os.environ["TZ"]
1060
+ except KeyError:
1061
+ pass
1062
+ if name is None or name in ("", ":"):
1063
+ for filepath in TZFILES:
1064
+ if not os.path.isabs(filepath):
1065
+ filename = filepath
1066
+ for path in _tzpath.TZPATH:
1067
+ filepath = os.path.join(path, filename)
1068
+ if _isfile(filepath):
1069
+ break
1070
+ else:
1071
+ continue
1072
+ if _isfile(filepath):
1073
+ try:
1074
+ tz = tzfile(filepath)
1075
+ break
1076
+ except (IOError, OSError, ValueError):
1077
+ pass
1078
+ else:
1079
+ tz = tzlocal()
1080
+ else:
1081
+ try:
1082
+ if name.startswith(":"):
1083
+ name = name[1:]
1084
+ except TypeError as e:
1085
+ if isinstance(name, bytes):
1086
+ new_msg = "gettz argument should be str, not bytes"
1087
+ six.raise_from(TypeError(new_msg), e)
1088
+ else:
1089
+ raise
1090
+
1091
+ # A NUL byte can never be part of a key or a path, and
1092
+ # depending on the platform and Python version it raises
1093
+ # ValueError from os.path, winreg or open(), so reject it
1094
+ # up front rather than catching it in every branch.
1095
+ if "\x00" in name:
1096
+ return None
1097
+
1098
+ if os.path.isabs(name):
1099
+ if _isfile(name):
1100
+ tz = tzfile(name)
1101
+ else:
1102
+ tz = None
1103
+ else:
1104
+ if _escapes_tzpath(name):
1105
+ _warn_tzpath_escape(name)
1106
+
1107
+ for path in _tzpath.TZPATH:
1108
+ filepath = os.path.join(path, name)
1109
+ if not _isfile(filepath):
1110
+ filepath = filepath.replace(' ', '_')
1111
+ if not _isfile(filepath):
1112
+ continue
1113
+ try:
1114
+ tz = tzfile(filepath, key=name)
1115
+ break
1116
+ except (IOError, OSError, ValueError):
1117
+ # TODO: A file that exists but can't be read or
1118
+ # isn't a valid TZif file is silently skipped,
1119
+ # and the key is looked up in the next TZPATH
1120
+ # entry and then in tzdata. Consider warning
1121
+ # here, since this usually means the system time
1122
+ # zone data is broken.
1123
+ pass
1124
+ else:
1125
+ tz = None
1126
+ # As with the search path lookup above, also try
1127
+ # the name with spaces replaced by underscores.
1128
+ candidates = [name]
1129
+ if " " in name:
1130
+ candidates.append(name.replace(" ", "_"))
1131
+
1132
+ for candidate in candidates:
1133
+ try:
1134
+ with _tzdata_impl._load_tzdata(candidate) as f:
1135
+ return tzfile(f, key=name)
1136
+ except ValueError:
1137
+ # TZFileNotFound is a ValueError, and so is
1138
+ # the error raised for files in tzdata that
1139
+ # are not TZif files (e.g. "zone.tab"),
1140
+ # which are skipped just as on TZPATH.
1141
+ pass
1142
+
1143
+ if tzwin is not None:
1144
+ try:
1145
+ tz = tzwin(name)
1146
+ except (WindowsError, UnicodeEncodeError):
1147
+ # UnicodeEncodeError is for Python 2.7 compat
1148
+ tz = None
1149
+
1150
+ if not tz:
1151
+ for c in name:
1152
+ # name is not a tzstr unless it has at least
1153
+ # one offset. For short values of "name", an
1154
+ # explicit for loop seems to be the fastest way
1155
+ # To determine if a string contains a digit
1156
+ if c in "0123456789":
1157
+ try:
1158
+ tz = tzstr(name)
1159
+ except ValueError:
1160
+ pass
1161
+ break
1162
+ else:
1163
+ if name in ("GMT", "UTC"):
1164
+ tz = UTC
1165
+ elif name in time.tzname:
1166
+ tz = tzlocal()
1167
+ return tz
1168
+
1169
+ return GettzFunc()
1170
+
1171
+
1172
+ gettz = __get_gettz()
1173
+ del __get_gettz
1174
+
1175
+
1176
+ class DeprecatedTzKeyWarning(FutureWarning):
1177
+ """Warning raised when :func:`gettz` is given a key outside of TZPATH.
1178
+
1179
+ Relative keys like ``"../../etc/localtime"`` resolve to files outside of
1180
+ every directory on :data:`TZPATH`. Support for these is deprecated, and a
1181
+ warnings filter turns this warning into an error by default. To keep the
1182
+ old behavior for now, filter it out, e.g.::
1183
+
1184
+ warnings.filterwarnings(
1185
+ "ignore", category=dateutil.tz.DeprecatedTzKeyWarning
1186
+ )
1187
+
1188
+ Absolute paths to TZif files are not affected.
1189
+ """
1190
+
1191
+
1192
+ def _escapes_tzpath(name):
1193
+ # A relative key stays inside every TZPATH entry unless, once normalized
1194
+ # (which also turns os.altsep into os.sep), it starts by going up a
1195
+ # directory.
1196
+ return os.path.normpath(name).split(os.sep, 1)[0] == os.pardir
1197
+
1198
+
1199
+ def _warn_tzpath_escape(name):
1200
+ # As in dateutil.zoneinfo.rebuild, the filter is appended at call time,
1201
+ # so any filter the user has installed for this category wins.
1202
+ warnings.filterwarnings(
1203
+ "error", category=DeprecatedTzKeyWarning, append=True
1204
+ )
1205
+ warnings.warn(
1206
+ "gettz(%r) refers to a file outside of TZPATH; support for keys "
1207
+ "like this is deprecated and will be removed in a future version. "
1208
+ "Use an absolute path instead." % (name,),
1209
+ DeprecatedTzKeyWarning,
1210
+ stacklevel=4,
1211
+ )
1212
+
1213
+
1214
+ def available_iana_timezones():
1215
+ """Returns a set containing all available IANA time zones keys.
1216
+
1217
+ These are suitable for use with :func:`gettz`. This is essentially a direct
1218
+ port of :py:func:`zoneinfo.available_timezones`.
1219
+
1220
+ The search includes time zones found on :data:`TZPATH` as well as any
1221
+ time zones provided by the `tzdata <https://pypi.org/project/tzdata/>`_
1222
+ package if it is installed.
1223
+
1224
+ :return:
1225
+ Returns a mutable set containing strings of time zones. Each call will
1226
+ return a fresh set.
1227
+
1228
+ .. caution::
1229
+
1230
+ This may attempt to open a large number of files, since the best way to
1231
+ determine if a given file on the time zone search path is to open it
1232
+ and check for the "magic string" at the beginning.
1233
+
1234
+ .. note::
1235
+
1236
+ These values are not designed to be exposed to end-users; for
1237
+ user-facing elements, applications should use something like CLDR (the
1238
+ Unicode Common Locale Data Repository) to get more user-friendly
1239
+ strings.
1240
+ """
1241
+ # Start with loading from the tzdata package if it exists: this has a
1242
+ # pre-assembled list of zones that only requires opening one file.
1243
+ try:
1244
+ valid_zones = set(_tzdata_impl._load_tzdata_keys())
1245
+ except ImportError:
1246
+ valid_zones = set()
1247
+
1248
+ def valid_key(fpath):
1249
+ try:
1250
+ with open(fpath, "rb") as f:
1251
+ return f.read(4) == b"TZif"
1252
+ except Exception: # pragma: nocover
1253
+ return False
1254
+
1255
+ for tz_root in _tzpath.TZPATH:
1256
+ if not os.path.exists(tz_root):
1257
+ continue
1258
+
1259
+ for root, dirnames, files in os.walk(tz_root):
1260
+ if root == tz_root:
1261
+ # right/ and posix/ are special directories and shouldn't be
1262
+ # included in the output of available zones
1263
+ if "right" in dirnames:
1264
+ dirnames.remove("right")
1265
+ if "posix" in dirnames:
1266
+ dirnames.remove("posix")
1267
+
1268
+ for file in files:
1269
+ fpath = os.path.join(root, file)
1270
+
1271
+ key = os.path.relpath(fpath, start=tz_root)
1272
+ if os.sep != "/": # pragma: nocover
1273
+ key = key.replace(os.sep, "/")
1274
+
1275
+ if not key or key in valid_zones:
1276
+ continue
1277
+
1278
+ if valid_key(fpath):
1279
+ valid_zones.add(key)
1280
+
1281
+ if "posixrules" in valid_zones:
1282
+ # posixrules is a special symlink-only time zone where it exists, it
1283
+ # should not be included in the output
1284
+ valid_zones.remove("posixrules")
1285
+ if "localtime" in valid_zones:
1286
+ # localtime is a special symlink-only time zone where it exists, it
1287
+ # should not be included in the output
1288
+ valid_zones.remove("localtime")
1289
+
1290
+ return valid_zones
1291
+
1292
+
1293
+ def datetime_exists(dt, tz=None):
1294
+ """
1295
+ Given a datetime and a time zone, determine whether or not a given datetime
1296
+ would fall in a gap.
1297
+
1298
+ :param dt:
1299
+ A :class:`datetime.datetime` (whose time zone will be ignored if ``tz``
1300
+ is provided.)
1301
+
1302
+ :param tz:
1303
+ A :class:`datetime.tzinfo` with support for the ``fold`` attribute. If
1304
+ ``None`` or not provided, the datetime's own time zone will be used.
1305
+
1306
+ :return:
1307
+ Returns a boolean value whether or not the "wall time" exists in
1308
+ ``tz``.
1309
+
1310
+ .. versionadded:: 2.7.0
1311
+ """
1312
+ if tz is None:
1313
+ if dt.tzinfo is None:
1314
+ raise ValueError('Datetime is naive and no time zone provided.')
1315
+ tz = dt.tzinfo
1316
+
1317
+ dt = dt.replace(tzinfo=None)
1318
+
1319
+ # This is essentially a test of whether or not the datetime can survive
1320
+ # a round trip to UTC.
1321
+ dt_rt = dt.replace(tzinfo=tz).astimezone(UTC).astimezone(tz)
1322
+ dt_rt = dt_rt.replace(tzinfo=None)
1323
+
1324
+ return dt == dt_rt
1325
+
1326
+
1327
+ def datetime_ambiguous(dt, tz=None):
1328
+ """
1329
+ Given a datetime and a time zone, determine whether or not a given datetime
1330
+ is ambiguous (i.e if there are two times differentiated only by their DST
1331
+ status).
1332
+
1333
+ :param dt:
1334
+ A :class:`datetime.datetime` (whose time zone will be ignored if ``tz``
1335
+ is provided.)
1336
+
1337
+ :param tz:
1338
+ A :class:`datetime.tzinfo` with support for the ``fold`` attribute. If
1339
+ ``None`` or not provided, the datetime's own time zone will be used.
1340
+
1341
+ :return:
1342
+ Returns a boolean value whether or not the "wall time" is ambiguous in
1343
+ ``tz``.
1344
+
1345
+ .. versionadded:: 2.6.0
1346
+ """
1347
+ if tz is None:
1348
+ if dt.tzinfo is None:
1349
+ raise ValueError('Datetime is naive and no time zone provided.')
1350
+
1351
+ tz = dt.tzinfo
1352
+
1353
+ # If a time zone defines its own "is_ambiguous" function, we'll use that.
1354
+ is_ambiguous_fn = getattr(tz, 'is_ambiguous', None)
1355
+ if is_ambiguous_fn is not None:
1356
+ try:
1357
+ return tz.is_ambiguous(dt)
1358
+ except Exception:
1359
+ pass
1360
+
1361
+ # If it doesn't come out and tell us it's ambiguous, we'll just check if
1362
+ # the fold attribute has any effect on this particular date and time.
1363
+ dt = dt.replace(tzinfo=tz)
1364
+ wall_0 = enfold(dt, fold=0)
1365
+ wall_1 = enfold(dt, fold=1)
1366
+
1367
+ same_offset = wall_0.utcoffset() == wall_1.utcoffset()
1368
+ same_dst = wall_0.dst() == wall_1.dst()
1369
+
1370
+ return not (same_offset and same_dst)
1371
+
1372
+
1373
+ def resolve_imaginary(dt):
1374
+ """
1375
+ Given a datetime that may be imaginary, return an existing datetime.
1376
+
1377
+ This function assumes that an imaginary datetime represents what the
1378
+ wall time would be in a zone had the offset transition not occurred, so
1379
+ it will always fall forward by the transition's change in offset.
1380
+
1381
+ .. doctest::
1382
+
1383
+ >>> from dateutil import tz
1384
+ >>> from datetime import datetime
1385
+ >>> NYC = tz.gettz('America/New_York')
1386
+ >>> print(tz.resolve_imaginary(datetime(2017, 3, 12, 2, 30, tzinfo=NYC)))
1387
+ 2017-03-12 03:30:00-04:00
1388
+
1389
+ >>> KIR = tz.gettz('Pacific/Kiritimati')
1390
+ >>> print(tz.resolve_imaginary(datetime(1995, 1, 1, 12, 30, tzinfo=KIR)))
1391
+ 1995-01-02 12:30:00+14:00
1392
+
1393
+ As a note, :func:`datetime.astimezone` is guaranteed to produce a valid,
1394
+ existing datetime, so a round-trip to and from UTC is sufficient to get
1395
+ an extant datetime, however, this generally "falls back" to an earlier time
1396
+ rather than falling forward to the STD side (though no guarantees are made
1397
+ about this behavior).
1398
+
1399
+ :param dt:
1400
+ A :class:`datetime.datetime` which may or may not exist.
1401
+
1402
+ :return:
1403
+ Returns an existing :class:`datetime.datetime`. If ``dt`` was not
1404
+ imaginary, the datetime returned is guaranteed to be the same object
1405
+ passed to the function.
1406
+
1407
+ .. versionadded:: 2.7.0
1408
+ """
1409
+ if dt.tzinfo is not None and not datetime_exists(dt):
1410
+
1411
+ curr_offset = (dt + datetime.timedelta(hours=24)).utcoffset()
1412
+ old_offset = (dt - datetime.timedelta(hours=24)).utcoffset()
1413
+
1414
+ dt += curr_offset - old_offset
1415
+
1416
+ return dt
1417
+
1418
+
1419
+ def _datetime_to_timestamp(dt):
1420
+ """
1421
+ Convert a :class:`datetime.datetime` object to an epoch timestamp in
1422
+ seconds since January 1, 1970, ignoring the time zone.
1423
+ """
1424
+ return (dt.replace(tzinfo=None) - EPOCH).total_seconds()
1425
+
1426
+
1427
+ if sys.version_info >= (3, 6):
1428
+ def _get_supported_offset(second_offset):
1429
+ return second_offset
1430
+ else:
1431
+ def _get_supported_offset(second_offset):
1432
+ # For python pre-3.6, round to full-minutes if that's not the case.
1433
+ # Python's datetime doesn't accept sub-minute timezones. Check
1434
+ # http://python.org/sf/1447945 or https://bugs.python.org/issue5288
1435
+ # for some information.
1436
+ old_offset = second_offset
1437
+ calculated_offset = 60 * ((second_offset + 30) // 60)
1438
+ return calculated_offset
1439
+
1440
+
1441
+ if sys.version_info < (3, 8):
1442
+
1443
+ def _isfile(path):
1444
+ # bpo-33721: In Python 3.8 non-UTF8 paths return False rather than
1445
+ # raising an error. See https://bugs.python.org/issue33721
1446
+ try:
1447
+ return os.path.isfile(path)
1448
+ except ValueError:
1449
+ return False
1450
+
1451
+ else:
1452
+ _isfile = os.path.isfile
1453
+
1454
+
1455
+ try:
1456
+ # Python 3.7 feature
1457
+ from contextlib import nullcontext as _nullcontext
1458
+ except ImportError:
1459
+ class _nullcontext(object):
1460
+ """
1461
+ Class for wrapping contexts so that they are passed through in a
1462
+ with statement.
1463
+ """
1464
+ def __init__(self, context):
1465
+ self.context = context
1466
+
1467
+ def __enter__(self):
1468
+ return self.context
1469
+
1470
+ def __exit__(*args, **kwargs):
1471
+ pass
1472
+
1473
+ # vim:ts=4:sw=4:et