@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,270 @@
1
+ # Copyright (c) 2010-2024 openpyxl
2
+
3
+ # Simplified implementation of headers and footers: let worksheets have separate items
4
+
5
+ import re
6
+ from warnings import warn
7
+
8
+ from openpyxl.descriptors import (
9
+ Alias,
10
+ Bool,
11
+ Strict,
12
+ String,
13
+ Integer,
14
+ MatchPattern,
15
+ Typed,
16
+ )
17
+ from openpyxl.descriptors.serialisable import Serialisable
18
+
19
+
20
+ from openpyxl.xml.functions import Element
21
+ from openpyxl.utils.escape import escape, unescape
22
+
23
+
24
+ FONT_PATTERN = '&"(?P<font>.+)"'
25
+ COLOR_PATTERN = "&K(?P<color>[A-F0-9]{6})"
26
+ SIZE_REGEX = r"&(?P<size>\d+\s?)"
27
+ FORMAT_REGEX = re.compile("{0}|{1}|{2}".format(FONT_PATTERN, COLOR_PATTERN,
28
+ SIZE_REGEX)
29
+ )
30
+
31
+ def _split_string(text):
32
+ """
33
+ Split the combined (decoded) string into left, center and right parts
34
+
35
+ # See http://stackoverflow.com/questions/27711175/regex-with-multiple-optional-groups for discussion
36
+ """
37
+
38
+ ITEM_REGEX = re.compile("""
39
+ (&L(?P<left>.+?))?
40
+ (&C(?P<center>.+?))?
41
+ (&R(?P<right>.+?))?
42
+ $""", re.VERBOSE | re.DOTALL)
43
+
44
+ m = ITEM_REGEX.match(text)
45
+ try:
46
+ parts = m.groupdict()
47
+ except AttributeError:
48
+ warn("""Cannot parse header or footer so it will be ignored""")
49
+ parts = {'left':'', 'right':'', 'center':''}
50
+ return parts
51
+
52
+
53
+ class _HeaderFooterPart(Strict):
54
+
55
+ """
56
+ Individual left/center/right header/footer part
57
+
58
+ Do not use directly.
59
+
60
+ Header & Footer ampersand codes:
61
+
62
+ * &A Inserts the worksheet name
63
+ * &B Toggles bold
64
+ * &D or &[Date] Inserts the current date
65
+ * &E Toggles double-underline
66
+ * &F or &[File] Inserts the workbook name
67
+ * &I Toggles italic
68
+ * &N or &[Pages] Inserts the total page count
69
+ * &S Toggles strikethrough
70
+ * &T Inserts the current time
71
+ * &[Tab] Inserts the worksheet name
72
+ * &U Toggles underline
73
+ * &X Toggles superscript
74
+ * &Y Toggles subscript
75
+ * &P or &[Page] Inserts the current page number
76
+ * &P+n Inserts the page number incremented by n
77
+ * &P-n Inserts the page number decremented by n
78
+ * &[Path] Inserts the workbook path
79
+ * && Escapes the ampersand character
80
+ * &"fontname" Selects the named font
81
+ * &nn Selects the specified 2-digit font point size
82
+
83
+ Colours are in RGB Hex
84
+ """
85
+
86
+ text = String(allow_none=True)
87
+ font = String(allow_none=True)
88
+ size = Integer(allow_none=True)
89
+ RGB = ("^[A-Fa-f0-9]{6}$")
90
+ color = MatchPattern(allow_none=True, pattern=RGB)
91
+
92
+
93
+ def __init__(self, text=None, font=None, size=None, color=None):
94
+ self.text = text
95
+ self.font = font
96
+ self.size = size
97
+ self.color = color
98
+
99
+
100
+ def __str__(self):
101
+ """
102
+ Convert to Excel HeaderFooter miniformat minus position
103
+ """
104
+ fmt = []
105
+ if self.font:
106
+ fmt.append(u'&"{0}"'.format(self.font))
107
+ if self.size:
108
+ fmt.append("&{0} ".format(self.size))
109
+ if self.color:
110
+ fmt.append("&K{0}".format(self.color))
111
+ return u"".join(fmt + [self.text])
112
+
113
+ def __bool__(self):
114
+ return bool(self.text)
115
+
116
+
117
+
118
+ @classmethod
119
+ def from_str(cls, text):
120
+ """
121
+ Convert from miniformat to object
122
+ """
123
+ keys = ('font', 'color', 'size')
124
+ kw = dict((k, v) for match in FORMAT_REGEX.findall(text)
125
+ for k, v in zip(keys, match) if v)
126
+
127
+ kw['text'] = FORMAT_REGEX.sub('', text)
128
+
129
+ return cls(**kw)
130
+
131
+
132
+ class HeaderFooterItem(Strict):
133
+ """
134
+ Header or footer item
135
+
136
+ """
137
+
138
+ left = Typed(expected_type=_HeaderFooterPart)
139
+ center = Typed(expected_type=_HeaderFooterPart)
140
+ centre = Alias("center")
141
+ right = Typed(expected_type=_HeaderFooterPart)
142
+
143
+ __keys = ('L', 'C', 'R')
144
+
145
+
146
+ def __init__(self, left=None, right=None, center=None):
147
+ if left is None:
148
+ left = _HeaderFooterPart()
149
+ self.left = left
150
+ if center is None:
151
+ center = _HeaderFooterPart()
152
+ self.center = center
153
+ if right is None:
154
+ right = _HeaderFooterPart()
155
+ self.right = right
156
+
157
+
158
+ def __str__(self):
159
+ """
160
+ Pack parts into a single string
161
+ """
162
+ TRANSFORM = {'&[Tab]': '&A', '&[Pages]': '&N', '&[Date]': '&D',
163
+ '&[Path]': '&Z', '&[Page]': '&P', '&[Time]': '&T', '&[File]': '&F',
164
+ '&[Picture]': '&G'}
165
+
166
+ # escape keys and create regex
167
+ SUBS_REGEX = re.compile("|".join(["({0})".format(re.escape(k))
168
+ for k in TRANSFORM]))
169
+
170
+ def replace(match):
171
+ """
172
+ Callback for re.sub
173
+ Replace expanded control with mini-format equivalent
174
+ """
175
+ sub = match.group(0)
176
+ return TRANSFORM[sub]
177
+
178
+ txt = []
179
+ for key, part in zip(
180
+ self.__keys, [self.left, self.center, self.right]):
181
+ if part.text is not None:
182
+ txt.append(u"&{0}{1}".format(key, str(part)))
183
+ txt = "".join(txt)
184
+ txt = SUBS_REGEX.sub(replace, txt)
185
+ return escape(txt)
186
+
187
+
188
+ def __bool__(self):
189
+ return any([self.left, self.center, self.right])
190
+
191
+
192
+
193
+ def to_tree(self, tagname):
194
+ """
195
+ Return as XML node
196
+ """
197
+ el = Element(tagname)
198
+ el.text = str(self)
199
+ return el
200
+
201
+
202
+ @classmethod
203
+ def from_tree(cls, node):
204
+ if node.text:
205
+ text = unescape(node.text)
206
+ parts = _split_string(text)
207
+ for k, v in parts.items():
208
+ if v is not None:
209
+ parts[k] = _HeaderFooterPart.from_str(v)
210
+ self = cls(**parts)
211
+ return self
212
+
213
+
214
+ class HeaderFooter(Serialisable):
215
+
216
+ tagname = "headerFooter"
217
+
218
+ differentOddEven = Bool(allow_none=True)
219
+ differentFirst = Bool(allow_none=True)
220
+ scaleWithDoc = Bool(allow_none=True)
221
+ alignWithMargins = Bool(allow_none=True)
222
+ oddHeader = Typed(expected_type=HeaderFooterItem, allow_none=True)
223
+ oddFooter = Typed(expected_type=HeaderFooterItem, allow_none=True)
224
+ evenHeader = Typed(expected_type=HeaderFooterItem, allow_none=True)
225
+ evenFooter = Typed(expected_type=HeaderFooterItem, allow_none=True)
226
+ firstHeader = Typed(expected_type=HeaderFooterItem, allow_none=True)
227
+ firstFooter = Typed(expected_type=HeaderFooterItem, allow_none=True)
228
+
229
+ __elements__ = ("oddHeader", "oddFooter", "evenHeader", "evenFooter", "firstHeader", "firstFooter")
230
+
231
+ def __init__(self,
232
+ differentOddEven=None,
233
+ differentFirst=None,
234
+ scaleWithDoc=None,
235
+ alignWithMargins=None,
236
+ oddHeader=None,
237
+ oddFooter=None,
238
+ evenHeader=None,
239
+ evenFooter=None,
240
+ firstHeader=None,
241
+ firstFooter=None,
242
+ ):
243
+ self.differentOddEven = differentOddEven
244
+ self.differentFirst = differentFirst
245
+ self.scaleWithDoc = scaleWithDoc
246
+ self.alignWithMargins = alignWithMargins
247
+ if oddHeader is None:
248
+ oddHeader = HeaderFooterItem()
249
+ self.oddHeader = oddHeader
250
+ if oddFooter is None:
251
+ oddFooter = HeaderFooterItem()
252
+ self.oddFooter = oddFooter
253
+ if evenHeader is None:
254
+ evenHeader = HeaderFooterItem()
255
+ self.evenHeader = evenHeader
256
+ if evenFooter is None:
257
+ evenFooter = HeaderFooterItem()
258
+ self.evenFooter = evenFooter
259
+ if firstHeader is None:
260
+ firstHeader = HeaderFooterItem()
261
+ self.firstHeader = firstHeader
262
+ if firstFooter is None:
263
+ firstFooter = HeaderFooterItem()
264
+ self.firstFooter = firstFooter
265
+
266
+
267
+ def __bool__(self):
268
+ parts = [getattr(self, attr) for attr in self.__attrs__ + self.__elements__]
269
+ return any(parts)
270
+
@@ -0,0 +1,46 @@
1
+ from openpyxl.descriptors.serialisable import Serialisable
2
+ from openpyxl.descriptors import (
3
+ String,
4
+ Sequence,
5
+ )
6
+ from openpyxl.descriptors.excel import Relation
7
+
8
+
9
+ class Hyperlink(Serialisable):
10
+
11
+ tagname = "hyperlink"
12
+
13
+ ref = String()
14
+ location = String(allow_none=True)
15
+ tooltip = String(allow_none=True)
16
+ display = String(allow_none=True)
17
+ id = Relation()
18
+ target = String(allow_none=True)
19
+
20
+ __attrs__ = ("ref", "location", "tooltip", "display", "id")
21
+
22
+ def __init__(self,
23
+ ref=None,
24
+ location=None,
25
+ tooltip=None,
26
+ display=None,
27
+ id=None,
28
+ target=None,
29
+ ):
30
+ self.ref = ref
31
+ self.location = location
32
+ self.tooltip = tooltip
33
+ self.display = display
34
+ self.id = id
35
+ self.target = target
36
+
37
+
38
+ class HyperlinkList(Serialisable):
39
+
40
+ tagname = "hyperlinks"
41
+
42
+ __expected_type = Hyperlink
43
+ hyperlink = Sequence(expected_type=__expected_type)
44
+
45
+ def __init__(self, hyperlink=()):
46
+ self.hyperlink = hyperlink
@@ -0,0 +1,141 @@
1
+ # Copyright (c) 2010-2024 openpyxl
2
+
3
+ import copy
4
+
5
+ from openpyxl.descriptors.serialisable import Serialisable
6
+ from openpyxl.descriptors import (
7
+ Integer,
8
+ Sequence,
9
+ )
10
+
11
+ from openpyxl.cell.cell import MergedCell
12
+ from openpyxl.styles.borders import Border
13
+
14
+ from .cell_range import CellRange
15
+
16
+
17
+ class MergeCell(CellRange):
18
+
19
+ tagname = "mergeCell"
20
+ ref = CellRange.coord
21
+
22
+ __attrs__ = ("ref",)
23
+
24
+
25
+ def __init__(self,
26
+ ref=None,
27
+ ):
28
+ super().__init__(ref)
29
+
30
+
31
+ def __copy__(self):
32
+ return self.__class__(self.ref)
33
+
34
+
35
+ class MergeCells(Serialisable):
36
+
37
+ tagname = "mergeCells"
38
+
39
+ count = Integer(allow_none=True)
40
+ mergeCell = Sequence(expected_type=MergeCell, )
41
+
42
+ __elements__ = ('mergeCell',)
43
+ __attrs__ = ('count',)
44
+
45
+ def __init__(self,
46
+ count=None,
47
+ mergeCell=(),
48
+ ):
49
+ self.mergeCell = mergeCell
50
+
51
+
52
+ @property
53
+ def count(self):
54
+ return len(self.mergeCell)
55
+
56
+
57
+ class MergedCellRange(CellRange):
58
+
59
+ """
60
+ MergedCellRange stores the border information of a merged cell in the top
61
+ left cell of the merged cell.
62
+ The remaining cells in the merged cell are stored as MergedCell objects and
63
+ get their border information from the upper left cell.
64
+ """
65
+
66
+ def __init__(self, worksheet, coord):
67
+ self.ws = worksheet
68
+ super().__init__(range_string=coord)
69
+ self.start_cell = None
70
+ self._get_borders()
71
+
72
+
73
+ def _get_borders(self):
74
+ """
75
+ If the upper left cell of the merged cell does not yet exist, it is
76
+ created.
77
+ The upper left cell gets the border information of the bottom and right
78
+ border from the bottom right cell of the merged cell, if available.
79
+ """
80
+
81
+ # Top-left cell.
82
+ self.start_cell = self.ws._cells.get((self.min_row, self.min_col))
83
+ if self.start_cell is None:
84
+ self.start_cell = self.ws.cell(row=self.min_row, column=self.min_col)
85
+
86
+ # Bottom-right cell
87
+ end_cell = self.ws._cells.get((self.max_row, self.max_col))
88
+ if end_cell is not None:
89
+ self.start_cell.border += Border(right=end_cell.border.right,
90
+ bottom=end_cell.border.bottom)
91
+
92
+
93
+ def format(self):
94
+ """
95
+ Each cell of the merged cell is created as MergedCell if it does not
96
+ already exist.
97
+
98
+ The MergedCells at the edge of the merged cell gets its borders from
99
+ the upper left cell.
100
+
101
+ - The top MergedCells get the top border from the top left cell.
102
+ - The bottom MergedCells get the bottom border from the top left cell.
103
+ - The left MergedCells get the left border from the top left cell.
104
+ - The right MergedCells get the right border from the top left cell.
105
+ """
106
+
107
+ names = ['top', 'left', 'right', 'bottom']
108
+
109
+ for name in names:
110
+ side = getattr(self.start_cell.border, name)
111
+ if side and side.style is None:
112
+ continue # don't need to do anything if there is no border style
113
+ border = Border(**{name:side})
114
+ for coord in getattr(self, name):
115
+ cell = self.ws._cells.get(coord)
116
+ if cell is None:
117
+ row, col = coord
118
+ cell = MergedCell(self.ws, row=row, column=col)
119
+ self.ws._cells[(cell.row, cell.column)] = cell
120
+ cell.border += border
121
+
122
+ protected = self.start_cell.protection is not None
123
+ if protected:
124
+ protection = copy.copy(self.start_cell.protection)
125
+ for coord in self.cells:
126
+ cell = self.ws._cells.get(coord)
127
+ if cell is None:
128
+ row, col = coord
129
+ cell = MergedCell(self.ws, row=row, column=col)
130
+ self.ws._cells[(cell.row, cell.column)] = cell
131
+
132
+ if protected:
133
+ cell.protection = protection
134
+
135
+
136
+ def __contains__(self, coord):
137
+ return coord in CellRange(self.coord)
138
+
139
+
140
+ def __copy__(self):
141
+ return self.__class__(self.ws, self.coord)
@@ -0,0 +1,133 @@
1
+ # Copyright (c) 2010-2024 openpyxl
2
+
3
+ from openpyxl.descriptors.serialisable import Serialisable
4
+ from openpyxl.descriptors import (
5
+ Typed,
6
+ Integer,
7
+ String,
8
+ Set,
9
+ Bool,
10
+ Sequence,
11
+ )
12
+
13
+ from openpyxl.drawing.spreadsheet_drawing import AnchorMarker
14
+ from openpyxl.xml.constants import SHEET_DRAWING_NS
15
+
16
+
17
+ class ObjectAnchor(Serialisable):
18
+
19
+ tagname = "anchor"
20
+
21
+ _from = Typed(expected_type=AnchorMarker, namespace=SHEET_DRAWING_NS)
22
+ to = Typed(expected_type=AnchorMarker, namespace=SHEET_DRAWING_NS)
23
+ moveWithCells = Bool(allow_none=True)
24
+ sizeWithCells = Bool(allow_none=True)
25
+ z_order = Integer(allow_none=True, hyphenated=True)
26
+
27
+
28
+ def __init__(self,
29
+ _from=None,
30
+ to=None,
31
+ moveWithCells=False,
32
+ sizeWithCells=False,
33
+ z_order=None,
34
+ ):
35
+ self._from = _from
36
+ self.to = to
37
+ self.moveWithCells = moveWithCells
38
+ self.sizeWithCells = sizeWithCells
39
+ self.z_order = z_order
40
+
41
+
42
+ class ObjectPr(Serialisable):
43
+
44
+ tagname = "objectPr"
45
+
46
+ anchor = Typed(expected_type=ObjectAnchor, )
47
+ locked = Bool(allow_none=True)
48
+ defaultSize = Bool(allow_none=True)
49
+ _print = Bool(allow_none=True)
50
+ disabled = Bool(allow_none=True)
51
+ uiObject = Bool(allow_none=True)
52
+ autoFill = Bool(allow_none=True)
53
+ autoLine = Bool(allow_none=True)
54
+ autoPict = Bool(allow_none=True)
55
+ macro = String()
56
+ altText = String(allow_none=True)
57
+ dde = Bool(allow_none=True)
58
+
59
+ __elements__ = ('anchor',)
60
+
61
+ def __init__(self,
62
+ anchor=None,
63
+ locked=True,
64
+ defaultSize=True,
65
+ _print=True,
66
+ disabled=False,
67
+ uiObject=False,
68
+ autoFill=True,
69
+ autoLine=True,
70
+ autoPict=True,
71
+ macro=None,
72
+ altText=None,
73
+ dde=False,
74
+ ):
75
+ self.anchor = anchor
76
+ self.locked = locked
77
+ self.defaultSize = defaultSize
78
+ self._print = _print
79
+ self.disabled = disabled
80
+ self.uiObject = uiObject
81
+ self.autoFill = autoFill
82
+ self.autoLine = autoLine
83
+ self.autoPict = autoPict
84
+ self.macro = macro
85
+ self.altText = altText
86
+ self.dde = dde
87
+
88
+
89
+ class OleObject(Serialisable):
90
+
91
+ tagname = "oleObject"
92
+
93
+ objectPr = Typed(expected_type=ObjectPr, allow_none=True)
94
+ progId = String(allow_none=True)
95
+ dvAspect = Set(values=(['DVASPECT_CONTENT', 'DVASPECT_ICON']))
96
+ link = String(allow_none=True)
97
+ oleUpdate = Set(values=(['OLEUPDATE_ALWAYS', 'OLEUPDATE_ONCALL']))
98
+ autoLoad = Bool(allow_none=True)
99
+ shapeId = Integer()
100
+
101
+ __elements__ = ('objectPr',)
102
+
103
+ def __init__(self,
104
+ objectPr=None,
105
+ progId=None,
106
+ dvAspect='DVASPECT_CONTENT',
107
+ link=None,
108
+ oleUpdate=None,
109
+ autoLoad=False,
110
+ shapeId=None,
111
+ ):
112
+ self.objectPr = objectPr
113
+ self.progId = progId
114
+ self.dvAspect = dvAspect
115
+ self.link = link
116
+ self.oleUpdate = oleUpdate
117
+ self.autoLoad = autoLoad
118
+ self.shapeId = shapeId
119
+
120
+
121
+ class OleObjects(Serialisable):
122
+
123
+ tagname = "oleObjects"
124
+
125
+ oleObject = Sequence(expected_type=OleObject)
126
+
127
+ __elements__ = ('oleObject',)
128
+
129
+ def __init__(self,
130
+ oleObject=(),
131
+ ):
132
+ self.oleObject = oleObject
133
+