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,1765 @@
1
+ # Vendored by tools/vendor_deps.py from python-dateutil 3.0.0 (see licenses/LICENSE_DATEUTIL).
2
+ # -*- coding: utf-8 -*-
3
+ """
4
+ The rrule module offers a small, complete, and very fast, implementation of
5
+ the recurrence rules documented in the
6
+ `iCalendar RFC <https://tools.ietf.org/html/rfc5545>`_,
7
+ including support for caching of results.
8
+ """
9
+ import calendar
10
+ import datetime
11
+ import heapq
12
+ import itertools
13
+ import re
14
+ import sys
15
+ from functools import wraps
16
+ # For warning about deprecation of until and count
17
+ from warnings import warn
18
+
19
+ from matplotlib_rs._vendor.six import advance_iterator, integer_types
20
+
21
+ from matplotlib_rs._vendor.six.moves import _thread, range
22
+
23
+ from ._common import weekday as weekdaybase
24
+
25
+ try:
26
+ from math import gcd
27
+ except ImportError:
28
+ from fractions import gcd
29
+
30
+ __all__ = ["rrule", "rruleset", "rrulestr",
31
+ "YEARLY", "MONTHLY", "WEEKLY", "DAILY",
32
+ "HOURLY", "MINUTELY", "SECONDLY",
33
+ "MO", "TU", "WE", "TH", "FR", "SA", "SU"]
34
+
35
+ # Every mask is 7 days longer to handle cross-year weekly periods.
36
+ M366MASK = tuple([1]*31+[2]*29+[3]*31+[4]*30+[5]*31+[6]*30 +
37
+ [7]*31+[8]*31+[9]*30+[10]*31+[11]*30+[12]*31+[1]*7)
38
+ M365MASK = list(M366MASK)
39
+ M29, M30, M31 = list(range(1, 30)), list(range(1, 31)), list(range(1, 32))
40
+ MDAY366MASK = tuple(M31+M29+M31+M30+M31+M30+M31+M31+M30+M31+M30+M31+M31[:7])
41
+ MDAY365MASK = list(MDAY366MASK)
42
+ M29, M30, M31 = list(range(-29, 0)), list(range(-30, 0)), list(range(-31, 0))
43
+ NMDAY366MASK = tuple(M31+M29+M31+M30+M31+M30+M31+M31+M30+M31+M30+M31+M31[:7])
44
+ NMDAY365MASK = list(NMDAY366MASK)
45
+ M366RANGE = (0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366)
46
+ M365RANGE = (0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365)
47
+ WDAYMASK = [0, 1, 2, 3, 4, 5, 6]*55
48
+ del M29, M30, M31, M365MASK[59], MDAY365MASK[59], NMDAY365MASK[31]
49
+ MDAY365MASK = tuple(MDAY365MASK)
50
+ M365MASK = tuple(M365MASK)
51
+
52
+ FREQNAMES = ['YEARLY', 'MONTHLY', 'WEEKLY', 'DAILY', 'HOURLY', 'MINUTELY', 'SECONDLY']
53
+
54
+ (YEARLY,
55
+ MONTHLY,
56
+ WEEKLY,
57
+ DAILY,
58
+ HOURLY,
59
+ MINUTELY,
60
+ SECONDLY) = list(range(7))
61
+
62
+ # Imported on demand.
63
+ easter = None
64
+ parser = None
65
+
66
+
67
+ class weekday(weekdaybase):
68
+ """
69
+ This version of weekday does not allow n = 0.
70
+ """
71
+ def __init__(self, wkday, n=None):
72
+ if n == 0:
73
+ raise ValueError("Can't create weekday with n==0")
74
+
75
+ super(weekday, self).__init__(wkday, n)
76
+
77
+
78
+ MO, TU, WE, TH, FR, SA, SU = weekdays = tuple(weekday(x) for x in range(7))
79
+
80
+
81
+ def _invalidates_cache(f):
82
+ """
83
+ Decorator for rruleset methods which may invalidate the
84
+ cached length.
85
+ """
86
+ @wraps(f)
87
+ def inner_func(self, *args, **kwargs):
88
+ rv = f(self, *args, **kwargs)
89
+ self._invalidate_cache()
90
+ return rv
91
+
92
+ return inner_func
93
+
94
+
95
+ class rrulebase(object):
96
+ def __init__(self, cache=False):
97
+ if cache:
98
+ self._cache = []
99
+ self._cache_lock = _thread.allocate_lock()
100
+ self._invalidate_cache()
101
+ else:
102
+ self._cache = None
103
+ self._cache_complete = False
104
+ self._len = None
105
+
106
+ def __reduce_ex__(self, protocol):
107
+ rv = super(rrulebase, self).__reduce_ex__(protocol)
108
+ state, slots = rv[2], None
109
+ if isinstance(state, tuple):
110
+ state, slots = state
111
+ if self._cache is not None:
112
+ state = dict(state)
113
+ state.pop("_cache_lock", None)
114
+ state.pop("_cache_gen", None)
115
+ state["_cache"] = []
116
+ if slots is not None:
117
+ state = (state, slots)
118
+ return rv[:2] + (state,) + rv[3:]
119
+
120
+ def __setstate__(self, state):
121
+ if isinstance(state, tuple):
122
+ state, slots = state
123
+ for name, value in slots.items():
124
+ setattr(self, name, value)
125
+ self.__dict__.update(state)
126
+ if self._cache is not None:
127
+ self._cache_lock = _thread.allocate_lock()
128
+ self._invalidate_cache()
129
+
130
+ def __iter__(self):
131
+ if self._cache_complete:
132
+ return iter(self._cache)
133
+ elif self._cache is None:
134
+ return self._iter()
135
+ else:
136
+ return self._iter_cached()
137
+
138
+ def _invalidate_cache(self):
139
+ if self._cache is not None:
140
+ self._cache = []
141
+ self._cache_complete = False
142
+ self._cache_gen = self._iter()
143
+
144
+ if self._cache_lock.locked():
145
+ self._cache_lock.release()
146
+
147
+ self._len = None
148
+
149
+ def _iter_cached(self):
150
+ i = 0
151
+ gen = self._cache_gen
152
+ cache = self._cache
153
+ acquire = self._cache_lock.acquire
154
+ release = self._cache_lock.release
155
+ while gen:
156
+ if i == len(cache):
157
+ acquire()
158
+ if self._cache_complete:
159
+ break
160
+ try:
161
+ for j in range(10):
162
+ cache.append(advance_iterator(gen))
163
+ except StopIteration:
164
+ self._cache_gen = gen = None
165
+ self._cache_complete = True
166
+ break
167
+ release()
168
+ yield cache[i]
169
+ i += 1
170
+ while i < self._len:
171
+ yield cache[i]
172
+ i += 1
173
+
174
+ def __getitem__(self, item):
175
+ if self._cache_complete:
176
+ return self._cache[item]
177
+ elif isinstance(item, slice):
178
+ if item.step and item.step < 0:
179
+ return list(iter(self))[item]
180
+ else:
181
+ return list(itertools.islice(self,
182
+ item.start or 0,
183
+ item.stop or sys.maxsize,
184
+ item.step or 1))
185
+ elif item >= 0:
186
+ gen = iter(self)
187
+ try:
188
+ for i in range(item+1):
189
+ res = advance_iterator(gen)
190
+ except StopIteration:
191
+ raise IndexError
192
+ return res
193
+ else:
194
+ return list(iter(self))[item]
195
+
196
+ def __contains__(self, item):
197
+ if self._cache_complete:
198
+ return item in self._cache
199
+ else:
200
+ for i in self:
201
+ if i == item:
202
+ return True
203
+ elif i > item:
204
+ return False
205
+ return False
206
+
207
+ # __len__() introduces a large performance penalty.
208
+ def count(self):
209
+ """ Returns the number of recurrences in this set. It will have go
210
+ through the whole recurrence, if this hasn't been done before. """
211
+ if self._len is None:
212
+ for x in self:
213
+ pass
214
+ return self._len
215
+
216
+ def before(self, dt, inc=False):
217
+ """ Returns the last recurrence before the given datetime instance. The
218
+ inc keyword defines what happens if dt is an occurrence. With
219
+ inc=True, if dt itself is an occurrence, it will be returned. """
220
+ if self._cache_complete:
221
+ gen = self._cache
222
+ else:
223
+ gen = self
224
+ last = None
225
+ if inc:
226
+ for i in gen:
227
+ if i > dt:
228
+ break
229
+ last = i
230
+ else:
231
+ for i in gen:
232
+ if i >= dt:
233
+ break
234
+ last = i
235
+ return last
236
+
237
+ def after(self, dt, inc=False):
238
+ """ Returns the first recurrence after the given datetime instance. The
239
+ inc keyword defines what happens if dt is an occurrence. With
240
+ inc=True, if dt itself is an occurrence, it will be returned. """
241
+ if self._cache_complete:
242
+ gen = self._cache
243
+ else:
244
+ gen = self
245
+ if inc:
246
+ for i in gen:
247
+ if i >= dt:
248
+ return i
249
+ else:
250
+ for i in gen:
251
+ if i > dt:
252
+ return i
253
+ return None
254
+
255
+ def xafter(self, dt, count=None, inc=False):
256
+ """
257
+ Generator which yields up to `count` recurrences after the given
258
+ datetime instance, equivalent to `after`.
259
+
260
+ :param dt:
261
+ The datetime at which to start generating recurrences.
262
+
263
+ :param count:
264
+ The maximum number of recurrences to generate. If `None` (default),
265
+ dates are generated until the recurrence rule is exhausted.
266
+
267
+ :param inc:
268
+ If `dt` is an instance of the rule and `inc` is `True`, it is
269
+ included in the output.
270
+
271
+ :yields: Yields a sequence of `datetime` objects.
272
+ """
273
+
274
+ if self._cache_complete:
275
+ gen = self._cache
276
+ else:
277
+ gen = self
278
+
279
+ # Select the comparison function
280
+ if inc:
281
+ comp = lambda dc, dtc: dc >= dtc
282
+ else:
283
+ comp = lambda dc, dtc: dc > dtc
284
+
285
+ # Generate dates
286
+ n = 0
287
+ for d in gen:
288
+ if comp(d, dt):
289
+ if count is not None:
290
+ n += 1
291
+ if n > count:
292
+ break
293
+
294
+ yield d
295
+
296
+ def between(self, after, before, inc=False, count=1):
297
+ """ Returns all the occurrences of the rrule between after and before.
298
+ The inc keyword defines what happens if after and/or before are
299
+ themselves occurrences. With inc=True, they will be included in the
300
+ list, if they are found in the recurrence set. """
301
+ if self._cache_complete:
302
+ gen = self._cache
303
+ else:
304
+ gen = self
305
+ started = False
306
+ l = []
307
+ if inc:
308
+ for i in gen:
309
+ if i > before:
310
+ break
311
+ elif not started:
312
+ if i >= after:
313
+ started = True
314
+ l.append(i)
315
+ else:
316
+ l.append(i)
317
+ else:
318
+ for i in gen:
319
+ if i >= before:
320
+ break
321
+ elif not started:
322
+ if i > after:
323
+ started = True
324
+ l.append(i)
325
+ else:
326
+ l.append(i)
327
+ return l
328
+
329
+
330
+ class rrule(rrulebase):
331
+ """
332
+ That's the base of the rrule operation. It accepts all the keywords
333
+ defined in the RFC as its constructor parameters (except byday,
334
+ which was renamed to byweekday) and more. The constructor prototype is::
335
+
336
+ rrule(freq)
337
+
338
+ Where freq must be one of YEARLY, MONTHLY, WEEKLY, DAILY, HOURLY, MINUTELY,
339
+ or SECONDLY.
340
+
341
+ .. note::
342
+ Per RFC section 3.3.10, recurrence instances falling on invalid dates
343
+ and times are ignored rather than coerced:
344
+
345
+ Recurrence rules may generate recurrence instances with an invalid
346
+ date (e.g., February 30) or nonexistent local time (e.g., 1:30 AM
347
+ on a day where the local time is moved forward by an hour at 1:00
348
+ AM). Such recurrence instances MUST be ignored and MUST NOT be
349
+ counted as part of the recurrence set.
350
+
351
+ This can lead to possibly surprising behavior when, for example, the
352
+ start date occurs at the end of the month:
353
+
354
+ >>> from dateutil.rrule import rrule, MONTHLY
355
+ >>> from datetime import datetime
356
+ >>> start_date = datetime(2014, 12, 31)
357
+ >>> list(rrule(freq=MONTHLY, count=4, dtstart=start_date))
358
+ ... # doctest: +NORMALIZE_WHITESPACE
359
+ [datetime.datetime(2014, 12, 31, 0, 0),
360
+ datetime.datetime(2015, 1, 31, 0, 0),
361
+ datetime.datetime(2015, 3, 31, 0, 0),
362
+ datetime.datetime(2015, 5, 31, 0, 0)]
363
+
364
+ Additionally, it supports the following keyword arguments:
365
+
366
+ :param dtstart:
367
+ The recurrence start. Besides being the base for the recurrence,
368
+ missing parameters in the final recurrence instances will also be
369
+ extracted from this date. If not given, datetime.now() will be used
370
+ instead.
371
+ :param interval:
372
+ The interval between each freq iteration. For example, when using
373
+ YEARLY, an interval of 2 means once every two years, but with HOURLY,
374
+ it means once every two hours. The default interval is 1.
375
+ :param wkst:
376
+ The week start day. Must be one of the MO, TU, WE constants, or an
377
+ integer, specifying the first day of the week. This will affect
378
+ recurrences based on weekly periods. The default week start is got
379
+ from calendar.firstweekday(), and may be modified by
380
+ calendar.setfirstweekday().
381
+ :param count:
382
+ If given, this determines how many occurrences will be generated.
383
+
384
+ .. note::
385
+ As of version 2.5.0, the use of the keyword ``until`` in conjunction
386
+ with ``count`` is deprecated, to make sure ``dateutil`` is fully
387
+ compliant with `RFC-5545 Sec. 3.3.10 <https://tools.ietf.org/
388
+ html/rfc5545#section-3.3.10>`_. Therefore, ``until`` and ``count``
389
+ **must not** occur in the same call to ``rrule``.
390
+ :param until:
391
+ If given, this must be a datetime instance specifying the upper-bound
392
+ limit of the recurrence. The last recurrence in the rule is the greatest
393
+ datetime that is less than or equal to the value specified in the
394
+ ``until`` parameter.
395
+
396
+ .. note::
397
+ As of version 2.5.0, the use of the keyword ``until`` in conjunction
398
+ with ``count`` is deprecated, to make sure ``dateutil`` is fully
399
+ compliant with `RFC-5545 Sec. 3.3.10 <https://tools.ietf.org/
400
+ html/rfc5545#section-3.3.10>`_. Therefore, ``until`` and ``count``
401
+ **must not** occur in the same call to ``rrule``.
402
+ :param bysetpos:
403
+ If given, it must be either an integer, or a sequence of integers,
404
+ positive or negative. Each given integer will specify an occurrence
405
+ number, corresponding to the nth occurrence of the rule inside the
406
+ frequency period. For example, a bysetpos of -1 if combined with a
407
+ MONTHLY frequency, and a byweekday of (MO, TU, WE, TH, FR), will
408
+ result in the last work day of every month.
409
+ :param bymonth:
410
+ If given, it must be either an integer, or a sequence of integers,
411
+ meaning the months to apply the recurrence to.
412
+ :param bymonthday:
413
+ If given, it must be either an integer, or a sequence of integers,
414
+ meaning the month days to apply the recurrence to.
415
+ :param byyearday:
416
+ If given, it must be either an integer, or a sequence of integers,
417
+ meaning the year days to apply the recurrence to.
418
+ :param byeaster:
419
+ If given, it must be either an integer, or a sequence of integers,
420
+ positive or negative. Each integer will define an offset from the
421
+ Easter Sunday. Passing the offset 0 to byeaster will yield the Easter
422
+ Sunday itself. This is an extension to the RFC specification.
423
+ :param byweekno:
424
+ If given, it must be either an integer, or a sequence of integers,
425
+ meaning the week numbers to apply the recurrence to. Week numbers
426
+ have the meaning described in ISO8601, that is, the first week of
427
+ the year is that containing at least four days of the new year.
428
+ :param byweekday:
429
+ If given, it must be either an integer (0 == MO), a sequence of
430
+ integers, one of the weekday constants (MO, TU, etc), or a sequence
431
+ of these constants. When given, these variables will define the
432
+ weekdays where the recurrence will be applied. It's also possible to
433
+ use an argument n for the weekday instances, which will mean the nth
434
+ occurrence of this weekday in the period. For example, with MONTHLY,
435
+ or with YEARLY and BYMONTH, using FR(+1) in byweekday will specify the
436
+ first friday of the month where the recurrence happens. Notice that in
437
+ the RFC documentation, this is specified as BYDAY, but was renamed to
438
+ avoid the ambiguity of that keyword.
439
+ :param byhour:
440
+ If given, it must be either an integer, or a sequence of integers,
441
+ meaning the hours to apply the recurrence to.
442
+ :param byminute:
443
+ If given, it must be either an integer, or a sequence of integers,
444
+ meaning the minutes to apply the recurrence to.
445
+ :param bysecond:
446
+ If given, it must be either an integer, or a sequence of integers,
447
+ meaning the seconds to apply the recurrence to.
448
+ :param cache:
449
+ If given, it must be a boolean value specifying to enable or disable
450
+ caching of results. If you will use the same rrule instance multiple
451
+ times, enabling caching will improve the performance considerably.
452
+ """
453
+ def __init__(self, freq, dtstart=None,
454
+ interval=1, wkst=None, count=None, until=None, bysetpos=None,
455
+ bymonth=None, bymonthday=None, byyearday=None, byeaster=None,
456
+ byweekno=None, byweekday=None,
457
+ byhour=None, byminute=None, bysecond=None,
458
+ cache=False):
459
+ super(rrule, self).__init__(cache)
460
+ global easter
461
+ if not dtstart:
462
+ if until and until.tzinfo:
463
+ dtstart = datetime.datetime.now(tz=until.tzinfo).replace(microsecond=0)
464
+ else:
465
+ dtstart = datetime.datetime.now().replace(microsecond=0)
466
+ elif not isinstance(dtstart, datetime.datetime):
467
+ dtstart = datetime.datetime.fromordinal(dtstart.toordinal())
468
+ else:
469
+ dtstart = dtstart.replace(microsecond=0)
470
+ self._dtstart = dtstart
471
+ self._tzinfo = dtstart.tzinfo
472
+ self._freq = freq
473
+ self._interval = interval
474
+ self._count = count
475
+
476
+ # Cache the original byxxx rules, if they are provided, as the _byxxx
477
+ # attributes do not necessarily map to the inputs, and this can be
478
+ # a problem in generating the strings. Only store things if they've
479
+ # been supplied (the string retrieval will just use .get())
480
+ self._original_rule = {}
481
+
482
+ if until and not isinstance(until, datetime.datetime):
483
+ until = datetime.datetime.fromordinal(until.toordinal())
484
+ self._until = until
485
+
486
+ if self._dtstart and self._until:
487
+ if (self._dtstart.tzinfo is not None) != (self._until.tzinfo is not None):
488
+ # According to RFC5545 Section 3.3.10:
489
+ # https://tools.ietf.org/html/rfc5545#section-3.3.10
490
+ #
491
+ # > If the "DTSTART" property is specified as a date with UTC
492
+ # > time or a date with local time and time zone reference,
493
+ # > then the UNTIL rule part MUST be specified as a date with
494
+ # > UTC time.
495
+ raise ValueError(
496
+ 'RRULE UNTIL values must be specified in UTC when DTSTART '
497
+ 'is timezone-aware'
498
+ )
499
+
500
+ if count is not None and until:
501
+ warn("Using both 'count' and 'until' is inconsistent with RFC 5545"
502
+ " and has been deprecated in dateutil. Future versions will "
503
+ "raise an error.", DeprecationWarning)
504
+
505
+ if wkst is None:
506
+ self._wkst = calendar.firstweekday()
507
+ elif isinstance(wkst, integer_types):
508
+ self._wkst = wkst
509
+ else:
510
+ self._wkst = wkst.weekday
511
+
512
+ if bysetpos is None:
513
+ self._bysetpos = None
514
+ elif isinstance(bysetpos, integer_types):
515
+ if bysetpos == 0 or not (-366 <= bysetpos <= 366):
516
+ raise ValueError("bysetpos must be between 1 and 366, "
517
+ "or between -366 and -1")
518
+ self._bysetpos = (bysetpos,)
519
+ else:
520
+ self._bysetpos = tuple(bysetpos)
521
+ for pos in self._bysetpos:
522
+ if pos == 0 or not (-366 <= pos <= 366):
523
+ raise ValueError("bysetpos must be between 1 and 366, "
524
+ "or between -366 and -1")
525
+
526
+ if self._bysetpos:
527
+ self._original_rule['bysetpos'] = self._bysetpos
528
+
529
+ if (byweekno is None and byyearday is None and bymonthday is None and
530
+ byweekday is None and byeaster is None):
531
+ if freq == YEARLY:
532
+ if bymonth is None:
533
+ bymonth = dtstart.month
534
+ self._original_rule['bymonth'] = None
535
+ bymonthday = dtstart.day
536
+ self._original_rule['bymonthday'] = None
537
+ elif freq == MONTHLY:
538
+ bymonthday = dtstart.day
539
+ self._original_rule['bymonthday'] = None
540
+ elif freq == WEEKLY:
541
+ byweekday = dtstart.weekday()
542
+ self._original_rule['byweekday'] = None
543
+
544
+ # bymonth
545
+ if bymonth is None:
546
+ self._bymonth = None
547
+ else:
548
+ if isinstance(bymonth, integer_types):
549
+ bymonth = (bymonth,)
550
+
551
+ self._bymonth = tuple(sorted(set(bymonth)))
552
+
553
+ if 'bymonth' not in self._original_rule:
554
+ self._original_rule['bymonth'] = self._bymonth
555
+
556
+ # byyearday
557
+ if byyearday is None:
558
+ self._byyearday = None
559
+ else:
560
+ if isinstance(byyearday, integer_types):
561
+ byyearday = (byyearday,)
562
+
563
+ self._byyearday = tuple(sorted(set(byyearday)))
564
+ self._original_rule['byyearday'] = self._byyearday
565
+
566
+ # byeaster
567
+ if byeaster is not None:
568
+ if not easter:
569
+ from matplotlib_rs._vendor.dateutil import easter
570
+ if isinstance(byeaster, integer_types):
571
+ self._byeaster = (byeaster,)
572
+ else:
573
+ self._byeaster = tuple(sorted(byeaster))
574
+
575
+ self._original_rule['byeaster'] = self._byeaster
576
+ else:
577
+ self._byeaster = None
578
+
579
+ # bymonthday
580
+ if bymonthday is None:
581
+ self._bymonthday = ()
582
+ self._bynmonthday = ()
583
+ else:
584
+ if isinstance(bymonthday, integer_types):
585
+ bymonthday = (bymonthday,)
586
+
587
+ bymonthday = set(bymonthday) # Ensure it's unique
588
+
589
+ self._bymonthday = tuple(sorted(x for x in bymonthday if x > 0))
590
+ self._bynmonthday = tuple(sorted(x for x in bymonthday if x < 0))
591
+
592
+ # Storing positive numbers first, then negative numbers
593
+ if 'bymonthday' not in self._original_rule:
594
+ self._original_rule['bymonthday'] = tuple(
595
+ itertools.chain(self._bymonthday, self._bynmonthday))
596
+
597
+ # byweekno
598
+ if byweekno is None:
599
+ self._byweekno = None
600
+ else:
601
+ if isinstance(byweekno, integer_types):
602
+ byweekno = (byweekno,)
603
+
604
+ self._byweekno = tuple(sorted(set(byweekno)))
605
+
606
+ self._original_rule['byweekno'] = self._byweekno
607
+
608
+ # byweekday / bynweekday
609
+ if byweekday is None:
610
+ self._byweekday = None
611
+ self._bynweekday = None
612
+ else:
613
+ # If it's one of the valid non-sequence types, convert to a
614
+ # single-element sequence before the iterator that builds the
615
+ # byweekday set.
616
+ if isinstance(byweekday, integer_types) or hasattr(byweekday, "n"):
617
+ byweekday = (byweekday,)
618
+
619
+ self._byweekday = set()
620
+ self._bynweekday = set()
621
+ for wday in byweekday:
622
+ if isinstance(wday, integer_types):
623
+ self._byweekday.add(wday)
624
+ elif not wday.n or freq > MONTHLY:
625
+ self._byweekday.add(wday.weekday)
626
+ else:
627
+ self._bynweekday.add((wday.weekday, wday.n))
628
+
629
+ if not self._byweekday:
630
+ self._byweekday = None
631
+ elif not self._bynweekday:
632
+ self._bynweekday = None
633
+
634
+ if self._byweekday is not None:
635
+ self._byweekday = tuple(sorted(self._byweekday))
636
+ orig_byweekday = [weekday(x) for x in self._byweekday]
637
+ else:
638
+ orig_byweekday = ()
639
+
640
+ if self._bynweekday is not None:
641
+ self._bynweekday = tuple(sorted(self._bynweekday))
642
+ orig_bynweekday = [weekday(*x) for x in self._bynweekday]
643
+ else:
644
+ orig_bynweekday = ()
645
+
646
+ if 'byweekday' not in self._original_rule:
647
+ self._original_rule['byweekday'] = tuple(itertools.chain(
648
+ orig_byweekday, orig_bynweekday))
649
+
650
+ # byhour
651
+ if byhour is None:
652
+ if freq < HOURLY:
653
+ self._byhour = {dtstart.hour}
654
+ else:
655
+ self._byhour = None
656
+ else:
657
+ if isinstance(byhour, integer_types):
658
+ byhour = (byhour,)
659
+
660
+ if freq == HOURLY:
661
+ self._byhour = self.__construct_byset(start=dtstart.hour,
662
+ byxxx=byhour,
663
+ base=24)
664
+ else:
665
+ self._byhour = set(byhour)
666
+
667
+ self._byhour = tuple(sorted(self._byhour))
668
+ self._original_rule['byhour'] = self._byhour
669
+
670
+ # byminute
671
+ if byminute is None:
672
+ if freq < MINUTELY:
673
+ self._byminute = {dtstart.minute}
674
+ else:
675
+ self._byminute = None
676
+ else:
677
+ if isinstance(byminute, integer_types):
678
+ byminute = (byminute,)
679
+
680
+ if freq == MINUTELY:
681
+ self._byminute = self.__construct_byset(start=dtstart.minute,
682
+ byxxx=byminute,
683
+ base=60)
684
+ else:
685
+ self._byminute = set(byminute)
686
+
687
+ self._byminute = tuple(sorted(self._byminute))
688
+ self._original_rule['byminute'] = self._byminute
689
+
690
+ # bysecond
691
+ if bysecond is None:
692
+ if freq < SECONDLY:
693
+ self._bysecond = ((dtstart.second,))
694
+ else:
695
+ self._bysecond = None
696
+ else:
697
+ if isinstance(bysecond, integer_types):
698
+ bysecond = (bysecond,)
699
+
700
+ self._bysecond = set(bysecond)
701
+
702
+ if freq == SECONDLY:
703
+ self._bysecond = self.__construct_byset(start=dtstart.second,
704
+ byxxx=bysecond,
705
+ base=60)
706
+ else:
707
+ self._bysecond = set(bysecond)
708
+
709
+ self._bysecond = tuple(sorted(self._bysecond))
710
+ self._original_rule['bysecond'] = self._bysecond
711
+
712
+ if self._freq >= HOURLY:
713
+ self._timeset = None
714
+ else:
715
+ self._timeset = []
716
+ for hour in self._byhour:
717
+ for minute in self._byminute:
718
+ for second in self._bysecond:
719
+ self._timeset.append(
720
+ datetime.time(hour, minute, second,
721
+ tzinfo=self._tzinfo))
722
+ self._timeset.sort()
723
+ self._timeset = tuple(self._timeset)
724
+
725
+ def __str__(self):
726
+ """
727
+ Output a string that would generate this RRULE if passed to rrulestr.
728
+ This is mostly compatible with RFC5545, except for the
729
+ dateutil-specific extension BYEASTER.
730
+ """
731
+
732
+ output = []
733
+ h, m, s = [None] * 3
734
+ if self._dtstart:
735
+ output.append(self._dtstart.strftime('DTSTART:%Y%m%dT%H%M%S'))
736
+ h, m, s = self._dtstart.timetuple()[3:6]
737
+
738
+ parts = ['FREQ=' + FREQNAMES[self._freq]]
739
+ if self._interval != 1:
740
+ parts.append('INTERVAL=' + str(self._interval))
741
+
742
+ if self._wkst:
743
+ parts.append('WKST=' + repr(weekday(self._wkst))[0:2])
744
+
745
+ if self._count is not None:
746
+ parts.append('COUNT=' + str(self._count))
747
+
748
+ if self._until:
749
+ parts.append(self._until.strftime('UNTIL=%Y%m%dT%H%M%S'))
750
+
751
+ if self._original_rule.get('byweekday') is not None:
752
+ # The str() method on weekday objects doesn't generate
753
+ # RFC5545-compliant strings, so we should modify that.
754
+ original_rule = dict(self._original_rule)
755
+ wday_strings = []
756
+ for wday in original_rule['byweekday']:
757
+ if wday.n:
758
+ wday_strings.append('{n:+d}{wday}'.format(
759
+ n=wday.n,
760
+ wday=repr(wday)[0:2]))
761
+ else:
762
+ wday_strings.append(repr(wday))
763
+
764
+ original_rule['byweekday'] = wday_strings
765
+ else:
766
+ original_rule = self._original_rule
767
+
768
+ partfmt = '{name}={vals}'
769
+ for name, key in [('BYSETPOS', 'bysetpos'),
770
+ ('BYMONTH', 'bymonth'),
771
+ ('BYMONTHDAY', 'bymonthday'),
772
+ ('BYYEARDAY', 'byyearday'),
773
+ ('BYWEEKNO', 'byweekno'),
774
+ ('BYDAY', 'byweekday'),
775
+ ('BYHOUR', 'byhour'),
776
+ ('BYMINUTE', 'byminute'),
777
+ ('BYSECOND', 'bysecond'),
778
+ ('BYEASTER', 'byeaster')]:
779
+ value = original_rule.get(key)
780
+ if value:
781
+ parts.append(partfmt.format(name=name, vals=(','.join(str(v)
782
+ for v in value))))
783
+
784
+ output.append('RRULE:' + ';'.join(parts))
785
+ return '\n'.join(output)
786
+
787
+ def replace(self, **kwargs):
788
+ """Return new rrule with same attributes except for those attributes given new
789
+ values by whichever keyword arguments are specified."""
790
+ new_kwargs = {"interval": self._interval,
791
+ "count": self._count,
792
+ "dtstart": self._dtstart,
793
+ "freq": self._freq,
794
+ "until": self._until,
795
+ "wkst": self._wkst,
796
+ "cache": False if self._cache is None else True }
797
+ new_kwargs.update(self._original_rule)
798
+ new_kwargs.update(kwargs)
799
+ return rrule(**new_kwargs)
800
+
801
+ def _iter(self):
802
+ year, month, day, hour, minute, second, weekday, yearday, _ = \
803
+ self._dtstart.timetuple()
804
+
805
+ # Some local variables to speed things up a bit
806
+ freq = self._freq
807
+ interval = self._interval
808
+ wkst = self._wkst
809
+ until = self._until
810
+ bymonth = self._bymonth
811
+ byweekno = self._byweekno
812
+ byyearday = self._byyearday
813
+ byweekday = self._byweekday
814
+ byeaster = self._byeaster
815
+ bymonthday = self._bymonthday
816
+ bynmonthday = self._bynmonthday
817
+ bysetpos = self._bysetpos
818
+ byhour = self._byhour
819
+ byminute = self._byminute
820
+ bysecond = self._bysecond
821
+
822
+ ii = _iterinfo(self)
823
+ ii.rebuild(year, month)
824
+
825
+ getdayset = {YEARLY: ii.ydayset,
826
+ MONTHLY: ii.mdayset,
827
+ WEEKLY: ii.wdayset,
828
+ DAILY: ii.ddayset,
829
+ HOURLY: ii.ddayset,
830
+ MINUTELY: ii.ddayset,
831
+ SECONDLY: ii.ddayset}[freq]
832
+
833
+ if freq < HOURLY:
834
+ timeset = self._timeset
835
+ else:
836
+ gettimeset = {HOURLY: ii.htimeset,
837
+ MINUTELY: ii.mtimeset,
838
+ SECONDLY: ii.stimeset}[freq]
839
+ if ((freq >= HOURLY and
840
+ self._byhour and hour not in self._byhour) or
841
+ (freq >= MINUTELY and
842
+ self._byminute and minute not in self._byminute) or
843
+ (freq >= SECONDLY and
844
+ self._bysecond and second not in self._bysecond)):
845
+ timeset = ()
846
+ else:
847
+ timeset = gettimeset(hour, minute, second)
848
+
849
+ total = 0
850
+ count = self._count
851
+ while True:
852
+ # Get dayset with the right frequency
853
+ dayset, start, end = getdayset(year, month, day)
854
+
855
+ # Do the "hard" work ;-)
856
+ filtered = False
857
+ for i in dayset[start:end]:
858
+ if ((bymonth and ii.mmask[i] not in bymonth) or
859
+ (byweekno and not ii.wnomask[i]) or
860
+ (byweekday and ii.wdaymask[i] not in byweekday) or
861
+ (ii.nwdaymask and not ii.nwdaymask[i]) or
862
+ (byeaster and not ii.eastermask[i]) or
863
+ ((bymonthday or bynmonthday) and
864
+ ii.mdaymask[i] not in bymonthday and
865
+ ii.nmdaymask[i] not in bynmonthday) or
866
+ (byyearday and
867
+ ((i < ii.yearlen and i+1 not in byyearday and
868
+ -ii.yearlen+i not in byyearday) or
869
+ (i >= ii.yearlen and i+1-ii.yearlen not in byyearday and
870
+ -ii.nextyearlen+i-ii.yearlen not in byyearday)))):
871
+ dayset[i] = None
872
+ filtered = True
873
+
874
+ # Output results
875
+ if bysetpos and timeset:
876
+ poslist = []
877
+ for pos in bysetpos:
878
+ if pos < 0:
879
+ daypos, timepos = divmod(pos, len(timeset))
880
+ else:
881
+ daypos, timepos = divmod(pos-1, len(timeset))
882
+ try:
883
+ i = [x for x in dayset[start:end]
884
+ if x is not None][daypos]
885
+ time = timeset[timepos]
886
+ except IndexError:
887
+ pass
888
+ else:
889
+ date = datetime.date.fromordinal(ii.yearordinal+i)
890
+ res = datetime.datetime.combine(date, time)
891
+ if res not in poslist:
892
+ poslist.append(res)
893
+ poslist.sort()
894
+ for res in poslist:
895
+ if until and res > until:
896
+ self._len = total
897
+ return
898
+ elif res >= self._dtstart:
899
+ if count is not None:
900
+ count -= 1
901
+ if count < 0:
902
+ self._len = total
903
+ return
904
+ total += 1
905
+ yield res
906
+ else:
907
+ for i in dayset[start:end]:
908
+ if i is not None:
909
+ date = datetime.date.fromordinal(ii.yearordinal + i)
910
+ for time in timeset:
911
+ res = datetime.datetime.combine(date, time)
912
+ if until and res > until:
913
+ self._len = total
914
+ return
915
+ elif res >= self._dtstart:
916
+ if count is not None:
917
+ count -= 1
918
+ if count < 0:
919
+ self._len = total
920
+ return
921
+
922
+ total += 1
923
+ yield res
924
+
925
+ # Handle frequency and interval
926
+ fixday = False
927
+ if freq == YEARLY:
928
+ year += interval
929
+ if year > datetime.MAXYEAR:
930
+ self._len = total
931
+ return
932
+ ii.rebuild(year, month)
933
+ elif freq == MONTHLY:
934
+ month += interval
935
+ if month > 12:
936
+ div, mod = divmod(month, 12)
937
+ month = mod
938
+ year += div
939
+ if month == 0:
940
+ month = 12
941
+ year -= 1
942
+ if year > datetime.MAXYEAR:
943
+ self._len = total
944
+ return
945
+ ii.rebuild(year, month)
946
+ elif freq == WEEKLY:
947
+ if wkst > weekday:
948
+ day += -(weekday+1+(6-wkst))+self._interval*7
949
+ else:
950
+ day += -(weekday-wkst)+self._interval*7
951
+ weekday = wkst
952
+ fixday = True
953
+ elif freq == DAILY:
954
+ day += interval
955
+ fixday = True
956
+ elif freq == HOURLY:
957
+ if filtered:
958
+ # Jump to one iteration before next day
959
+ hour += ((23-hour)//interval)*interval
960
+
961
+ if byhour:
962
+ ndays, hour = self.__mod_distance(value=hour,
963
+ byxxx=self._byhour,
964
+ base=24)
965
+ else:
966
+ ndays, hour = divmod(hour+interval, 24)
967
+
968
+ if ndays:
969
+ day += ndays
970
+ fixday = True
971
+
972
+ timeset = gettimeset(hour, minute, second)
973
+ elif freq == MINUTELY:
974
+ if filtered:
975
+ # Jump to one iteration before next day
976
+ minute += ((1439-(hour*60+minute))//interval)*interval
977
+
978
+ valid = False
979
+ rep_rate = (24*60)
980
+ for j in range(rep_rate // gcd(interval, rep_rate)):
981
+ if byminute:
982
+ nhours, minute = \
983
+ self.__mod_distance(value=minute,
984
+ byxxx=self._byminute,
985
+ base=60)
986
+ else:
987
+ nhours, minute = divmod(minute+interval, 60)
988
+
989
+ div, hour = divmod(hour+nhours, 24)
990
+ if div:
991
+ day += div
992
+ fixday = True
993
+ filtered = False
994
+
995
+ if not byhour or hour in byhour:
996
+ valid = True
997
+ break
998
+
999
+ if not valid:
1000
+ raise ValueError('Invalid combination of interval and ' +
1001
+ 'byhour resulting in empty rule.')
1002
+
1003
+ timeset = gettimeset(hour, minute, second)
1004
+ elif freq == SECONDLY:
1005
+ if filtered:
1006
+ # Jump to one iteration before next day
1007
+ second += (((86399 - (hour * 3600 + minute * 60 + second))
1008
+ // interval) * interval)
1009
+
1010
+ rep_rate = (24 * 3600)
1011
+ valid = False
1012
+ for j in range(0, rep_rate // gcd(interval, rep_rate)):
1013
+ if bysecond:
1014
+ nminutes, second = \
1015
+ self.__mod_distance(value=second,
1016
+ byxxx=self._bysecond,
1017
+ base=60)
1018
+ else:
1019
+ nminutes, second = divmod(second+interval, 60)
1020
+
1021
+ div, minute = divmod(minute+nminutes, 60)
1022
+ if div:
1023
+ hour += div
1024
+ div, hour = divmod(hour, 24)
1025
+ if div:
1026
+ day += div
1027
+ fixday = True
1028
+
1029
+ if ((not byhour or hour in byhour) and
1030
+ (not byminute or minute in byminute) and
1031
+ (not bysecond or second in bysecond)):
1032
+ valid = True
1033
+ break
1034
+
1035
+ if not valid:
1036
+ raise ValueError('Invalid combination of interval, ' +
1037
+ 'byhour and byminute resulting in empty' +
1038
+ ' rule.')
1039
+
1040
+ timeset = gettimeset(hour, minute, second)
1041
+
1042
+ if fixday and day > 28:
1043
+ daysinmonth = calendar.monthrange(year, month)[1]
1044
+ if day > daysinmonth:
1045
+ while day > daysinmonth:
1046
+ day -= daysinmonth
1047
+ month += 1
1048
+ if month == 13:
1049
+ month = 1
1050
+ year += 1
1051
+ if year > datetime.MAXYEAR:
1052
+ self._len = total
1053
+ return
1054
+ daysinmonth = calendar.monthrange(year, month)[1]
1055
+ ii.rebuild(year, month)
1056
+
1057
+ def __construct_byset(self, start, byxxx, base):
1058
+ """
1059
+ If a `BYXXX` sequence is passed to the constructor at the same level as
1060
+ `FREQ` (e.g. `FREQ=HOURLY,BYHOUR={2,4,7},INTERVAL=3`), there are some
1061
+ specifications which cannot be reached given some starting conditions.
1062
+
1063
+ This occurs whenever the interval is not coprime with the base of a
1064
+ given unit and the difference between the starting position and the
1065
+ ending position is not coprime with the greatest common denominator
1066
+ between the interval and the base. For example, with a FREQ of hourly
1067
+ starting at 17:00 and an interval of 4, the only valid values for
1068
+ BYHOUR would be {21, 1, 5, 9, 13, 17}, because 4 and 24 are not
1069
+ coprime.
1070
+
1071
+ :param start:
1072
+ Specifies the starting position.
1073
+ :param byxxx:
1074
+ An iterable containing the list of allowed values.
1075
+ :param base:
1076
+ The largest allowable value for the specified frequency (e.g.
1077
+ 24 hours, 60 minutes).
1078
+
1079
+ This does not preserve the type of the iterable, returning a set, since
1080
+ the values should be unique and the order is irrelevant, this will
1081
+ speed up later lookups.
1082
+
1083
+ In the event of an empty set, raises a :exception:`ValueError`, as this
1084
+ results in an empty rrule.
1085
+ """
1086
+
1087
+ cset = set()
1088
+
1089
+ # Support a single byxxx value.
1090
+ if isinstance(byxxx, integer_types):
1091
+ byxxx = (byxxx, )
1092
+
1093
+ for num in byxxx:
1094
+ i_gcd = gcd(self._interval, base)
1095
+ # Use divmod rather than % because we need to wrap negative nums.
1096
+ if i_gcd == 1 or divmod(num - start, i_gcd)[1] == 0:
1097
+ cset.add(num)
1098
+
1099
+ if len(cset) == 0:
1100
+ raise ValueError("Invalid rrule byxxx generates an empty set.")
1101
+
1102
+ return cset
1103
+
1104
+ def __mod_distance(self, value, byxxx, base):
1105
+ """
1106
+ Calculates the next value in a sequence where the `FREQ` parameter is
1107
+ specified along with a `BYXXX` parameter at the same "level"
1108
+ (e.g. `HOURLY` specified with `BYHOUR`).
1109
+
1110
+ :param value:
1111
+ The old value of the component.
1112
+ :param byxxx:
1113
+ The `BYXXX` set, which should have been generated by
1114
+ `rrule._construct_byset`, or something else which checks that a
1115
+ valid rule is present.
1116
+ :param base:
1117
+ The largest allowable value for the specified frequency (e.g.
1118
+ 24 hours, 60 minutes).
1119
+
1120
+ If a valid value is not found after `base` iterations (the maximum
1121
+ number before the sequence would start to repeat), this raises a
1122
+ :exception:`ValueError`, as no valid values were found.
1123
+
1124
+ This returns a tuple of `divmod(n*interval, base)`, where `n` is the
1125
+ smallest number of `interval` repetitions until the next specified
1126
+ value in `byxxx` is found.
1127
+ """
1128
+ accumulator = 0
1129
+ for ii in range(1, base + 1):
1130
+ # Using divmod() over % to account for negative intervals
1131
+ div, value = divmod(value + self._interval, base)
1132
+ accumulator += div
1133
+ if value in byxxx:
1134
+ return (accumulator, value)
1135
+
1136
+
1137
+ class _iterinfo(object):
1138
+ __slots__ = ["rrule", "lastyear", "lastmonth",
1139
+ "yearlen", "nextyearlen", "yearordinal", "yearweekday",
1140
+ "mmask", "mrange", "mdaymask", "nmdaymask",
1141
+ "wdaymask", "wnomask", "nwdaymask", "eastermask"]
1142
+
1143
+ def __init__(self, rrule):
1144
+ for attr in self.__slots__:
1145
+ setattr(self, attr, None)
1146
+ self.rrule = rrule
1147
+
1148
+ def rebuild(self, year, month):
1149
+ # Every mask is 7 days longer to handle cross-year weekly periods.
1150
+ rr = self.rrule
1151
+ if year != self.lastyear:
1152
+ self.yearlen = 365 + calendar.isleap(year)
1153
+ self.nextyearlen = 365 + calendar.isleap(year + 1)
1154
+ firstyday = datetime.date(year, 1, 1)
1155
+ self.yearordinal = firstyday.toordinal()
1156
+ self.yearweekday = firstyday.weekday()
1157
+
1158
+ wday = datetime.date(year, 1, 1).weekday()
1159
+ if self.yearlen == 365:
1160
+ self.mmask = M365MASK
1161
+ self.mdaymask = MDAY365MASK
1162
+ self.nmdaymask = NMDAY365MASK
1163
+ self.wdaymask = WDAYMASK[wday:]
1164
+ self.mrange = M365RANGE
1165
+ else:
1166
+ self.mmask = M366MASK
1167
+ self.mdaymask = MDAY366MASK
1168
+ self.nmdaymask = NMDAY366MASK
1169
+ self.wdaymask = WDAYMASK[wday:]
1170
+ self.mrange = M366RANGE
1171
+
1172
+ if not rr._byweekno:
1173
+ self.wnomask = None
1174
+ else:
1175
+ self.wnomask = [0]*(self.yearlen+7)
1176
+ # no1wkst = firstwkst = self.wdaymask.index(rr._wkst)
1177
+ no1wkst = firstwkst = (7-self.yearweekday+rr._wkst) % 7
1178
+ if no1wkst >= 4:
1179
+ no1wkst = 0
1180
+ # Number of days in the year, plus the days we got
1181
+ # from last year.
1182
+ wyearlen = self.yearlen+(self.yearweekday-rr._wkst) % 7
1183
+ else:
1184
+ # Number of days in the year, minus the days we
1185
+ # left in last year.
1186
+ wyearlen = self.yearlen-no1wkst
1187
+ div, mod = divmod(wyearlen, 7)
1188
+ numweeks = div+mod//4
1189
+ for n in rr._byweekno:
1190
+ if n < 0:
1191
+ n += numweeks+1
1192
+ if not (0 < n <= numweeks):
1193
+ continue
1194
+ if n > 1:
1195
+ i = no1wkst+(n-1)*7
1196
+ if no1wkst != firstwkst:
1197
+ i -= 7-firstwkst
1198
+ else:
1199
+ i = no1wkst
1200
+ for j in range(7):
1201
+ self.wnomask[i] = 1
1202
+ i += 1
1203
+ if self.wdaymask[i] == rr._wkst:
1204
+ break
1205
+ if 1 in rr._byweekno:
1206
+ # Check week number 1 of next year as well
1207
+ # TODO: Check -numweeks for next year.
1208
+ i = no1wkst+numweeks*7
1209
+ if no1wkst != firstwkst:
1210
+ i -= 7-firstwkst
1211
+ if i < self.yearlen:
1212
+ # If week starts in next year, we
1213
+ # don't care about it.
1214
+ for j in range(7):
1215
+ self.wnomask[i] = 1
1216
+ i += 1
1217
+ if self.wdaymask[i] == rr._wkst:
1218
+ break
1219
+ if no1wkst:
1220
+ # Check last week number of last year as
1221
+ # well. If no1wkst is 0, either the year
1222
+ # started on week start, or week number 1
1223
+ # got days from last year, so there are no
1224
+ # days from last year's last week number in
1225
+ # this year.
1226
+ if -1 not in rr._byweekno:
1227
+ lyearweekday = datetime.date(year-1, 1, 1).weekday()
1228
+ lno1wkst = (7-lyearweekday+rr._wkst) % 7
1229
+ lyearlen = 365+calendar.isleap(year-1)
1230
+ if lno1wkst >= 4:
1231
+ lno1wkst = 0
1232
+ lnumweeks = 52+(lyearlen +
1233
+ (lyearweekday-rr._wkst) % 7) % 7//4
1234
+ else:
1235
+ lnumweeks = 52+(self.yearlen-no1wkst) % 7//4
1236
+ else:
1237
+ lnumweeks = -1
1238
+ if lnumweeks in rr._byweekno:
1239
+ for i in range(no1wkst):
1240
+ self.wnomask[i] = 1
1241
+
1242
+ if (rr._bynweekday and (month != self.lastmonth or
1243
+ year != self.lastyear)):
1244
+ ranges = []
1245
+ if rr._freq == YEARLY:
1246
+ if rr._bymonth:
1247
+ for month in rr._bymonth:
1248
+ ranges.append(self.mrange[month-1:month+1])
1249
+ else:
1250
+ ranges = [(0, self.yearlen)]
1251
+ elif rr._freq == MONTHLY:
1252
+ ranges = [self.mrange[month-1:month+1]]
1253
+ if ranges:
1254
+ # Weekly frequency won't get here, so we may not
1255
+ # care about cross-year weekly periods.
1256
+ self.nwdaymask = [0]*self.yearlen
1257
+ for first, last in ranges:
1258
+ last -= 1
1259
+ for wday, n in rr._bynweekday:
1260
+ if n < 0:
1261
+ i = last+(n+1)*7
1262
+ i -= (self.wdaymask[i]-wday) % 7
1263
+ else:
1264
+ i = first+(n-1)*7
1265
+ i += (7-self.wdaymask[i]+wday) % 7
1266
+ if first <= i <= last:
1267
+ self.nwdaymask[i] = 1
1268
+
1269
+ if rr._byeaster:
1270
+ self.eastermask = [0]*(self.yearlen+7)
1271
+ eyday = easter.easter(year).toordinal()-self.yearordinal
1272
+ for offset in rr._byeaster:
1273
+ self.eastermask[eyday+offset] = 1
1274
+
1275
+ self.lastyear = year
1276
+ self.lastmonth = month
1277
+
1278
+ def ydayset(self, year, month, day):
1279
+ return list(range(self.yearlen)), 0, self.yearlen
1280
+
1281
+ def mdayset(self, year, month, day):
1282
+ dset = [None]*self.yearlen
1283
+ start, end = self.mrange[month-1:month+1]
1284
+ for i in range(start, end):
1285
+ dset[i] = i
1286
+ return dset, start, end
1287
+
1288
+ def wdayset(self, year, month, day):
1289
+ # We need to handle cross-year weeks here.
1290
+ dset = [None]*(self.yearlen+7)
1291
+ i = datetime.date(year, month, day).toordinal()-self.yearordinal
1292
+ start = i
1293
+ for j in range(7):
1294
+ dset[i] = i
1295
+ i += 1
1296
+ # if (not (0 <= i < self.yearlen) or
1297
+ # self.wdaymask[i] == self.rrule._wkst):
1298
+ # This will cross the year boundary, if necessary.
1299
+ if self.wdaymask[i] == self.rrule._wkst:
1300
+ break
1301
+ return dset, start, i
1302
+
1303
+ def ddayset(self, year, month, day):
1304
+ dset = [None] * self.yearlen
1305
+ i = datetime.date(year, month, day).toordinal() - self.yearordinal
1306
+ dset[i] = i
1307
+ return dset, i, i + 1
1308
+
1309
+ def htimeset(self, hour, minute, second):
1310
+ tset = []
1311
+ rr = self.rrule
1312
+ for minute in rr._byminute:
1313
+ for second in rr._bysecond:
1314
+ tset.append(datetime.time(hour, minute, second,
1315
+ tzinfo=rr._tzinfo))
1316
+ tset.sort()
1317
+ return tset
1318
+
1319
+ def mtimeset(self, hour, minute, second):
1320
+ tset = []
1321
+ rr = self.rrule
1322
+ for second in rr._bysecond:
1323
+ tset.append(datetime.time(hour, minute, second, tzinfo=rr._tzinfo))
1324
+ tset.sort()
1325
+ return tset
1326
+
1327
+ def stimeset(self, hour, minute, second):
1328
+ return (datetime.time(hour, minute, second,
1329
+ tzinfo=self.rrule._tzinfo),)
1330
+
1331
+
1332
+ class rruleset(rrulebase):
1333
+ """ The rruleset type allows more complex recurrence setups, mixing
1334
+ multiple rules, dates, exclusion rules, and exclusion dates. The type
1335
+ constructor takes the following keyword arguments:
1336
+
1337
+ :param cache: If True, caching of results will be enabled, improving
1338
+ performance of multiple queries considerably. """
1339
+
1340
+ class _genitem(object):
1341
+ def __init__(self, genlist, gen):
1342
+ try:
1343
+ self.dt = advance_iterator(gen)
1344
+ genlist.append(self)
1345
+ except StopIteration:
1346
+ pass
1347
+ self.genlist = genlist
1348
+ self.gen = gen
1349
+
1350
+ def __next__(self):
1351
+ try:
1352
+ self.dt = advance_iterator(self.gen)
1353
+ except StopIteration:
1354
+ if self.genlist[0] is self:
1355
+ heapq.heappop(self.genlist)
1356
+ else:
1357
+ self.genlist.remove(self)
1358
+ heapq.heapify(self.genlist)
1359
+
1360
+ next = __next__
1361
+
1362
+ def __lt__(self, other):
1363
+ return self.dt < other.dt
1364
+
1365
+ def __gt__(self, other):
1366
+ return self.dt > other.dt
1367
+
1368
+ def __eq__(self, other):
1369
+ return self.dt == other.dt
1370
+
1371
+ def __ne__(self, other):
1372
+ return self.dt != other.dt
1373
+
1374
+ def __init__(self, cache=False):
1375
+ super(rruleset, self).__init__(cache)
1376
+ self._rrule = []
1377
+ self._rdate = []
1378
+ self._exrule = []
1379
+ self._exdate = []
1380
+
1381
+ @_invalidates_cache
1382
+ def rrule(self, rrule):
1383
+ """ Include the given :py:class:`rrule` instance in the recurrence set
1384
+ generation. """
1385
+ self._rrule.append(rrule)
1386
+
1387
+ @_invalidates_cache
1388
+ def rdate(self, rdate):
1389
+ """ Include the given :py:class:`datetime` instance in the recurrence
1390
+ set generation. """
1391
+ self._rdate.append(rdate)
1392
+
1393
+ @_invalidates_cache
1394
+ def exrule(self, exrule):
1395
+ """ Include the given rrule instance in the recurrence set exclusion
1396
+ list. Dates which are part of the given recurrence rules will not
1397
+ be generated, even if some inclusive rrule or rdate matches them.
1398
+ """
1399
+ self._exrule.append(exrule)
1400
+
1401
+ @_invalidates_cache
1402
+ def exdate(self, exdate):
1403
+ """ Include the given datetime instance in the recurrence set
1404
+ exclusion list. Dates included that way will not be generated,
1405
+ even if some inclusive rrule or rdate matches them. """
1406
+ self._exdate.append(exdate)
1407
+
1408
+ def _iter(self):
1409
+ rlist = []
1410
+ self._rdate.sort()
1411
+ self._genitem(rlist, iter(self._rdate))
1412
+ for gen in [iter(x) for x in self._rrule]:
1413
+ self._genitem(rlist, gen)
1414
+ exlist = []
1415
+ self._exdate.sort()
1416
+ self._genitem(exlist, iter(self._exdate))
1417
+ for gen in [iter(x) for x in self._exrule]:
1418
+ self._genitem(exlist, gen)
1419
+ lastdt = None
1420
+ total = 0
1421
+ heapq.heapify(rlist)
1422
+ heapq.heapify(exlist)
1423
+ while rlist:
1424
+ ritem = rlist[0]
1425
+ if not lastdt or lastdt != ritem.dt:
1426
+ while exlist and exlist[0] < ritem:
1427
+ exitem = exlist[0]
1428
+ advance_iterator(exitem)
1429
+ if exlist and exlist[0] is exitem:
1430
+ heapq.heapreplace(exlist, exitem)
1431
+ if not exlist or ritem != exlist[0]:
1432
+ total += 1
1433
+ yield ritem.dt
1434
+ lastdt = ritem.dt
1435
+ advance_iterator(ritem)
1436
+ if rlist and rlist[0] is ritem:
1437
+ heapq.heapreplace(rlist, ritem)
1438
+ self._len = total
1439
+
1440
+
1441
+
1442
+
1443
+ class _rrulestr(object):
1444
+ """ Parses a string representation of a recurrence rule or set of
1445
+ recurrence rules.
1446
+
1447
+ :param s:
1448
+ Required, a string defining one or more recurrence rules.
1449
+
1450
+ :param dtstart:
1451
+ If given, used as the default recurrence start if not specified in the
1452
+ rule string.
1453
+
1454
+ :param cache:
1455
+ If set ``True`` caching of results will be enabled, improving
1456
+ performance of multiple queries considerably.
1457
+
1458
+ :param unfold:
1459
+ If set ``True`` indicates that a rule string is split over more
1460
+ than one line and should be joined before processing.
1461
+
1462
+ :param forceset:
1463
+ If set ``True`` forces a :class:`dateutil.rrule.rruleset` to
1464
+ be returned.
1465
+
1466
+ :param compatible:
1467
+ If set ``True`` forces ``unfold`` and ``forceset`` to be ``True``.
1468
+
1469
+ :param ignoretz:
1470
+ If set ``True``, time zones in parsed strings are ignored and a naive
1471
+ :class:`datetime.datetime` object is returned.
1472
+
1473
+ :param tzids:
1474
+ If given, a callable or mapping used to retrieve a
1475
+ :class:`datetime.tzinfo` from a string representation.
1476
+ Defaults to :func:`dateutil.tz.gettz`.
1477
+
1478
+ :param tzinfos:
1479
+ Additional time zone names / aliases which may be present in a string
1480
+ representation. See :func:`dateutil.parser.parse` for more
1481
+ information.
1482
+
1483
+ :return:
1484
+ Returns a :class:`dateutil.rrule.rruleset` or
1485
+ :class:`dateutil.rrule.rrule`
1486
+ """
1487
+
1488
+ _freq_map = {"YEARLY": YEARLY,
1489
+ "MONTHLY": MONTHLY,
1490
+ "WEEKLY": WEEKLY,
1491
+ "DAILY": DAILY,
1492
+ "HOURLY": HOURLY,
1493
+ "MINUTELY": MINUTELY,
1494
+ "SECONDLY": SECONDLY}
1495
+
1496
+ _weekday_map = {"MO": 0, "TU": 1, "WE": 2, "TH": 3,
1497
+ "FR": 4, "SA": 5, "SU": 6}
1498
+
1499
+ def _handle_int(self, rrkwargs, name, value, **kwargs):
1500
+ rrkwargs[name.lower()] = int(value)
1501
+
1502
+ def _handle_int_list(self, rrkwargs, name, value, **kwargs):
1503
+ rrkwargs[name.lower()] = [int(x) for x in value.split(',')]
1504
+
1505
+ _handle_INTERVAL = _handle_int
1506
+ _handle_COUNT = _handle_int
1507
+ _handle_BYSETPOS = _handle_int_list
1508
+ _handle_BYMONTH = _handle_int_list
1509
+ _handle_BYMONTHDAY = _handle_int_list
1510
+ _handle_BYYEARDAY = _handle_int_list
1511
+ _handle_BYEASTER = _handle_int_list
1512
+ _handle_BYWEEKNO = _handle_int_list
1513
+ _handle_BYHOUR = _handle_int_list
1514
+ _handle_BYMINUTE = _handle_int_list
1515
+ _handle_BYSECOND = _handle_int_list
1516
+
1517
+ def _handle_FREQ(self, rrkwargs, name, value, **kwargs):
1518
+ rrkwargs["freq"] = self._freq_map[value]
1519
+
1520
+ def _handle_UNTIL(self, rrkwargs, name, value, **kwargs):
1521
+ global parser
1522
+ if not parser:
1523
+ from matplotlib_rs._vendor.dateutil import parser
1524
+ try:
1525
+ rrkwargs["until"] = parser.parse(value,
1526
+ ignoretz=kwargs.get("ignoretz"),
1527
+ tzinfos=kwargs.get("tzinfos"))
1528
+ except ValueError:
1529
+ raise ValueError("invalid until date")
1530
+
1531
+ def _handle_WKST(self, rrkwargs, name, value, **kwargs):
1532
+ rrkwargs["wkst"] = self._weekday_map[value]
1533
+
1534
+ def _handle_BYWEEKDAY(self, rrkwargs, name, value, **kwargs):
1535
+ """
1536
+ Two ways to specify this: +1MO or MO(+1)
1537
+ """
1538
+ l = []
1539
+ for wday in value.split(','):
1540
+ if '(' in wday:
1541
+ # If it's of the form TH(+1), etc.
1542
+ splt = wday.split('(')
1543
+ w = splt[0]
1544
+ n = int(splt[1][:-1])
1545
+ elif len(wday):
1546
+ # If it's of the form +1MO
1547
+ for i in range(len(wday)):
1548
+ if wday[i] not in '+-0123456789':
1549
+ break
1550
+ n = wday[:i] or None
1551
+ w = wday[i:]
1552
+ if n:
1553
+ n = int(n)
1554
+ else:
1555
+ raise ValueError("Invalid (empty) BYDAY specification.")
1556
+
1557
+ l.append(weekdays[self._weekday_map[w]](n))
1558
+ rrkwargs["byweekday"] = l
1559
+
1560
+ _handle_BYDAY = _handle_BYWEEKDAY
1561
+
1562
+ def _parse_rfc_rrule(self, line,
1563
+ dtstart=None,
1564
+ cache=False,
1565
+ ignoretz=False,
1566
+ tzinfos=None):
1567
+ if line.find(':') != -1:
1568
+ name, value = line.split(':')
1569
+ if name != "RRULE":
1570
+ raise ValueError("unknown parameter name")
1571
+ else:
1572
+ value = line
1573
+ rrkwargs = {}
1574
+ for pair in value.split(';'):
1575
+ name, value = pair.split('=')
1576
+ name = name.upper()
1577
+ value = value.upper()
1578
+ try:
1579
+ getattr(self, "_handle_"+name)(rrkwargs, name, value,
1580
+ ignoretz=ignoretz,
1581
+ tzinfos=tzinfos)
1582
+ except AttributeError:
1583
+ raise ValueError("unknown parameter '%s'" % name)
1584
+ except (KeyError, ValueError):
1585
+ raise ValueError("invalid '%s': %s" % (name, value))
1586
+ return rrule(dtstart=dtstart, cache=cache, **rrkwargs)
1587
+
1588
+ def _parse_date_value(self, date_value, parms, rule_tzids,
1589
+ ignoretz, tzids, tzinfos):
1590
+ global parser
1591
+ if not parser:
1592
+ from matplotlib_rs._vendor.dateutil import parser
1593
+
1594
+ datevals = []
1595
+ value_found = False
1596
+ TZID = None
1597
+
1598
+ for parm in parms:
1599
+ if parm.startswith("TZID="):
1600
+ try:
1601
+ tzkey = rule_tzids[parm.split('TZID=')[-1]]
1602
+ except KeyError:
1603
+ continue
1604
+ if tzids is None:
1605
+ from . import tz
1606
+ tzlookup = tz.gettz
1607
+ elif callable(tzids):
1608
+ tzlookup = tzids
1609
+ else:
1610
+ tzlookup = getattr(tzids, 'get', None)
1611
+ if tzlookup is None:
1612
+ msg = ('tzids must be a callable, mapping, or None, '
1613
+ 'not %s' % tzids)
1614
+ raise ValueError(msg)
1615
+
1616
+ TZID = tzlookup(tzkey)
1617
+ continue
1618
+
1619
+ # RFC 5445 3.8.2.4: The VALUE parameter is optional, but may be found
1620
+ # only once.
1621
+ if parm not in {"VALUE=DATE-TIME", "VALUE=DATE"}:
1622
+ raise ValueError("unsupported parm: " + parm)
1623
+ else:
1624
+ if value_found:
1625
+ msg = ("Duplicate value parameter found in: " + parm)
1626
+ raise ValueError(msg)
1627
+ value_found = True
1628
+
1629
+ for datestr in date_value.split(','):
1630
+ date = parser.parse(datestr, ignoretz=ignoretz, tzinfos=tzinfos)
1631
+ if TZID is not None:
1632
+ if date.tzinfo is None:
1633
+ date = date.replace(tzinfo=TZID)
1634
+ else:
1635
+ raise ValueError('DTSTART/EXDATE specifies multiple timezone')
1636
+ datevals.append(date)
1637
+
1638
+ return datevals
1639
+
1640
+ def _parse_rfc(self, s,
1641
+ dtstart=None,
1642
+ cache=False,
1643
+ unfold=False,
1644
+ forceset=False,
1645
+ compatible=False,
1646
+ ignoretz=False,
1647
+ tzids=None,
1648
+ tzinfos=None):
1649
+ global parser
1650
+ if compatible:
1651
+ forceset = True
1652
+ unfold = True
1653
+
1654
+ TZID_NAMES = dict(map(
1655
+ lambda x: (x.upper(), x),
1656
+ re.findall('TZID=(?P<name>[^:]+):', s)
1657
+ ))
1658
+ s = s.upper()
1659
+ if not s.strip():
1660
+ raise ValueError("empty string")
1661
+ if unfold:
1662
+ lines = s.splitlines()
1663
+ i = 0
1664
+ while i < len(lines):
1665
+ line = lines[i].rstrip()
1666
+ if not line:
1667
+ del lines[i]
1668
+ elif i > 0 and line[0] == " ":
1669
+ lines[i-1] += line[1:]
1670
+ del lines[i]
1671
+ else:
1672
+ i += 1
1673
+ else:
1674
+ lines = s.split()
1675
+ if (not forceset and len(lines) == 1 and (s.find(':') == -1 or
1676
+ s.startswith('RRULE:'))):
1677
+ return self._parse_rfc_rrule(lines[0], cache=cache,
1678
+ dtstart=dtstart, ignoretz=ignoretz,
1679
+ tzinfos=tzinfos)
1680
+ else:
1681
+ rrulevals = []
1682
+ rdatevals = []
1683
+ exrulevals = []
1684
+ exdatevals = []
1685
+ for line in lines:
1686
+ if not line:
1687
+ continue
1688
+ if line.find(':') == -1:
1689
+ name = "RRULE"
1690
+ value = line
1691
+ else:
1692
+ name, value = line.split(':', 1)
1693
+ parms = name.split(';')
1694
+ if not parms:
1695
+ raise ValueError("empty property name")
1696
+ name = parms[0]
1697
+ parms = parms[1:]
1698
+ if name == "RRULE":
1699
+ for parm in parms:
1700
+ if parm.startswith("X-"):
1701
+ # Experimental random vendor features; safe to ignore
1702
+ continue
1703
+ raise ValueError("unsupported RRULE parm: " + parm)
1704
+ rrulevals.append(value)
1705
+ elif name == "RDATE":
1706
+ for parm in parms:
1707
+ if parm != "VALUE=DATE-TIME":
1708
+ raise ValueError("unsupported RDATE parm: "+parm)
1709
+ rdatevals.append(value)
1710
+ elif name == "EXRULE":
1711
+ for parm in parms:
1712
+ raise ValueError("unsupported EXRULE parm: "+parm)
1713
+ exrulevals.append(value)
1714
+ elif name == "EXDATE":
1715
+ exdatevals.extend(
1716
+ self._parse_date_value(value, parms,
1717
+ TZID_NAMES, ignoretz,
1718
+ tzids, tzinfos)
1719
+ )
1720
+ elif name == "DTSTART":
1721
+ dtvals = self._parse_date_value(value, parms, TZID_NAMES,
1722
+ ignoretz, tzids, tzinfos)
1723
+ if len(dtvals) != 1:
1724
+ raise ValueError("Multiple DTSTART values specified:" +
1725
+ value)
1726
+ dtstart = dtvals[0]
1727
+ else:
1728
+ raise ValueError("unsupported property: "+name)
1729
+ if (forceset or len(rrulevals) > 1 or rdatevals
1730
+ or exrulevals or exdatevals):
1731
+ if not parser and (rdatevals or exdatevals):
1732
+ from matplotlib_rs._vendor.dateutil import parser
1733
+ rset = rruleset(cache=cache)
1734
+ for value in rrulevals:
1735
+ rset.rrule(self._parse_rfc_rrule(value, dtstart=dtstart,
1736
+ ignoretz=ignoretz,
1737
+ tzinfos=tzinfos))
1738
+ for value in rdatevals:
1739
+ for datestr in value.split(','):
1740
+ rset.rdate(parser.parse(datestr,
1741
+ ignoretz=ignoretz,
1742
+ tzinfos=tzinfos))
1743
+ for value in exrulevals:
1744
+ rset.exrule(self._parse_rfc_rrule(value, dtstart=dtstart,
1745
+ ignoretz=ignoretz,
1746
+ tzinfos=tzinfos))
1747
+ for value in exdatevals:
1748
+ rset.exdate(value)
1749
+ if compatible and dtstart:
1750
+ rset.rdate(dtstart)
1751
+ return rset
1752
+ else:
1753
+ return self._parse_rfc_rrule(rrulevals[0],
1754
+ dtstart=dtstart,
1755
+ cache=cache,
1756
+ ignoretz=ignoretz,
1757
+ tzinfos=tzinfos)
1758
+
1759
+ def __call__(self, s, **kwargs):
1760
+ return self._parse_rfc(s, **kwargs)
1761
+
1762
+
1763
+ rrulestr = _rrulestr()
1764
+
1765
+ # vim:ts=4:sw=4:et