@v587d/capital-generation 2.29.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 (299) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/README.md +3 -3
  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/python-runtime/errors.d.ts +1 -1
  12. package/lib/python-runtime/errors.js +2 -0
  13. package/lib/python-runtime/manager.d.ts +28 -1
  14. package/lib/python-runtime/manager.js +141 -5
  15. package/lib/python-runtime/probe.d.ts +24 -0
  16. package/lib/python-runtime/probe.js +66 -50
  17. package/lib/sources/csindex-http.d.ts +4 -0
  18. package/lib/sources/csindex-http.js +233 -0
  19. package/lib/sources/eastmoney-http.js +1504 -1
  20. package/lib/sources/fuyao-rest.js +168 -8
  21. package/lib/sources/official-http.d.ts +4 -0
  22. package/lib/sources/official-http.js +477 -0
  23. package/lib/sources/python-remote.d.ts +25 -0
  24. package/lib/sources/python-remote.js +461 -0
  25. package/lib/sources/sina-http.d.ts +2 -0
  26. package/lib/sources/sina-http.js +484 -0
  27. package/lib/sources/tencent-http.js +23 -8
  28. package/lib/sources/ths-http.d.ts +2 -0
  29. package/lib/sources/ths-http.js +514 -0
  30. package/lib/time/tools.js +19 -0
  31. package/lib/web-retriever/local-fetch.d.ts +1 -1
  32. package/lib/web-retriever/local-fetch.js +1 -1
  33. package/lib/web-retriever/sources.d.ts +7 -0
  34. package/lib/web-retriever/sources.js +46 -21
  35. package/lib/web-retriever/throttle.d.ts +8 -0
  36. package/lib/web-retriever/throttle.js +13 -0
  37. package/lib/web-retriever/tools.js +1 -1
  38. package/lib/web-retriever/wind-client.d.ts +1 -1
  39. package/lib/web-retriever/wind-client.js +1 -1
  40. package/package.json +1 -1
  41. package/preset/capital-generation/agent.patch.yml +7 -5
  42. package/preset/capital-generation/skills/capital-data-protocol/SKILL.md +16 -16
  43. package/python/scripts/baostock_stock_basic.py +129 -0
  44. package/python/scripts/baostock_valuation_history.py +141 -0
  45. package/python/scripts/pbc_social_financing.py +291 -0
  46. package/python/vendor/baostock/LICENSE +19 -0
  47. package/python/vendor/baostock/__init__.py +42 -0
  48. package/python/vendor/baostock/common/__init__.py +0 -0
  49. package/python/vendor/baostock/common/contants.py +189 -0
  50. package/python/vendor/baostock/common/context.py +4 -0
  51. package/python/vendor/baostock/corpreport/__init__.py +0 -0
  52. package/python/vendor/baostock/corpreport/corp_performance.py +202 -0
  53. package/python/vendor/baostock/data/__init__.py +0 -0
  54. package/python/vendor/baostock/data/messageheader.py +17 -0
  55. package/python/vendor/baostock/data/msg.py +21 -0
  56. package/python/vendor/baostock/data/resultset.py +200 -0
  57. package/python/vendor/baostock/demo/__init__.py +0 -0
  58. package/python/vendor/baostock/demo/demo_A_stock_5mk-data.py +34 -0
  59. package/python/vendor/baostock/demo/demo_A_stock_k_data.py +36 -0
  60. package/python/vendor/baostock/demo/demo_AllStock.py +27 -0
  61. package/python/vendor/baostock/demo/demo_Balance_data.py +22 -0
  62. package/python/vendor/baostock/demo/demo_CashFlow_data.py +22 -0
  63. package/python/vendor/baostock/demo/demo_Dividend_data.py +35 -0
  64. package/python/vendor/baostock/demo/demo_Dupont_data.py +25 -0
  65. package/python/vendor/baostock/demo/demo_Forecast_report.py +24 -0
  66. package/python/vendor/baostock/demo/demo_Growth_data.py +22 -0
  67. package/python/vendor/baostock/demo/demo_Index_k_data.py +39 -0
  68. package/python/vendor/baostock/demo/demo_Operation_data.py +22 -0
  69. package/python/vendor/baostock/demo/demo_PerformanceExpress_report.py +25 -0
  70. package/python/vendor/baostock/demo/demo_Profit_data.py +22 -0
  71. package/python/vendor/baostock/demo/demo_TradeDates.py +27 -0
  72. package/python/vendor/baostock/demo/demo_adjust_factor_data.py +23 -0
  73. package/python/vendor/baostock/demo/demo_assignDayData.py +23 -0
  74. package/python/vendor/baostock/demo/demo_daily_adjust_factor_data.py +28 -0
  75. package/python/vendor/baostock/demo/demo_daily_k_4_AStock.py +28 -0
  76. package/python/vendor/baostock/demo/demo_daily_k_4_ETF.py +28 -0
  77. package/python/vendor/baostock/demo/demo_depositRate_data.py +26 -0
  78. package/python/vendor/baostock/demo/demo_hs300_stocks.py +26 -0
  79. package/python/vendor/baostock/demo/demo_loanRate_data.py +26 -0
  80. package/python/vendor/baostock/demo/demo_moneySupplyDataMonth_data.py +26 -0
  81. package/python/vendor/baostock/demo/demo_moneySupplyDataYear_data.py +26 -0
  82. package/python/vendor/baostock/demo/demo_requiredReserveRatio_data.py +26 -0
  83. package/python/vendor/baostock/demo/demo_set_API_key.py +37 -0
  84. package/python/vendor/baostock/demo/demo_stockBasic_data.py +27 -0
  85. package/python/vendor/baostock/demo/demo_stock_Valuation_indicator_data.py +34 -0
  86. package/python/vendor/baostock/demo/demo_stock_industry.py +26 -0
  87. package/python/vendor/baostock/demo/demo_sz50stocks.py +26 -0
  88. package/python/vendor/baostock/demo/demo_zz500_stock.py +26 -0
  89. package/python/vendor/baostock/evaluation/__init__.py +0 -0
  90. package/python/vendor/baostock/evaluation/season_index.py +758 -0
  91. package/python/vendor/baostock/login/__init__.py +0 -0
  92. package/python/vendor/baostock/login/loginout.py +230 -0
  93. package/python/vendor/baostock/macroscopic/__init__.py +0 -0
  94. package/python/vendor/baostock/macroscopic/economic_data.py +723 -0
  95. package/python/vendor/baostock/metadata/__init__.py +0 -0
  96. package/python/vendor/baostock/metadata/stock_metadata.py +207 -0
  97. package/python/vendor/baostock/security/__init__.py +0 -0
  98. package/python/vendor/baostock/security/history.py +265 -0
  99. package/python/vendor/baostock/security/sectorinfo.py +1024 -0
  100. package/python/vendor/baostock/util/__init__.py +0 -0
  101. package/python/vendor/baostock/util/socketutil.py +97 -0
  102. package/python/vendor/baostock/util/stringutil.py +83 -0
  103. package/python/vendor/et_xmlfile/LICENSE +23 -0
  104. package/python/vendor/et_xmlfile/LICENSE.python +298 -0
  105. package/python/vendor/et_xmlfile/__init__.py +8 -0
  106. package/python/vendor/et_xmlfile/incremental_tree.py +917 -0
  107. package/python/vendor/et_xmlfile/xmlfile.py +158 -0
  108. package/python/vendor/openpyxl/LICENSE +23 -0
  109. package/python/vendor/openpyxl/__init__.py +19 -0
  110. package/python/vendor/openpyxl/_constants.py +13 -0
  111. package/python/vendor/openpyxl/cell/__init__.py +4 -0
  112. package/python/vendor/openpyxl/cell/_writer.py +136 -0
  113. package/python/vendor/openpyxl/cell/cell.py +332 -0
  114. package/python/vendor/openpyxl/cell/read_only.py +136 -0
  115. package/python/vendor/openpyxl/cell/rich_text.py +202 -0
  116. package/python/vendor/openpyxl/cell/text.py +184 -0
  117. package/python/vendor/openpyxl/chart/_3d.py +105 -0
  118. package/python/vendor/openpyxl/chart/__init__.py +19 -0
  119. package/python/vendor/openpyxl/chart/_chart.py +199 -0
  120. package/python/vendor/openpyxl/chart/area_chart.py +106 -0
  121. package/python/vendor/openpyxl/chart/axis.py +401 -0
  122. package/python/vendor/openpyxl/chart/bar_chart.py +144 -0
  123. package/python/vendor/openpyxl/chart/bubble_chart.py +67 -0
  124. package/python/vendor/openpyxl/chart/chartspace.py +195 -0
  125. package/python/vendor/openpyxl/chart/data_source.py +246 -0
  126. package/python/vendor/openpyxl/chart/descriptors.py +43 -0
  127. package/python/vendor/openpyxl/chart/error_bar.py +62 -0
  128. package/python/vendor/openpyxl/chart/label.py +127 -0
  129. package/python/vendor/openpyxl/chart/layout.py +74 -0
  130. package/python/vendor/openpyxl/chart/legend.py +75 -0
  131. package/python/vendor/openpyxl/chart/line_chart.py +129 -0
  132. package/python/vendor/openpyxl/chart/marker.py +90 -0
  133. package/python/vendor/openpyxl/chart/picture.py +35 -0
  134. package/python/vendor/openpyxl/chart/pie_chart.py +177 -0
  135. package/python/vendor/openpyxl/chart/pivot.py +65 -0
  136. package/python/vendor/openpyxl/chart/plotarea.py +162 -0
  137. package/python/vendor/openpyxl/chart/print_settings.py +57 -0
  138. package/python/vendor/openpyxl/chart/radar_chart.py +55 -0
  139. package/python/vendor/openpyxl/chart/reader.py +32 -0
  140. package/python/vendor/openpyxl/chart/reference.py +124 -0
  141. package/python/vendor/openpyxl/chart/scatter_chart.py +53 -0
  142. package/python/vendor/openpyxl/chart/series.py +197 -0
  143. package/python/vendor/openpyxl/chart/series_factory.py +41 -0
  144. package/python/vendor/openpyxl/chart/shapes.py +89 -0
  145. package/python/vendor/openpyxl/chart/stock_chart.py +54 -0
  146. package/python/vendor/openpyxl/chart/surface_chart.py +119 -0
  147. package/python/vendor/openpyxl/chart/text.py +78 -0
  148. package/python/vendor/openpyxl/chart/title.py +76 -0
  149. package/python/vendor/openpyxl/chart/trendline.py +98 -0
  150. package/python/vendor/openpyxl/chart/updown_bars.py +31 -0
  151. package/python/vendor/openpyxl/chartsheet/__init__.py +3 -0
  152. package/python/vendor/openpyxl/chartsheet/chartsheet.py +107 -0
  153. package/python/vendor/openpyxl/chartsheet/custom.py +61 -0
  154. package/python/vendor/openpyxl/chartsheet/properties.py +28 -0
  155. package/python/vendor/openpyxl/chartsheet/protection.py +41 -0
  156. package/python/vendor/openpyxl/chartsheet/publish.py +58 -0
  157. package/python/vendor/openpyxl/chartsheet/relation.py +97 -0
  158. package/python/vendor/openpyxl/chartsheet/views.py +51 -0
  159. package/python/vendor/openpyxl/comments/__init__.py +4 -0
  160. package/python/vendor/openpyxl/comments/author.py +21 -0
  161. package/python/vendor/openpyxl/comments/comment_sheet.py +211 -0
  162. package/python/vendor/openpyxl/comments/comments.py +62 -0
  163. package/python/vendor/openpyxl/comments/shape_writer.py +112 -0
  164. package/python/vendor/openpyxl/compat/__init__.py +54 -0
  165. package/python/vendor/openpyxl/compat/abc.py +8 -0
  166. package/python/vendor/openpyxl/compat/numbers.py +43 -0
  167. package/python/vendor/openpyxl/compat/product.py +17 -0
  168. package/python/vendor/openpyxl/compat/singleton.py +40 -0
  169. package/python/vendor/openpyxl/compat/strings.py +25 -0
  170. package/python/vendor/openpyxl/descriptors/__init__.py +58 -0
  171. package/python/vendor/openpyxl/descriptors/base.py +272 -0
  172. package/python/vendor/openpyxl/descriptors/container.py +41 -0
  173. package/python/vendor/openpyxl/descriptors/excel.py +112 -0
  174. package/python/vendor/openpyxl/descriptors/namespace.py +12 -0
  175. package/python/vendor/openpyxl/descriptors/nested.py +129 -0
  176. package/python/vendor/openpyxl/descriptors/sequence.py +136 -0
  177. package/python/vendor/openpyxl/descriptors/serialisable.py +240 -0
  178. package/python/vendor/openpyxl/descriptors/slots.py +18 -0
  179. package/python/vendor/openpyxl/drawing/__init__.py +4 -0
  180. package/python/vendor/openpyxl/drawing/colors.py +435 -0
  181. package/python/vendor/openpyxl/drawing/connector.py +144 -0
  182. package/python/vendor/openpyxl/drawing/drawing.py +92 -0
  183. package/python/vendor/openpyxl/drawing/effect.py +407 -0
  184. package/python/vendor/openpyxl/drawing/fill.py +425 -0
  185. package/python/vendor/openpyxl/drawing/geometry.py +584 -0
  186. package/python/vendor/openpyxl/drawing/graphic.py +177 -0
  187. package/python/vendor/openpyxl/drawing/image.py +65 -0
  188. package/python/vendor/openpyxl/drawing/line.py +144 -0
  189. package/python/vendor/openpyxl/drawing/picture.py +144 -0
  190. package/python/vendor/openpyxl/drawing/properties.py +174 -0
  191. package/python/vendor/openpyxl/drawing/relation.py +17 -0
  192. package/python/vendor/openpyxl/drawing/spreadsheet_drawing.py +382 -0
  193. package/python/vendor/openpyxl/drawing/text.py +717 -0
  194. package/python/vendor/openpyxl/drawing/xdr.py +33 -0
  195. package/python/vendor/openpyxl/formatting/__init__.py +3 -0
  196. package/python/vendor/openpyxl/formatting/formatting.py +114 -0
  197. package/python/vendor/openpyxl/formatting/rule.py +291 -0
  198. package/python/vendor/openpyxl/formula/__init__.py +3 -0
  199. package/python/vendor/openpyxl/formula/tokenizer.py +446 -0
  200. package/python/vendor/openpyxl/formula/translate.py +166 -0
  201. package/python/vendor/openpyxl/packaging/__init__.py +3 -0
  202. package/python/vendor/openpyxl/packaging/core.py +115 -0
  203. package/python/vendor/openpyxl/packaging/custom.py +289 -0
  204. package/python/vendor/openpyxl/packaging/extended.py +137 -0
  205. package/python/vendor/openpyxl/packaging/interface.py +56 -0
  206. package/python/vendor/openpyxl/packaging/manifest.py +194 -0
  207. package/python/vendor/openpyxl/packaging/relationship.py +158 -0
  208. package/python/vendor/openpyxl/packaging/workbook.py +185 -0
  209. package/python/vendor/openpyxl/pivot/__init__.py +1 -0
  210. package/python/vendor/openpyxl/pivot/cache.py +965 -0
  211. package/python/vendor/openpyxl/pivot/fields.py +326 -0
  212. package/python/vendor/openpyxl/pivot/record.py +111 -0
  213. package/python/vendor/openpyxl/pivot/table.py +1261 -0
  214. package/python/vendor/openpyxl/reader/__init__.py +1 -0
  215. package/python/vendor/openpyxl/reader/drawings.py +71 -0
  216. package/python/vendor/openpyxl/reader/excel.py +349 -0
  217. package/python/vendor/openpyxl/reader/strings.py +44 -0
  218. package/python/vendor/openpyxl/reader/workbook.py +133 -0
  219. package/python/vendor/openpyxl/styles/__init__.py +11 -0
  220. package/python/vendor/openpyxl/styles/alignment.py +62 -0
  221. package/python/vendor/openpyxl/styles/borders.py +103 -0
  222. package/python/vendor/openpyxl/styles/builtins.py +1397 -0
  223. package/python/vendor/openpyxl/styles/cell_style.py +206 -0
  224. package/python/vendor/openpyxl/styles/colors.py +172 -0
  225. package/python/vendor/openpyxl/styles/differential.py +95 -0
  226. package/python/vendor/openpyxl/styles/fills.py +224 -0
  227. package/python/vendor/openpyxl/styles/fonts.py +113 -0
  228. package/python/vendor/openpyxl/styles/named_styles.py +282 -0
  229. package/python/vendor/openpyxl/styles/numbers.py +200 -0
  230. package/python/vendor/openpyxl/styles/protection.py +17 -0
  231. package/python/vendor/openpyxl/styles/proxy.py +62 -0
  232. package/python/vendor/openpyxl/styles/styleable.py +151 -0
  233. package/python/vendor/openpyxl/styles/stylesheet.py +274 -0
  234. package/python/vendor/openpyxl/styles/table.py +94 -0
  235. package/python/vendor/openpyxl/utils/__init__.py +17 -0
  236. package/python/vendor/openpyxl/utils/bound_dictionary.py +26 -0
  237. package/python/vendor/openpyxl/utils/cell.py +240 -0
  238. package/python/vendor/openpyxl/utils/dataframe.py +87 -0
  239. package/python/vendor/openpyxl/utils/datetime.py +140 -0
  240. package/python/vendor/openpyxl/utils/escape.py +43 -0
  241. package/python/vendor/openpyxl/utils/exceptions.py +34 -0
  242. package/python/vendor/openpyxl/utils/formulas.py +24 -0
  243. package/python/vendor/openpyxl/utils/indexed_list.py +49 -0
  244. package/python/vendor/openpyxl/utils/inference.py +60 -0
  245. package/python/vendor/openpyxl/utils/protection.py +22 -0
  246. package/python/vendor/openpyxl/utils/units.py +108 -0
  247. package/python/vendor/openpyxl/workbook/__init__.py +4 -0
  248. package/python/vendor/openpyxl/workbook/_writer.py +197 -0
  249. package/python/vendor/openpyxl/workbook/child.py +166 -0
  250. package/python/vendor/openpyxl/workbook/defined_name.py +189 -0
  251. package/python/vendor/openpyxl/workbook/external_link/__init__.py +3 -0
  252. package/python/vendor/openpyxl/workbook/external_link/external.py +190 -0
  253. package/python/vendor/openpyxl/workbook/external_reference.py +18 -0
  254. package/python/vendor/openpyxl/workbook/function_group.py +36 -0
  255. package/python/vendor/openpyxl/workbook/properties.py +151 -0
  256. package/python/vendor/openpyxl/workbook/protection.py +163 -0
  257. package/python/vendor/openpyxl/workbook/smart_tags.py +56 -0
  258. package/python/vendor/openpyxl/workbook/views.py +155 -0
  259. package/python/vendor/openpyxl/workbook/web.py +98 -0
  260. package/python/vendor/openpyxl/workbook/workbook.py +438 -0
  261. package/python/vendor/openpyxl/worksheet/__init__.py +1 -0
  262. package/python/vendor/openpyxl/worksheet/_read_only.py +190 -0
  263. package/python/vendor/openpyxl/worksheet/_reader.py +472 -0
  264. package/python/vendor/openpyxl/worksheet/_write_only.py +160 -0
  265. package/python/vendor/openpyxl/worksheet/_writer.py +390 -0
  266. package/python/vendor/openpyxl/worksheet/cell_range.py +512 -0
  267. package/python/vendor/openpyxl/worksheet/cell_watch.py +34 -0
  268. package/python/vendor/openpyxl/worksheet/controls.py +107 -0
  269. package/python/vendor/openpyxl/worksheet/copier.py +70 -0
  270. package/python/vendor/openpyxl/worksheet/custom.py +35 -0
  271. package/python/vendor/openpyxl/worksheet/datavalidation.py +202 -0
  272. package/python/vendor/openpyxl/worksheet/dimensions.py +306 -0
  273. package/python/vendor/openpyxl/worksheet/drawing.py +14 -0
  274. package/python/vendor/openpyxl/worksheet/errors.py +93 -0
  275. package/python/vendor/openpyxl/worksheet/filters.py +486 -0
  276. package/python/vendor/openpyxl/worksheet/formula.py +51 -0
  277. package/python/vendor/openpyxl/worksheet/header_footer.py +270 -0
  278. package/python/vendor/openpyxl/worksheet/hyperlink.py +46 -0
  279. package/python/vendor/openpyxl/worksheet/merge.py +141 -0
  280. package/python/vendor/openpyxl/worksheet/ole.py +133 -0
  281. package/python/vendor/openpyxl/worksheet/page.py +174 -0
  282. package/python/vendor/openpyxl/worksheet/pagebreak.py +94 -0
  283. package/python/vendor/openpyxl/worksheet/picture.py +8 -0
  284. package/python/vendor/openpyxl/worksheet/print_settings.py +184 -0
  285. package/python/vendor/openpyxl/worksheet/properties.py +97 -0
  286. package/python/vendor/openpyxl/worksheet/protection.py +120 -0
  287. package/python/vendor/openpyxl/worksheet/related.py +17 -0
  288. package/python/vendor/openpyxl/worksheet/scenario.py +105 -0
  289. package/python/vendor/openpyxl/worksheet/smart_tag.py +78 -0
  290. package/python/vendor/openpyxl/worksheet/table.py +385 -0
  291. package/python/vendor/openpyxl/worksheet/views.py +155 -0
  292. package/python/vendor/openpyxl/worksheet/worksheet.py +907 -0
  293. package/python/vendor/openpyxl/writer/__init__.py +1 -0
  294. package/python/vendor/openpyxl/writer/excel.py +295 -0
  295. package/python/vendor/openpyxl/writer/theme.py +291 -0
  296. package/python/vendor/openpyxl/xml/__init__.py +42 -0
  297. package/python/vendor/openpyxl/xml/constants.py +129 -0
  298. package/python/vendor/openpyxl/xml/functions.py +87 -0
  299. package/watchlist/package.json +1 -1
