@v587d/capital-generation 2.28.0 → 2.30.0

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 (302) hide show
  1. package/CHANGELOG.md +59 -0
  2. package/README.md +5 -4
  3. package/THIRD_PARTY_NOTICES.md +16 -0
  4. package/automation/package.json +1 -1
  5. package/chart-ui/package.json +1 -1
  6. package/config/package.json +1 -1
  7. package/lib/collector-runtime.js +56 -1
  8. package/lib/data-collector/catalog-taxonomy.d.ts +1 -1
  9. package/lib/data-collector/catalog-taxonomy.js +33 -0
  10. package/lib/data-collector/tools.js +7 -7
  11. package/lib/host-version.d.ts +9 -0
  12. package/lib/host-version.js +57 -0
  13. package/lib/python-runtime/errors.d.ts +1 -1
  14. package/lib/python-runtime/errors.js +2 -0
  15. package/lib/python-runtime/manager.d.ts +28 -1
  16. package/lib/python-runtime/manager.js +141 -5
  17. package/lib/python-runtime/probe.d.ts +24 -0
  18. package/lib/python-runtime/probe.js +66 -50
  19. package/lib/runtime-entry.js +8 -0
  20. package/lib/sources/csindex-http.d.ts +4 -0
  21. package/lib/sources/csindex-http.js +233 -0
  22. package/lib/sources/eastmoney-http.js +1504 -1
  23. package/lib/sources/fuyao-rest.js +168 -8
  24. package/lib/sources/official-http.d.ts +4 -0
  25. package/lib/sources/official-http.js +477 -0
  26. package/lib/sources/python-remote.d.ts +25 -0
  27. package/lib/sources/python-remote.js +461 -0
  28. package/lib/sources/sina-http.d.ts +2 -0
  29. package/lib/sources/sina-http.js +484 -0
  30. package/lib/sources/tencent-http.js +23 -8
  31. package/lib/sources/ths-http.d.ts +2 -0
  32. package/lib/sources/ths-http.js +514 -0
  33. package/lib/time/tools.js +19 -0
  34. package/lib/web-retriever/local-fetch.d.ts +1 -1
  35. package/lib/web-retriever/local-fetch.js +1 -1
  36. package/lib/web-retriever/sources.d.ts +7 -0
  37. package/lib/web-retriever/sources.js +46 -21
  38. package/lib/web-retriever/throttle.d.ts +8 -0
  39. package/lib/web-retriever/throttle.js +13 -0
  40. package/lib/web-retriever/tools.js +1 -1
  41. package/lib/web-retriever/wind-client.d.ts +1 -1
  42. package/lib/web-retriever/wind-client.js +1 -1
  43. package/package.json +6 -3
  44. package/preset/capital-generation/agent.patch.yml +7 -5
  45. package/preset/capital-generation/skills/capital-data-protocol/SKILL.md +16 -16
  46. package/python/scripts/baostock_stock_basic.py +129 -0
  47. package/python/scripts/baostock_valuation_history.py +141 -0
  48. package/python/scripts/pbc_social_financing.py +291 -0
  49. package/python/vendor/baostock/LICENSE +19 -0
  50. package/python/vendor/baostock/__init__.py +42 -0
  51. package/python/vendor/baostock/common/__init__.py +0 -0
  52. package/python/vendor/baostock/common/contants.py +189 -0
  53. package/python/vendor/baostock/common/context.py +4 -0
  54. package/python/vendor/baostock/corpreport/__init__.py +0 -0
  55. package/python/vendor/baostock/corpreport/corp_performance.py +202 -0
  56. package/python/vendor/baostock/data/__init__.py +0 -0
  57. package/python/vendor/baostock/data/messageheader.py +17 -0
  58. package/python/vendor/baostock/data/msg.py +21 -0
  59. package/python/vendor/baostock/data/resultset.py +200 -0
  60. package/python/vendor/baostock/demo/__init__.py +0 -0
  61. package/python/vendor/baostock/demo/demo_A_stock_5mk-data.py +34 -0
  62. package/python/vendor/baostock/demo/demo_A_stock_k_data.py +36 -0
  63. package/python/vendor/baostock/demo/demo_AllStock.py +27 -0
  64. package/python/vendor/baostock/demo/demo_Balance_data.py +22 -0
  65. package/python/vendor/baostock/demo/demo_CashFlow_data.py +22 -0
  66. package/python/vendor/baostock/demo/demo_Dividend_data.py +35 -0
  67. package/python/vendor/baostock/demo/demo_Dupont_data.py +25 -0
  68. package/python/vendor/baostock/demo/demo_Forecast_report.py +24 -0
  69. package/python/vendor/baostock/demo/demo_Growth_data.py +22 -0
  70. package/python/vendor/baostock/demo/demo_Index_k_data.py +39 -0
  71. package/python/vendor/baostock/demo/demo_Operation_data.py +22 -0
  72. package/python/vendor/baostock/demo/demo_PerformanceExpress_report.py +25 -0
  73. package/python/vendor/baostock/demo/demo_Profit_data.py +22 -0
  74. package/python/vendor/baostock/demo/demo_TradeDates.py +27 -0
  75. package/python/vendor/baostock/demo/demo_adjust_factor_data.py +23 -0
  76. package/python/vendor/baostock/demo/demo_assignDayData.py +23 -0
  77. package/python/vendor/baostock/demo/demo_daily_adjust_factor_data.py +28 -0
  78. package/python/vendor/baostock/demo/demo_daily_k_4_AStock.py +28 -0
  79. package/python/vendor/baostock/demo/demo_daily_k_4_ETF.py +28 -0
  80. package/python/vendor/baostock/demo/demo_depositRate_data.py +26 -0
  81. package/python/vendor/baostock/demo/demo_hs300_stocks.py +26 -0
  82. package/python/vendor/baostock/demo/demo_loanRate_data.py +26 -0
  83. package/python/vendor/baostock/demo/demo_moneySupplyDataMonth_data.py +26 -0
  84. package/python/vendor/baostock/demo/demo_moneySupplyDataYear_data.py +26 -0
  85. package/python/vendor/baostock/demo/demo_requiredReserveRatio_data.py +26 -0
  86. package/python/vendor/baostock/demo/demo_set_API_key.py +37 -0
  87. package/python/vendor/baostock/demo/demo_stockBasic_data.py +27 -0
  88. package/python/vendor/baostock/demo/demo_stock_Valuation_indicator_data.py +34 -0
  89. package/python/vendor/baostock/demo/demo_stock_industry.py +26 -0
  90. package/python/vendor/baostock/demo/demo_sz50stocks.py +26 -0
  91. package/python/vendor/baostock/demo/demo_zz500_stock.py +26 -0
  92. package/python/vendor/baostock/evaluation/__init__.py +0 -0
  93. package/python/vendor/baostock/evaluation/season_index.py +758 -0
  94. package/python/vendor/baostock/login/__init__.py +0 -0
  95. package/python/vendor/baostock/login/loginout.py +230 -0
  96. package/python/vendor/baostock/macroscopic/__init__.py +0 -0
  97. package/python/vendor/baostock/macroscopic/economic_data.py +723 -0
  98. package/python/vendor/baostock/metadata/__init__.py +0 -0
  99. package/python/vendor/baostock/metadata/stock_metadata.py +207 -0
  100. package/python/vendor/baostock/security/__init__.py +0 -0
  101. package/python/vendor/baostock/security/history.py +265 -0
  102. package/python/vendor/baostock/security/sectorinfo.py +1024 -0
  103. package/python/vendor/baostock/util/__init__.py +0 -0
  104. package/python/vendor/baostock/util/socketutil.py +97 -0
  105. package/python/vendor/baostock/util/stringutil.py +83 -0
  106. package/python/vendor/et_xmlfile/LICENSE +23 -0
  107. package/python/vendor/et_xmlfile/LICENSE.python +298 -0
  108. package/python/vendor/et_xmlfile/__init__.py +8 -0
  109. package/python/vendor/et_xmlfile/incremental_tree.py +917 -0
  110. package/python/vendor/et_xmlfile/xmlfile.py +158 -0
  111. package/python/vendor/openpyxl/LICENSE +23 -0
  112. package/python/vendor/openpyxl/__init__.py +19 -0
  113. package/python/vendor/openpyxl/_constants.py +13 -0
  114. package/python/vendor/openpyxl/cell/__init__.py +4 -0
  115. package/python/vendor/openpyxl/cell/_writer.py +136 -0
  116. package/python/vendor/openpyxl/cell/cell.py +332 -0
  117. package/python/vendor/openpyxl/cell/read_only.py +136 -0
  118. package/python/vendor/openpyxl/cell/rich_text.py +202 -0
  119. package/python/vendor/openpyxl/cell/text.py +184 -0
  120. package/python/vendor/openpyxl/chart/_3d.py +105 -0
  121. package/python/vendor/openpyxl/chart/__init__.py +19 -0
  122. package/python/vendor/openpyxl/chart/_chart.py +199 -0
  123. package/python/vendor/openpyxl/chart/area_chart.py +106 -0
  124. package/python/vendor/openpyxl/chart/axis.py +401 -0
  125. package/python/vendor/openpyxl/chart/bar_chart.py +144 -0
  126. package/python/vendor/openpyxl/chart/bubble_chart.py +67 -0
  127. package/python/vendor/openpyxl/chart/chartspace.py +195 -0
  128. package/python/vendor/openpyxl/chart/data_source.py +246 -0
  129. package/python/vendor/openpyxl/chart/descriptors.py +43 -0
  130. package/python/vendor/openpyxl/chart/error_bar.py +62 -0
  131. package/python/vendor/openpyxl/chart/label.py +127 -0
  132. package/python/vendor/openpyxl/chart/layout.py +74 -0
  133. package/python/vendor/openpyxl/chart/legend.py +75 -0
  134. package/python/vendor/openpyxl/chart/line_chart.py +129 -0
  135. package/python/vendor/openpyxl/chart/marker.py +90 -0
  136. package/python/vendor/openpyxl/chart/picture.py +35 -0
  137. package/python/vendor/openpyxl/chart/pie_chart.py +177 -0
  138. package/python/vendor/openpyxl/chart/pivot.py +65 -0
  139. package/python/vendor/openpyxl/chart/plotarea.py +162 -0
  140. package/python/vendor/openpyxl/chart/print_settings.py +57 -0
  141. package/python/vendor/openpyxl/chart/radar_chart.py +55 -0
  142. package/python/vendor/openpyxl/chart/reader.py +32 -0
  143. package/python/vendor/openpyxl/chart/reference.py +124 -0
  144. package/python/vendor/openpyxl/chart/scatter_chart.py +53 -0
  145. package/python/vendor/openpyxl/chart/series.py +197 -0
  146. package/python/vendor/openpyxl/chart/series_factory.py +41 -0
  147. package/python/vendor/openpyxl/chart/shapes.py +89 -0
  148. package/python/vendor/openpyxl/chart/stock_chart.py +54 -0
  149. package/python/vendor/openpyxl/chart/surface_chart.py +119 -0
  150. package/python/vendor/openpyxl/chart/text.py +78 -0
  151. package/python/vendor/openpyxl/chart/title.py +76 -0
  152. package/python/vendor/openpyxl/chart/trendline.py +98 -0
  153. package/python/vendor/openpyxl/chart/updown_bars.py +31 -0
  154. package/python/vendor/openpyxl/chartsheet/__init__.py +3 -0
  155. package/python/vendor/openpyxl/chartsheet/chartsheet.py +107 -0
  156. package/python/vendor/openpyxl/chartsheet/custom.py +61 -0
  157. package/python/vendor/openpyxl/chartsheet/properties.py +28 -0
  158. package/python/vendor/openpyxl/chartsheet/protection.py +41 -0
  159. package/python/vendor/openpyxl/chartsheet/publish.py +58 -0
  160. package/python/vendor/openpyxl/chartsheet/relation.py +97 -0
  161. package/python/vendor/openpyxl/chartsheet/views.py +51 -0
  162. package/python/vendor/openpyxl/comments/__init__.py +4 -0
  163. package/python/vendor/openpyxl/comments/author.py +21 -0
  164. package/python/vendor/openpyxl/comments/comment_sheet.py +211 -0
  165. package/python/vendor/openpyxl/comments/comments.py +62 -0
  166. package/python/vendor/openpyxl/comments/shape_writer.py +112 -0
  167. package/python/vendor/openpyxl/compat/__init__.py +54 -0
  168. package/python/vendor/openpyxl/compat/abc.py +8 -0
  169. package/python/vendor/openpyxl/compat/numbers.py +43 -0
  170. package/python/vendor/openpyxl/compat/product.py +17 -0
  171. package/python/vendor/openpyxl/compat/singleton.py +40 -0
  172. package/python/vendor/openpyxl/compat/strings.py +25 -0
  173. package/python/vendor/openpyxl/descriptors/__init__.py +58 -0
  174. package/python/vendor/openpyxl/descriptors/base.py +272 -0
  175. package/python/vendor/openpyxl/descriptors/container.py +41 -0
  176. package/python/vendor/openpyxl/descriptors/excel.py +112 -0
  177. package/python/vendor/openpyxl/descriptors/namespace.py +12 -0
  178. package/python/vendor/openpyxl/descriptors/nested.py +129 -0
  179. package/python/vendor/openpyxl/descriptors/sequence.py +136 -0
  180. package/python/vendor/openpyxl/descriptors/serialisable.py +240 -0
  181. package/python/vendor/openpyxl/descriptors/slots.py +18 -0
  182. package/python/vendor/openpyxl/drawing/__init__.py +4 -0
  183. package/python/vendor/openpyxl/drawing/colors.py +435 -0
  184. package/python/vendor/openpyxl/drawing/connector.py +144 -0
  185. package/python/vendor/openpyxl/drawing/drawing.py +92 -0
  186. package/python/vendor/openpyxl/drawing/effect.py +407 -0
  187. package/python/vendor/openpyxl/drawing/fill.py +425 -0
  188. package/python/vendor/openpyxl/drawing/geometry.py +584 -0
  189. package/python/vendor/openpyxl/drawing/graphic.py +177 -0
  190. package/python/vendor/openpyxl/drawing/image.py +65 -0
  191. package/python/vendor/openpyxl/drawing/line.py +144 -0
  192. package/python/vendor/openpyxl/drawing/picture.py +144 -0
  193. package/python/vendor/openpyxl/drawing/properties.py +174 -0
  194. package/python/vendor/openpyxl/drawing/relation.py +17 -0
  195. package/python/vendor/openpyxl/drawing/spreadsheet_drawing.py +382 -0
  196. package/python/vendor/openpyxl/drawing/text.py +717 -0
  197. package/python/vendor/openpyxl/drawing/xdr.py +33 -0
  198. package/python/vendor/openpyxl/formatting/__init__.py +3 -0
  199. package/python/vendor/openpyxl/formatting/formatting.py +114 -0
  200. package/python/vendor/openpyxl/formatting/rule.py +291 -0
  201. package/python/vendor/openpyxl/formula/__init__.py +3 -0
  202. package/python/vendor/openpyxl/formula/tokenizer.py +446 -0
  203. package/python/vendor/openpyxl/formula/translate.py +166 -0
  204. package/python/vendor/openpyxl/packaging/__init__.py +3 -0
  205. package/python/vendor/openpyxl/packaging/core.py +115 -0
  206. package/python/vendor/openpyxl/packaging/custom.py +289 -0
  207. package/python/vendor/openpyxl/packaging/extended.py +137 -0
  208. package/python/vendor/openpyxl/packaging/interface.py +56 -0
  209. package/python/vendor/openpyxl/packaging/manifest.py +194 -0
  210. package/python/vendor/openpyxl/packaging/relationship.py +158 -0
  211. package/python/vendor/openpyxl/packaging/workbook.py +185 -0
  212. package/python/vendor/openpyxl/pivot/__init__.py +1 -0
  213. package/python/vendor/openpyxl/pivot/cache.py +965 -0
  214. package/python/vendor/openpyxl/pivot/fields.py +326 -0
  215. package/python/vendor/openpyxl/pivot/record.py +111 -0
  216. package/python/vendor/openpyxl/pivot/table.py +1261 -0
  217. package/python/vendor/openpyxl/reader/__init__.py +1 -0
  218. package/python/vendor/openpyxl/reader/drawings.py +71 -0
  219. package/python/vendor/openpyxl/reader/excel.py +349 -0
  220. package/python/vendor/openpyxl/reader/strings.py +44 -0
  221. package/python/vendor/openpyxl/reader/workbook.py +133 -0
  222. package/python/vendor/openpyxl/styles/__init__.py +11 -0
  223. package/python/vendor/openpyxl/styles/alignment.py +62 -0
  224. package/python/vendor/openpyxl/styles/borders.py +103 -0
  225. package/python/vendor/openpyxl/styles/builtins.py +1397 -0
  226. package/python/vendor/openpyxl/styles/cell_style.py +206 -0
  227. package/python/vendor/openpyxl/styles/colors.py +172 -0
  228. package/python/vendor/openpyxl/styles/differential.py +95 -0
  229. package/python/vendor/openpyxl/styles/fills.py +224 -0
  230. package/python/vendor/openpyxl/styles/fonts.py +113 -0
  231. package/python/vendor/openpyxl/styles/named_styles.py +282 -0
  232. package/python/vendor/openpyxl/styles/numbers.py +200 -0
  233. package/python/vendor/openpyxl/styles/protection.py +17 -0
  234. package/python/vendor/openpyxl/styles/proxy.py +62 -0
  235. package/python/vendor/openpyxl/styles/styleable.py +151 -0
  236. package/python/vendor/openpyxl/styles/stylesheet.py +274 -0
  237. package/python/vendor/openpyxl/styles/table.py +94 -0
  238. package/python/vendor/openpyxl/utils/__init__.py +17 -0
  239. package/python/vendor/openpyxl/utils/bound_dictionary.py +26 -0
  240. package/python/vendor/openpyxl/utils/cell.py +240 -0
  241. package/python/vendor/openpyxl/utils/dataframe.py +87 -0
  242. package/python/vendor/openpyxl/utils/datetime.py +140 -0
  243. package/python/vendor/openpyxl/utils/escape.py +43 -0
  244. package/python/vendor/openpyxl/utils/exceptions.py +34 -0
  245. package/python/vendor/openpyxl/utils/formulas.py +24 -0
  246. package/python/vendor/openpyxl/utils/indexed_list.py +49 -0
  247. package/python/vendor/openpyxl/utils/inference.py +60 -0
  248. package/python/vendor/openpyxl/utils/protection.py +22 -0
  249. package/python/vendor/openpyxl/utils/units.py +108 -0
  250. package/python/vendor/openpyxl/workbook/__init__.py +4 -0
  251. package/python/vendor/openpyxl/workbook/_writer.py +197 -0
  252. package/python/vendor/openpyxl/workbook/child.py +166 -0
  253. package/python/vendor/openpyxl/workbook/defined_name.py +189 -0
  254. package/python/vendor/openpyxl/workbook/external_link/__init__.py +3 -0
  255. package/python/vendor/openpyxl/workbook/external_link/external.py +190 -0
  256. package/python/vendor/openpyxl/workbook/external_reference.py +18 -0
  257. package/python/vendor/openpyxl/workbook/function_group.py +36 -0
  258. package/python/vendor/openpyxl/workbook/properties.py +151 -0
  259. package/python/vendor/openpyxl/workbook/protection.py +163 -0
  260. package/python/vendor/openpyxl/workbook/smart_tags.py +56 -0
  261. package/python/vendor/openpyxl/workbook/views.py +155 -0
  262. package/python/vendor/openpyxl/workbook/web.py +98 -0
  263. package/python/vendor/openpyxl/workbook/workbook.py +438 -0
  264. package/python/vendor/openpyxl/worksheet/__init__.py +1 -0
  265. package/python/vendor/openpyxl/worksheet/_read_only.py +190 -0
  266. package/python/vendor/openpyxl/worksheet/_reader.py +472 -0
  267. package/python/vendor/openpyxl/worksheet/_write_only.py +160 -0
  268. package/python/vendor/openpyxl/worksheet/_writer.py +390 -0
  269. package/python/vendor/openpyxl/worksheet/cell_range.py +512 -0
  270. package/python/vendor/openpyxl/worksheet/cell_watch.py +34 -0
  271. package/python/vendor/openpyxl/worksheet/controls.py +107 -0
  272. package/python/vendor/openpyxl/worksheet/copier.py +70 -0
  273. package/python/vendor/openpyxl/worksheet/custom.py +35 -0
  274. package/python/vendor/openpyxl/worksheet/datavalidation.py +202 -0
  275. package/python/vendor/openpyxl/worksheet/dimensions.py +306 -0
  276. package/python/vendor/openpyxl/worksheet/drawing.py +14 -0
  277. package/python/vendor/openpyxl/worksheet/errors.py +93 -0
  278. package/python/vendor/openpyxl/worksheet/filters.py +486 -0
  279. package/python/vendor/openpyxl/worksheet/formula.py +51 -0
  280. package/python/vendor/openpyxl/worksheet/header_footer.py +270 -0
  281. package/python/vendor/openpyxl/worksheet/hyperlink.py +46 -0
  282. package/python/vendor/openpyxl/worksheet/merge.py +141 -0
  283. package/python/vendor/openpyxl/worksheet/ole.py +133 -0
  284. package/python/vendor/openpyxl/worksheet/page.py +174 -0
  285. package/python/vendor/openpyxl/worksheet/pagebreak.py +94 -0
  286. package/python/vendor/openpyxl/worksheet/picture.py +8 -0
  287. package/python/vendor/openpyxl/worksheet/print_settings.py +184 -0
  288. package/python/vendor/openpyxl/worksheet/properties.py +97 -0
  289. package/python/vendor/openpyxl/worksheet/protection.py +120 -0
  290. package/python/vendor/openpyxl/worksheet/related.py +17 -0
  291. package/python/vendor/openpyxl/worksheet/scenario.py +105 -0
  292. package/python/vendor/openpyxl/worksheet/smart_tag.py +78 -0
  293. package/python/vendor/openpyxl/worksheet/table.py +385 -0
  294. package/python/vendor/openpyxl/worksheet/views.py +155 -0
  295. package/python/vendor/openpyxl/worksheet/worksheet.py +907 -0
  296. package/python/vendor/openpyxl/writer/__init__.py +1 -0
  297. package/python/vendor/openpyxl/writer/excel.py +295 -0
  298. package/python/vendor/openpyxl/writer/theme.py +291 -0
  299. package/python/vendor/openpyxl/xml/__init__.py +42 -0
  300. package/python/vendor/openpyxl/xml/constants.py +129 -0
  301. package/python/vendor/openpyxl/xml/functions.py +87 -0
  302. package/watchlist/package.json +1 -1
@@ -0,0 +1,512 @@
1
+ # Copyright (c) 2010-2024 openpyxl
2
+
3
+ from copy import copy
4
+ from operator import attrgetter
5
+
6
+ from openpyxl.descriptors import Strict
7
+ from openpyxl.descriptors import MinMax
8
+ from openpyxl.descriptors.sequence import UniqueSequence
9
+ from openpyxl.descriptors.serialisable import Serialisable
10
+
11
+ from openpyxl.utils import (
12
+ range_boundaries,
13
+ range_to_tuple,
14
+ get_column_letter,
15
+ quote_sheetname,
16
+ )
17
+
18
+ class CellRange(Serialisable):
19
+ """
20
+ Represents a range in a sheet: title and coordinates.
21
+
22
+ This object is used to perform operations on ranges, like:
23
+
24
+ - shift, expand or shrink
25
+ - union/intersection with another sheet range,
26
+
27
+ We can check whether a range is:
28
+
29
+ - equal or not equal to another,
30
+ - disjoint of another,
31
+ - contained in another.
32
+
33
+ We can get:
34
+
35
+ - the size of a range.
36
+ - the range bounds (vertices)
37
+ - the coordinates,
38
+ - the string representation,
39
+
40
+ """
41
+
42
+ min_col = MinMax(min=1, max=18278, expected_type=int)
43
+ min_row = MinMax(min=1, max=1048576, expected_type=int)
44
+ max_col = MinMax(min=1, max=18278, expected_type=int)
45
+ max_row = MinMax(min=1, max=1048576, expected_type=int)
46
+
47
+
48
+ def __init__(self, range_string=None, min_col=None, min_row=None,
49
+ max_col=None, max_row=None, title=None):
50
+ if range_string is not None:
51
+ if "!" in range_string:
52
+ title, (min_col, min_row, max_col, max_row) = range_to_tuple(range_string)
53
+ else:
54
+ min_col, min_row, max_col, max_row = range_boundaries(range_string)
55
+
56
+ self.min_col = min_col
57
+ self.min_row = min_row
58
+ self.max_col = max_col
59
+ self.max_row = max_row
60
+ self.title = title
61
+
62
+ if min_col > max_col:
63
+ fmt = "{max_col} must be greater than {min_col}"
64
+ raise ValueError(fmt.format(min_col=min_col, max_col=max_col))
65
+ if min_row > max_row:
66
+ fmt = "{max_row} must be greater than {min_row}"
67
+ raise ValueError(fmt.format(min_row=min_row, max_row=max_row))
68
+
69
+
70
+ @property
71
+ def bounds(self):
72
+ """
73
+ Vertices of the range as a tuple
74
+ """
75
+ return self.min_col, self.min_row, self.max_col, self.max_row
76
+
77
+
78
+ @property
79
+ def coord(self):
80
+ """
81
+ Excel-style representation of the range
82
+ """
83
+ fmt = "{min_col}{min_row}:{max_col}{max_row}"
84
+ if (self.min_col == self.max_col
85
+ and self.min_row == self.max_row):
86
+ fmt = "{min_col}{min_row}"
87
+
88
+ return fmt.format(
89
+ min_col=get_column_letter(self.min_col),
90
+ min_row=self.min_row,
91
+ max_col=get_column_letter(self.max_col),
92
+ max_row=self.max_row
93
+ )
94
+
95
+ @property
96
+ def rows(self):
97
+ """
98
+ Return cell coordinates as rows
99
+ """
100
+ for row in range(self.min_row, self.max_row+1):
101
+ yield [(row, col) for col in range(self.min_col, self.max_col+1)]
102
+
103
+
104
+ @property
105
+ def cols(self):
106
+ """
107
+ Return cell coordinates as columns
108
+ """
109
+ for col in range(self.min_col, self.max_col+1):
110
+ yield [(row, col) for row in range(self.min_row, self.max_row+1)]
111
+
112
+
113
+ @property
114
+ def cells(self):
115
+ from itertools import product
116
+ return product(range(self.min_row, self.max_row+1), range(self.min_col, self.max_col+1))
117
+
118
+
119
+ def _check_title(self, other):
120
+ """
121
+ Check whether comparisons between ranges are possible.
122
+ Cannot compare ranges from different worksheets
123
+ Skip if the range passed in has no title.
124
+ """
125
+ if not isinstance(other, CellRange):
126
+ raise TypeError(repr(type(other)))
127
+
128
+ if other.title and self.title != other.title:
129
+ raise ValueError("Cannot work with ranges from different worksheets")
130
+
131
+
132
+ def __repr__(self):
133
+ fmt = u"<{cls} {coord}>"
134
+ if self.title:
135
+ fmt = u"<{cls} {title!r}!{coord}>"
136
+ return fmt.format(cls=self.__class__.__name__, title=self.title, coord=self.coord)
137
+
138
+
139
+ def __hash__(self):
140
+ return hash((self.min_row, self.min_col, self.max_row, self.max_col))
141
+
142
+
143
+ def __str__(self):
144
+ fmt = "{coord}"
145
+ title = self.title
146
+ if title:
147
+ fmt = u"{title}!{coord}"
148
+ title = quote_sheetname(title)
149
+ return fmt.format(title=title, coord=self.coord)
150
+
151
+
152
+ def __copy__(self):
153
+ return self.__class__(min_col=self.min_col, min_row=self.min_row,
154
+ max_col=self.max_col, max_row=self.max_row,
155
+ title=self.title)
156
+
157
+
158
+ def shift(self, col_shift=0, row_shift=0):
159
+ """
160
+ Shift the focus of the range according to the shift values (*col_shift*, *row_shift*).
161
+
162
+ :type col_shift: int
163
+ :param col_shift: number of columns to be moved by, can be negative
164
+ :type row_shift: int
165
+ :param row_shift: number of rows to be moved by, can be negative
166
+ :raise: :class:`ValueError` if any row or column index < 1
167
+ """
168
+
169
+ if (self.min_col + col_shift <= 0
170
+ or self.min_row + row_shift <= 0):
171
+ raise ValueError("Invalid shift value: col_shift={0}, row_shift={1}".format(col_shift, row_shift))
172
+ self.min_col += col_shift
173
+ self.min_row += row_shift
174
+ self.max_col += col_shift
175
+ self.max_row += row_shift
176
+
177
+
178
+ def __ne__(self, other):
179
+ """
180
+ Test whether the ranges are not equal.
181
+
182
+ :type other: openpyxl.worksheet.cell_range.CellRange
183
+ :param other: Other sheet range
184
+ :return: ``True`` if *range* != *other*.
185
+ """
186
+ try:
187
+ self._check_title(other)
188
+ except ValueError:
189
+ return True
190
+
191
+ return (
192
+ other.min_row != self.min_row
193
+ or self.max_row != other.max_row
194
+ or other.min_col != self.min_col
195
+ or self.max_col != other.max_col
196
+ )
197
+
198
+
199
+ def __eq__(self, other):
200
+ """
201
+ Test whether the ranges are equal.
202
+
203
+ :type other: openpyxl.worksheet.cell_range.CellRange
204
+ :param other: Other sheet range
205
+ :return: ``True`` if *range* == *other*.
206
+ """
207
+ return not self.__ne__(other)
208
+
209
+
210
+ def issubset(self, other):
211
+ """
212
+ Test whether every cell in this range is also in *other*.
213
+
214
+ :type other: openpyxl.worksheet.cell_range.CellRange
215
+ :param other: Other sheet range
216
+ :return: ``True`` if *range* <= *other*.
217
+ """
218
+ self._check_title(other)
219
+
220
+ return other.__superset(self)
221
+
222
+ __le__ = issubset
223
+
224
+
225
+ def __lt__(self, other):
226
+ """
227
+ Test whether *other* contains every cell of this range, and more.
228
+
229
+ :type other: openpyxl.worksheet.cell_range.CellRange
230
+ :param other: Other sheet range
231
+ :return: ``True`` if *range* < *other*.
232
+ """
233
+ return self.__le__(other) and self.__ne__(other)
234
+
235
+
236
+ def __superset(self, other):
237
+ return (
238
+ (self.min_row <= other.min_row <= other.max_row <= self.max_row)
239
+ and
240
+ (self.min_col <= other.min_col <= other.max_col <= self.max_col)
241
+ )
242
+
243
+
244
+ def issuperset(self, other):
245
+ """
246
+ Test whether every cell in *other* is in this range.
247
+
248
+ :type other: openpyxl.worksheet.cell_range.CellRange
249
+ :param other: Other sheet range
250
+ :return: ``True`` if *range* >= *other* (or *other* in *range*).
251
+ """
252
+ self._check_title(other)
253
+
254
+ return self.__superset(other)
255
+
256
+ __ge__ = issuperset
257
+
258
+
259
+ def __contains__(self, coord):
260
+ """
261
+ Check whether the range contains a particular cell coordinate
262
+ """
263
+ cr = self.__class__(coord)
264
+ return self.__superset(cr)
265
+
266
+
267
+ def __gt__(self, other):
268
+ """
269
+ Test whether this range contains every cell in *other*, and more.
270
+
271
+ :type other: openpyxl.worksheet.cell_range.CellRange
272
+ :param other: Other sheet range
273
+ :return: ``True`` if *range* > *other*.
274
+ """
275
+ return self.__ge__(other) and self.__ne__(other)
276
+
277
+
278
+ def isdisjoint(self, other):
279
+ """
280
+ Return ``True`` if this range has no cell in common with *other*.
281
+ Ranges are disjoint if and only if their intersection is the empty range.
282
+
283
+ :type other: openpyxl.worksheet.cell_range.CellRange
284
+ :param other: Other sheet range.
285
+ :return: ``True`` if the range has no cells in common with other.
286
+ """
287
+ self._check_title(other)
288
+
289
+ # Sort by top-left vertex
290
+ if self.bounds > other.bounds:
291
+ self, other = other, self
292
+
293
+ return (self.max_col < other.min_col
294
+ or self.max_row < other.min_row
295
+ or other.max_row < self.min_row)
296
+
297
+
298
+ def intersection(self, other):
299
+ """
300
+ Return a new range with cells common to this range and *other*
301
+
302
+ :type other: openpyxl.worksheet.cell_range.CellRange
303
+ :param other: Other sheet range.
304
+ :return: the intersecting sheet range.
305
+ :raise: :class:`ValueError` if the *other* range doesn't intersect
306
+ with this range.
307
+ """
308
+ if self.isdisjoint(other):
309
+ raise ValueError("Range {0} doesn't intersect {0}".format(self, other))
310
+
311
+ min_row = max(self.min_row, other.min_row)
312
+ max_row = min(self.max_row, other.max_row)
313
+ min_col = max(self.min_col, other.min_col)
314
+ max_col = min(self.max_col, other.max_col)
315
+
316
+ return CellRange(min_col=min_col, min_row=min_row, max_col=max_col,
317
+ max_row=max_row)
318
+
319
+ __and__ = intersection
320
+
321
+
322
+ def union(self, other):
323
+ """
324
+ Return the minimal superset of this range and *other*. This new range
325
+ will contain all cells from this range, *other*, and any additional
326
+ cells required to form a rectangular ``CellRange``.
327
+
328
+ :type other: openpyxl.worksheet.cell_range.CellRange
329
+ :param other: Other sheet range.
330
+ :return: a ``CellRange`` that is a superset of this and *other*.
331
+ """
332
+ self._check_title(other)
333
+
334
+ min_row = min(self.min_row, other.min_row)
335
+ max_row = max(self.max_row, other.max_row)
336
+ min_col = min(self.min_col, other.min_col)
337
+ max_col = max(self.max_col, other.max_col)
338
+ return CellRange(min_col=min_col, min_row=min_row, max_col=max_col,
339
+ max_row=max_row, title=self.title)
340
+
341
+ __or__ = union
342
+
343
+
344
+ def __iter__(self):
345
+ """
346
+ For use as a dictionary elsewhere in the library.
347
+ """
348
+ for x in self.__attrs__:
349
+ if x == "title":
350
+ continue
351
+ v = getattr(self, x)
352
+ yield x, v
353
+
354
+
355
+ def expand(self, right=0, down=0, left=0, up=0):
356
+ """
357
+ Expand the range by the dimensions provided.
358
+
359
+ :type right: int
360
+ :param right: expand range to the right by this number of cells
361
+ :type down: int
362
+ :param down: expand range down by this number of cells
363
+ :type left: int
364
+ :param left: expand range to the left by this number of cells
365
+ :type up: int
366
+ :param up: expand range up by this number of cells
367
+ """
368
+ self.min_col -= left
369
+ self.min_row -= up
370
+ self.max_col += right
371
+ self.max_row += down
372
+
373
+
374
+ def shrink(self, right=0, bottom=0, left=0, top=0):
375
+ """
376
+ Shrink the range by the dimensions provided.
377
+
378
+ :type right: int
379
+ :param right: shrink range from the right by this number of cells
380
+ :type down: int
381
+ :param down: shrink range from the top by this number of cells
382
+ :type left: int
383
+ :param left: shrink range from the left by this number of cells
384
+ :type up: int
385
+ :param up: shrink range from the bottom by this number of cells
386
+ """
387
+ self.min_col += left
388
+ self.min_row += top
389
+ self.max_col -= right
390
+ self.max_row -= bottom
391
+
392
+
393
+ @property
394
+ def size(self):
395
+ """ Return the size of the range as a dictionary of rows and columns. """
396
+ cols = self.max_col + 1 - self.min_col
397
+ rows = self.max_row + 1 - self.min_row
398
+ return {'columns':cols, 'rows':rows}
399
+
400
+
401
+ @property
402
+ def top(self):
403
+ """A list of cell coordinates that comprise the top of the range"""
404
+ return [(self.min_row, col) for col in range(self.min_col, self.max_col+1)]
405
+
406
+
407
+ @property
408
+ def bottom(self):
409
+ """A list of cell coordinates that comprise the bottom of the range"""
410
+ return [(self.max_row, col) for col in range(self.min_col, self.max_col+1)]
411
+
412
+
413
+ @property
414
+ def left(self):
415
+ """A list of cell coordinates that comprise the left-side of the range"""
416
+ return [(row, self.min_col) for row in range(self.min_row, self.max_row+1)]
417
+
418
+
419
+ @property
420
+ def right(self):
421
+ """A list of cell coordinates that comprise the right-side of the range"""
422
+ return [(row, self.max_col) for row in range(self.min_row, self.max_row+1)]
423
+
424
+
425
+ class MultiCellRange(Strict):
426
+
427
+
428
+ ranges = UniqueSequence(expected_type=CellRange)
429
+
430
+
431
+ def __init__(self, ranges=set()):
432
+ if isinstance(ranges, str):
433
+ ranges = [CellRange(r) for r in ranges.split()]
434
+ self.ranges = set(ranges)
435
+
436
+
437
+ def __contains__(self, coord):
438
+ if isinstance(coord, str):
439
+ coord = CellRange(coord)
440
+ for r in self.ranges:
441
+ if coord <= r:
442
+ return True
443
+ return False
444
+
445
+
446
+ def __repr__(self):
447
+ ranges = " ".join([str(r) for r in self.sorted()])
448
+ return f"<{self.__class__.__name__} [{ranges}]>"
449
+
450
+
451
+ def __str__(self):
452
+ ranges = u" ".join([str(r) for r in self.sorted()])
453
+ return ranges
454
+
455
+
456
+ def __hash__(self):
457
+ return hash(str(self))
458
+
459
+
460
+ def sorted(self):
461
+ """
462
+ Return a sorted list of items
463
+ """
464
+ return sorted(self.ranges, key=attrgetter('min_col', 'min_row', 'max_col', 'max_row'))
465
+
466
+
467
+ def add(self, coord):
468
+ """
469
+ Add a cell coordinate or CellRange
470
+ """
471
+ cr = coord
472
+ if isinstance(coord, str):
473
+ cr = CellRange(coord)
474
+ elif not isinstance(coord, CellRange):
475
+ raise ValueError("You can only add CellRanges")
476
+ if cr not in self:
477
+ self.ranges.add(cr)
478
+
479
+
480
+ def __iadd__(self, coord):
481
+ self.add(coord)
482
+ return self
483
+
484
+
485
+ def __eq__(self, other):
486
+ if isinstance(other, str):
487
+ other = self.__class__(other)
488
+ return self.ranges == other.ranges
489
+
490
+
491
+ def __ne__(self, other):
492
+ return not self == other
493
+
494
+
495
+ def __bool__(self):
496
+ return bool(self.ranges)
497
+
498
+
499
+ def remove(self, coord):
500
+ if not isinstance(coord, CellRange):
501
+ coord = CellRange(coord)
502
+ self.ranges.remove(coord)
503
+
504
+
505
+ def __iter__(self):
506
+ for cr in self.ranges:
507
+ yield cr
508
+
509
+
510
+ def __copy__(self):
511
+ ranges = {copy(r) for r in self.ranges}
512
+ return MultiCellRange(ranges)
@@ -0,0 +1,34 @@
1
+ #Autogenerated schema
2
+ from openpyxl.descriptors.serialisable import Serialisable
3
+ from openpyxl.descriptors import (
4
+ Sequence,
5
+ String,
6
+ )
7
+
8
+ # could be done using a nestedSequence
9
+
10
+ class CellWatch(Serialisable):
11
+
12
+ tagname = "cellWatch"
13
+
14
+ r = String()
15
+
16
+ def __init__(self,
17
+ r=None,
18
+ ):
19
+ self.r = r
20
+
21
+
22
+ class CellWatches(Serialisable):
23
+
24
+ tagname = "cellWatches"
25
+
26
+ cellWatch = Sequence(expected_type=CellWatch)
27
+
28
+ __elements__ = ('cellWatch',)
29
+
30
+ def __init__(self,
31
+ cellWatch=(),
32
+ ):
33
+ self.cellWatch = cellWatch
34
+
@@ -0,0 +1,107 @@
1
+ # Copyright (c) 2010-2024 openpyxl
2
+
3
+ from openpyxl.descriptors.serialisable import Serialisable
4
+ from openpyxl.descriptors import (
5
+ Typed,
6
+ Bool,
7
+ Integer,
8
+ String,
9
+ Sequence,
10
+ )
11
+
12
+ from openpyxl.descriptors.excel import Relation
13
+ from .ole import ObjectAnchor
14
+
15
+
16
+ class ControlProperty(Serialisable):
17
+
18
+ tagname = "controlPr"
19
+
20
+ anchor = Typed(expected_type=ObjectAnchor, )
21
+ locked = Bool(allow_none=True)
22
+ defaultSize = Bool(allow_none=True)
23
+ _print = Bool(allow_none=True)
24
+ disabled = Bool(allow_none=True)
25
+ recalcAlways = Bool(allow_none=True)
26
+ uiObject = Bool(allow_none=True)
27
+ autoFill = Bool(allow_none=True)
28
+ autoLine = Bool(allow_none=True)
29
+ autoPict = Bool(allow_none=True)
30
+ macro = String(allow_none=True)
31
+ altText = String(allow_none=True)
32
+ linkedCell = String(allow_none=True)
33
+ listFillRange = String(allow_none=True)
34
+ cf = String(allow_none=True)
35
+ id = Relation(allow_none=True)
36
+
37
+ __elements__ = ('anchor',)
38
+
39
+ def __init__(self,
40
+ anchor=None,
41
+ locked=True,
42
+ defaultSize=True,
43
+ _print=True,
44
+ disabled=False,
45
+ recalcAlways=False,
46
+ uiObject=False,
47
+ autoFill=True,
48
+ autoLine=True,
49
+ autoPict=True,
50
+ macro=None,
51
+ altText=None,
52
+ linkedCell=None,
53
+ listFillRange=None,
54
+ cf='pict',
55
+ id=None,
56
+ ):
57
+ self.anchor = anchor
58
+ self.locked = locked
59
+ self.defaultSize = defaultSize
60
+ self._print = _print
61
+ self.disabled = disabled
62
+ self.recalcAlways = recalcAlways
63
+ self.uiObject = uiObject
64
+ self.autoFill = autoFill
65
+ self.autoLine = autoLine
66
+ self.autoPict = autoPict
67
+ self.macro = macro
68
+ self.altText = altText
69
+ self.linkedCell = linkedCell
70
+ self.listFillRange = listFillRange
71
+ self.cf = cf
72
+ self.id = id
73
+
74
+
75
+ class Control(Serialisable):
76
+
77
+ tagname = "control"
78
+
79
+ controlPr = Typed(expected_type=ControlProperty, allow_none=True)
80
+ shapeId = Integer()
81
+ name = String(allow_none=True)
82
+
83
+ __elements__ = ('controlPr',)
84
+
85
+ def __init__(self,
86
+ controlPr=None,
87
+ shapeId=None,
88
+ name=None,
89
+ ):
90
+ self.controlPr = controlPr
91
+ self.shapeId = shapeId
92
+ self.name = name
93
+
94
+
95
+ class Controls(Serialisable):
96
+
97
+ tagname = "controls"
98
+
99
+ control = Sequence(expected_type=Control)
100
+
101
+ __elements__ = ('control',)
102
+
103
+ def __init__(self,
104
+ control=(),
105
+ ):
106
+ self.control = control
107
+