@@ -0,0 +1,70 @@
1
+ # Copyright (c) 2010-2024 openpyxl
2
+
3
+ #standard lib imports
4
+ from copy import copy
5
+
6
+ from .worksheet import Worksheet
7
+
8
+
9
+ class WorksheetCopy:
10
+ """
11
+ Copy the values, styles, dimensions, merged cells, margins, and
12
+ print/page setup from one worksheet to another within the same
13
+ workbook.
14
+ """
15
+
16
+ def __init__(self, source_worksheet, target_worksheet):
17
+ self.source = source_worksheet
18
+ self.target = target_worksheet
19
+ self._verify_resources()
20
+
21
+
22
+ def _verify_resources(self):
23
+
24
+ if (not isinstance(self.source, Worksheet)
25
+ and not isinstance(self.target, Worksheet)):
26
+ raise TypeError("Can only copy worksheets")
27
+
28
+ if self.source is self.target:
29
+ raise ValueError("Cannot copy a worksheet to itself")
30
+
31
+ if self.source.parent != self.target.parent:
32
+ raise ValueError('Cannot copy between worksheets from different workbooks')
33
+
34
+
35
+ def copy_worksheet(self):
36
+ self._copy_cells()
37
+ self._copy_dimensions()
38
+
39
+ self.target.sheet_format = copy(self.source.sheet_format)
40
+ self.target.sheet_properties = copy(self.source.sheet_properties)
41
+ self.target.merged_cells = copy(self.source.merged_cells)
42
+ self.target.page_margins = copy(self.source.page_margins)
43
+ self.target.page_setup = copy(self.source.page_setup)
44
+ self.target.print_options = copy(self.source.print_options)
45
+
46
+
47
+ def _copy_cells(self):
48
+ for (row, col), source_cell in self.source._cells.items():
49
+ target_cell = self.target.cell(column=col, row=row)
50
+
51
+ target_cell._value = source_cell._value
52
+ target_cell.data_type = source_cell.data_type
53
+
54
+ if source_cell.has_style:
55
+ target_cell._style = copy(source_cell._style)
56
+
57
+ if source_cell.hyperlink:
58
+ target_cell._hyperlink = copy(source_cell.hyperlink)
59
+
60
+ if source_cell.comment:
61
+ target_cell.comment = copy(source_cell.comment)
62
+
63
+
64
+ def _copy_dimensions(self):
65
+ for attr in ('row_dimensions', 'column_dimensions'):
66
+ src = getattr(self.source, attr)
67
+ target = getattr(self.target, attr)
68
+ for key, dim in src.items():
69
+ target[key] = copy(dim)
70
+ target[key].worksheet = self.target
@@ -0,0 +1,35 @@
1
+ #Autogenerated schema
2
+ from openpyxl.descriptors.serialisable import Serialisable
3
+ from openpyxl.descriptors import (
4
+ String,
5
+ Sequence,
6
+ )
7
+
8
+ # can be done with a nested sequence
9
+
10
+
11
+ class CustomProperty(Serialisable):
12
+
13
+ tagname = "customProperty"
14
+
15
+ name = String()
16
+
17
+ def __init__(self,
18
+ name=None,
19
+ ):
20
+ self.name = name
21
+
22
+
23
+ class CustomProperties(Serialisable):
24
+
25
+ tagname = "customProperties"
26
+
27
+ customPr = Sequence(expected_type=CustomProperty)
28
+
29
+ __elements__ = ('customPr',)
30
+
31
+ def __init__(self,
32
+ customPr=(),
33
+ ):
34
+ self.customPr = customPr
35
+
@@ -0,0 +1,202 @@
1
+ # Copyright (c) 2010-2024 openpyxl
2
+
3
+ from collections import defaultdict
4
+ from itertools import chain
5
+ from operator import itemgetter
6
+
7
+ from openpyxl.descriptors.serialisable import Serialisable
8
+ from openpyxl.descriptors import (
9
+ Bool,
10
+ NoneSet,
11
+ String,
12
+ Sequence,
13
+ Alias,
14
+ Integer,
15
+ Convertible,
16
+ )
17
+ from openpyxl.descriptors.nested import NestedText
18
+
19
+ from openpyxl.utils import (
20
+ rows_from_range,
21
+ coordinate_to_tuple,
22
+ get_column_letter,
23
+ )
24
+
25
+
26
+ def collapse_cell_addresses(cells, input_ranges=()):
27
+ """ Collapse a collection of cell co-ordinates down into an optimal
28
+ range or collection of ranges.
29
+
30
+ E.g. Cells A1, A2, A3, B1, B2 and B3 should have the data-validation
31
+ object applied, attempt to collapse down to a single range, A1:B3.
32
+
33
+ Currently only collapsing contiguous vertical ranges (i.e. above
34
+ example results in A1:A3 B1:B3).
35
+ """
36
+
37
+ ranges = list(input_ranges)
38
+
39
+ # convert cell into row, col tuple
40
+ raw_coords = (coordinate_to_tuple(cell) for cell in cells)
41
+
42
+ # group by column in order
43
+ grouped_coords = defaultdict(list)
44
+ for row, col in sorted(raw_coords, key=itemgetter(1)):
45
+ grouped_coords[col].append(row)
46
+
47
+ # create range string from first and last row in column
48
+ for col, cells in grouped_coords.items():
49
+ col = get_column_letter(col)
50
+ fmt = "{0}{1}:{2}{3}"
51
+ if len(cells) == 1:
52
+ fmt = "{0}{1}"
53
+ r = fmt.format(col, min(cells), col, max(cells))
54
+ ranges.append(r)
55
+
56
+ return " ".join(ranges)
57
+
58
+
59
+ def expand_cell_ranges(range_string):
60
+ """
61
+ Expand cell ranges to a sequence of addresses.
62
+ Reverse of collapse_cell_addresses
63
+ Eg. converts "A1:A2 B1:B2" to (A1, A2, B1, B2)
64
+ """
65
+ # expand ranges to rows and then flatten
66
+ rows = (rows_from_range(rs) for rs in range_string.split()) # list of rows
67
+ cells = (chain(*row) for row in rows) # flatten rows
68
+ return set(chain(*cells))
69
+
70
+
71
+ from .cell_range import MultiCellRange
72
+
73
+
74
+ class DataValidation(Serialisable):
75
+
76
+ tagname = "dataValidation"
77
+
78
+ sqref = Convertible(expected_type=MultiCellRange)
79
+ cells = Alias("sqref")
80
+ ranges = Alias("sqref")
81
+
82
+ showDropDown = Bool(allow_none=True)
83
+ hide_drop_down = Alias('showDropDown')
84
+ showInputMessage = Bool(allow_none=True)
85
+ showErrorMessage = Bool(allow_none=True)
86
+ allowBlank = Bool(allow_none=True)
87
+ allow_blank = Alias('allowBlank')
88
+
89
+ errorTitle = String(allow_none = True)
90
+ error = String(allow_none = True)
91
+ promptTitle = String(allow_none = True)
92
+ prompt = String(allow_none = True)
93
+ formula1 = NestedText(allow_none=True, expected_type=str)
94
+ formula2 = NestedText(allow_none=True, expected_type=str)
95
+
96
+ type = NoneSet(values=("whole", "decimal", "list", "date", "time",
97
+ "textLength", "custom"))
98
+ errorStyle = NoneSet(values=("stop", "warning", "information"))
99
+ imeMode = NoneSet(values=("noControl", "off", "on", "disabled",
100
+ "hiragana", "fullKatakana", "halfKatakana", "fullAlpha","halfAlpha",
101
+ "fullHangul", "halfHangul"))
102
+ operator = NoneSet(values=("between", "notBetween", "equal", "notEqual",
103
+ "lessThan", "lessThanOrEqual", "greaterThan", "greaterThanOrEqual"))
104
+ validation_type = Alias('type')
105
+
106
+ def __init__(self,
107
+ type=None,
108
+ formula1=None,
109
+ formula2=None,
110
+ showErrorMessage=False,
111
+ showInputMessage=False,
112
+ showDropDown=False,
113
+ allowBlank=False,
114
+ sqref=(),
115
+ promptTitle=None,
116
+ errorStyle=None,
117
+ error=None,
118
+ prompt=None,
119
+ errorTitle=None,
120
+ imeMode=None,
121
+ operator=None,
122
+ allow_blank=None,
123
+ ):
124
+ self.sqref = sqref
125
+ self.showDropDown = showDropDown
126
+ self.imeMode = imeMode
127
+ self.operator = operator
128
+ self.formula1 = formula1
129
+ self.formula2 = formula2
130
+ if allow_blank is not None:
131
+ allowBlank = allow_blank
132
+ self.allowBlank = allowBlank
133
+ self.showErrorMessage = showErrorMessage
134
+ self.showInputMessage = showInputMessage
135
+ self.type = type
136
+ self.promptTitle = promptTitle
137
+ self.errorStyle = errorStyle
138
+ self.error = error
139
+ self.prompt = prompt
140
+ self.errorTitle = errorTitle
141
+
142
+
143
+ def add(self, cell):
144
+ """Adds a cell or cell coordinate to this validator"""
145
+ if hasattr(cell, "coordinate"):
146
+ cell = cell.coordinate
147
+ self.sqref += cell
148
+
149
+
150
+ def __contains__(self, cell):
151
+ if hasattr(cell, "coordinate"):
152
+ cell = cell.coordinate
153
+ return cell in self.sqref
154
+
155
+
156
+ class DataValidationList(Serialisable):
157
+
158
+ tagname = "dataValidations"
159
+
160
+ disablePrompts = Bool(allow_none=True)
161
+ xWindow = Integer(allow_none=True)
162
+ yWindow = Integer(allow_none=True)
163
+ dataValidation = Sequence(expected_type=DataValidation)
164
+
165
+ __elements__ = ('dataValidation',)
166
+ __attrs__ = ('disablePrompts', 'xWindow', 'yWindow', 'count')
167
+
168
+ def __init__(self,
169
+ disablePrompts=None,
170
+ xWindow=None,
171
+ yWindow=None,
172
+ count=None,
173
+ dataValidation=(),
174
+ ):
175
+ self.disablePrompts = disablePrompts
176
+ self.xWindow = xWindow
177
+ self.yWindow = yWindow
178
+ self.dataValidation = dataValidation
179
+
180
+
181
+ @property
182
+ def count(self):
183
+ return len(self)
184
+
185
+
186
+ def __len__(self):
187
+ return len(self.dataValidation)
188
+
189
+
190
+ def append(self, dv):
191
+ self.dataValidation.append(dv)
192
+
193
+
194
+ def to_tree(self, tagname=None):
195
+ """
196
+ Need to skip validations that have no cell ranges
197
+ """
198
+ ranges = self.dataValidation # copy
199
+ self.dataValidation = [r for r in self.dataValidation if bool(r.sqref)]
200
+ xml = super().to_tree(tagname)
201
+ self.dataValidation = ranges
202
+ return xml
@@ -0,0 +1,306 @@
1
+ # Copyright (c) 2010-2024 openpyxl
2
+
3
+ from copy import copy
4
+
5
+ from openpyxl.compat import safe_string
6
+ from openpyxl.utils import (
7
+ get_column_letter,
8
+ get_column_interval,
9
+ column_index_from_string,
10
+ range_boundaries,
11
+ )
12
+ from openpyxl.utils.units import DEFAULT_COLUMN_WIDTH
13
+ from openpyxl.descriptors import (
14
+ Integer,
15
+ Float,
16
+ Bool,
17
+ Strict,
18
+ String,
19
+ Alias,
20
+ )
21
+ from openpyxl.descriptors.serialisable import Serialisable
22
+ from openpyxl.styles.styleable import StyleableObject
23
+ from openpyxl.utils.bound_dictionary import BoundDictionary
24
+ from openpyxl.xml.functions import Element
25
+
26
+
27
+ class Dimension(Strict, StyleableObject):
28
+ """Information about the display properties of a row or column."""
29
+ __fields__ = ('hidden',
30
+ 'outlineLevel',
31
+ 'collapsed',)
32
+
33
+ index = Integer()
34
+ hidden = Bool()
35
+ outlineLevel = Integer(allow_none=True)
36
+ outline_level = Alias('outlineLevel')
37
+ collapsed = Bool()
38
+ style = Alias('style_id')
39
+
40
+
41
+ def __init__(self, index, hidden, outlineLevel,
42
+ collapsed, worksheet, visible=True, style=None):
43
+ super().__init__(sheet=worksheet, style_array=style)
44
+ self.index = index
45
+ self.hidden = hidden
46
+ self.outlineLevel = outlineLevel
47
+ self.collapsed = collapsed
48
+
49
+
50
+ def __iter__(self):
51
+ for key in self.__fields__:
52
+ value = getattr(self, key, None)
53
+ if value:
54
+ yield key, safe_string(value)
55
+
56
+
57
+ def __copy__(self):
58
+ cp = self.__new__(self.__class__)
59
+ attrib = self.__dict__
60
+ attrib['worksheet'] = self.parent
61
+ cp.__init__(**attrib)
62
+ cp._style = copy(self._style)
63
+ return cp
64
+
65
+
66
+ def __repr__(self):
67
+ return f"<{self.__class__.__name__} Instance, Attributes={dict(self)}>"
68
+
69
+
70
+ class RowDimension(Dimension):
71
+ """Information about the display properties of a row."""
72
+
73
+ __fields__ = Dimension.__fields__ + ('ht', 'customFormat', 'customHeight', 's',
74
+ 'thickBot', 'thickTop')
75
+ r = Alias('index')
76
+ s = Alias('style_id')
77
+ ht = Float(allow_none=True)
78
+ height = Alias('ht')
79
+ thickBot = Bool()
80
+ thickTop = Bool()
81
+
82
+ def __init__(self,
83
+ worksheet,
84
+ index=0,
85
+ ht=None,
86
+ customHeight=None, # do not write
87
+ s=None,
88
+ customFormat=None, # do not write
89
+ hidden=False,
90
+ outlineLevel=0,
91
+ outline_level=None,
92
+ collapsed=False,
93
+ visible=None,
94
+ height=None,
95
+ r=None,
96
+ spans=None,
97
+ thickBot=None,
98
+ thickTop=None,
99
+ **kw
100
+ ):
101
+ if r is not None:
102
+ index = r
103
+ if height is not None:
104
+ ht = height
105
+ self.ht = ht
106
+ if visible is not None:
107
+ hidden = not visible
108
+ if outline_level is not None:
109
+ outlineLevel = outline_level
110
+ self.thickBot = thickBot
111
+ self.thickTop = thickTop
112
+ super().__init__(index, hidden, outlineLevel,
113
+ collapsed, worksheet, style=s)
114
+
115
+ @property
116
+ def customFormat(self):
117
+ """Always true if there is a style for the row"""
118
+ return self.has_style
119
+
120
+ @property
121
+ def customHeight(self):
122
+ """Always true if there is a height for the row"""
123
+ return self.ht is not None
124
+
125
+
126
+ class ColumnDimension(Dimension):
127
+ """Information about the display properties of a column."""
128
+
129
+ width = Float()
130
+ bestFit = Bool()
131
+ auto_size = Alias('bestFit')
132
+ index = String()
133
+ min = Integer(allow_none=True)
134
+ max = Integer(allow_none=True)
135
+ collapsed = Bool()
136
+
137
+ __fields__ = Dimension.__fields__ + ('width', 'bestFit', 'customWidth', 'style',
138
+ 'min', 'max')
139
+
140
+ def __init__(self,
141
+ worksheet,
142
+ index='A',
143
+ width=DEFAULT_COLUMN_WIDTH,
144
+ bestFit=False,
145
+ hidden=False,
146
+ outlineLevel=0,
147
+ outline_level=None,
148
+ collapsed=False,
149
+ style=None,
150
+ min=None,
151
+ max=None,
152
+ customWidth=False, # do not write
153
+ visible=None,
154
+ auto_size=None,):
155
+ self.width = width
156
+ self.min = min
157
+ self.max = max
158
+ if visible is not None:
159
+ hidden = not visible
160
+ if auto_size is not None:
161
+ bestFit = auto_size
162
+ self.bestFit = bestFit
163
+ if outline_level is not None:
164
+ outlineLevel = outline_level
165
+ self.collapsed = collapsed
166
+ super().__init__(index, hidden, outlineLevel,
167
+ collapsed, worksheet, style=style)
168
+
169
+
170
+ @property
171
+ def customWidth(self):
172
+ """Always true if there is a width for the column"""
173
+ return bool(self.width)
174
+
175
+
176
+ def reindex(self):
177
+ """
178
+ Set boundaries for column definition
179
+ """
180
+ if not all([self.min, self.max]):
181
+ self.min = self.max = column_index_from_string(self.index)
182
+
183
+ @property
184
+ def range(self):
185
+ """Return the range of cells actually covered"""
186
+ return f"{get_column_letter(self.min)}:{get_column_letter(self.max)}"
187
+
188
+
189
+ def to_tree(self):
190
+ attrs = dict(self)
191
+ if attrs.keys() != {'min', 'max'}:
192
+ return Element("col", **attrs)
193
+
194
+
195
+ class DimensionHolder(BoundDictionary):
196
+ """
197
+ Allow columns to be grouped
198
+ """
199
+
200
+ def __init__(self, worksheet, reference="index", default_factory=None):
201
+ self.worksheet = worksheet
202
+ self.max_outline = None
203
+ self.default_factory = default_factory
204
+ super().__init__(reference, default_factory)
205
+
206
+
207
+ def group(self, start, end=None, outline_level=1, hidden=False):
208
+ """allow grouping a range of consecutive rows or columns together
209
+
210
+ :param start: first row or column to be grouped (mandatory)
211
+ :param end: last row or column to be grouped (optional, default to start)
212
+ :param outline_level: outline level
213
+ :param hidden: should the group be hidden on workbook open or not
214
+ """
215
+ if end is None:
216
+ end = start
217
+
218
+ if isinstance(self.default_factory(), ColumnDimension):
219
+ new_dim = self[start]
220
+ new_dim.outline_level = outline_level
221
+ new_dim.hidden = hidden
222
+ work_sequence = get_column_interval(start, end)[1:]
223
+ for column_letter in work_sequence:
224
+ if column_letter in self:
225
+ del self[column_letter]
226
+ new_dim.min, new_dim.max = map(column_index_from_string, (start, end))
227
+ elif isinstance(self.default_factory(), RowDimension):
228
+ for el in range(start, end + 1):
229
+ new_dim = self.worksheet.row_dimensions[el]
230
+ new_dim.outline_level = outline_level
231
+ new_dim.hidden = hidden
232
+
233
+
234
+ def to_tree(self):
235
+
236
+ def sorter(value):
237
+ value.reindex()
238
+ return value.min
239
+
240
+ el = Element('cols')
241
+ outlines = set()
242
+
243
+ for col in sorted(self.values(), key=sorter):
244
+ obj = col.to_tree()
245
+ if obj is not None:
246
+ outlines.add(col.outlineLevel)
247
+ el.append(obj)
248
+
249
+ if outlines:
250
+ self.max_outline = max(outlines)
251
+
252
+ if len(el):
253
+ return el # must have at least one child
254
+
255
+
256
+ class SheetFormatProperties(Serialisable):
257
+
258
+ tagname = "sheetFormatPr"
259
+
260
+ baseColWidth = Integer(allow_none=True)
261
+ defaultColWidth = Float(allow_none=True)
262
+ defaultRowHeight = Float()
263
+ customHeight = Bool(allow_none=True)
264
+ zeroHeight = Bool(allow_none=True)
265
+ thickTop = Bool(allow_none=True)
266
+ thickBottom = Bool(allow_none=True)
267
+ outlineLevelRow = Integer(allow_none=True)
268
+ outlineLevelCol = Integer(allow_none=True)
269
+
270
+ def __init__(self,
271
+ baseColWidth=8, #according to spec
272
+ defaultColWidth=None,
273
+ defaultRowHeight=15,
274
+ customHeight=None,
275
+ zeroHeight=None,
276
+ thickTop=None,
277
+ thickBottom=None,
278
+ outlineLevelRow=None,
279
+ outlineLevelCol=None,
280
+ ):
281
+ self.baseColWidth = baseColWidth
282
+ self.defaultColWidth = defaultColWidth
283
+ self.defaultRowHeight = defaultRowHeight
284
+ self.customHeight = customHeight
285
+ self.zeroHeight = zeroHeight
286
+ self.thickTop = thickTop
287
+ self.thickBottom = thickBottom
288
+ self.outlineLevelRow = outlineLevelRow
289
+ self.outlineLevelCol = outlineLevelCol
290
+
291
+
292
+ class SheetDimension(Serialisable):
293
+
294
+ tagname = "dimension"
295
+
296
+ ref = String()
297
+
298
+ def __init__(self,
299
+ ref=None,
300
+ ):
301
+ self.ref = ref
302
+
303
+
304
+ @property
305
+ def boundaries(self):
306
+ return range_boundaries(self.ref)
@@ -0,0 +1,14 @@
1
+ # Copyright (c) 2010-2024 openpyxl
2
+
3
+ from openpyxl.descriptors.serialisable import Serialisable
4
+ from openpyxl.descriptors.excel import Relation
5
+
6
+
7
+ class Drawing(Serialisable):
8
+
9
+ tagname = "drawing"
10
+
11
+ id = Relation()
12
+
13
+ def __init__(self, id=None):
14
+ self.id = id