@v587d/capital-generation 2.29.0 → 2.30.1

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 (305) hide show
  1. package/CHANGELOG.md +58 -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/dataset-tools.js +4 -2
  11. package/lib/data-collector/describe.d.ts +2 -0
  12. package/lib/data-collector/describe.js +2 -0
  13. package/lib/data-collector/store.d.ts +11 -0
  14. package/lib/data-collector/store.js +80 -1
  15. package/lib/data-collector/tools.d.ts +1 -1
  16. package/lib/data-collector/tools.js +10 -9
  17. package/lib/python-runtime/errors.d.ts +1 -1
  18. package/lib/python-runtime/errors.js +2 -0
  19. package/lib/python-runtime/manager.d.ts +28 -1
  20. package/lib/python-runtime/manager.js +141 -5
  21. package/lib/python-runtime/probe.d.ts +24 -0
  22. package/lib/python-runtime/probe.js +66 -50
  23. package/lib/sources/csindex-http.d.ts +4 -0
  24. package/lib/sources/csindex-http.js +233 -0
  25. package/lib/sources/eastmoney-http.js +1504 -1
  26. package/lib/sources/fuyao-rest.js +168 -8
  27. package/lib/sources/official-http.d.ts +4 -0
  28. package/lib/sources/official-http.js +477 -0
  29. package/lib/sources/python-remote.d.ts +25 -0
  30. package/lib/sources/python-remote.js +461 -0
  31. package/lib/sources/sina-http.d.ts +2 -0
  32. package/lib/sources/sina-http.js +484 -0
  33. package/lib/sources/tencent-http.js +23 -8
  34. package/lib/sources/ths-http.d.ts +2 -0
  35. package/lib/sources/ths-http.js +517 -0
  36. package/lib/time/tools.js +19 -0
  37. package/lib/web-retriever/local-fetch.d.ts +1 -1
  38. package/lib/web-retriever/local-fetch.js +1 -1
  39. package/lib/web-retriever/sources.d.ts +7 -0
  40. package/lib/web-retriever/sources.js +46 -21
  41. package/lib/web-retriever/throttle.d.ts +8 -0
  42. package/lib/web-retriever/throttle.js +13 -0
  43. package/lib/web-retriever/tools.js +1 -1
  44. package/lib/web-retriever/wind-client.d.ts +1 -1
  45. package/lib/web-retriever/wind-client.js +1 -1
  46. package/package.json +1 -1
  47. package/preset/capital-generation/agent.patch.yml +7 -5
  48. package/preset/capital-generation/skills/capital-data-protocol/SKILL.md +16 -16
  49. package/python/scripts/baostock_stock_basic.py +129 -0
  50. package/python/scripts/baostock_valuation_history.py +141 -0
  51. package/python/scripts/pbc_social_financing.py +291 -0
  52. package/python/vendor/baostock/LICENSE +19 -0
  53. package/python/vendor/baostock/__init__.py +42 -0
  54. package/python/vendor/baostock/common/__init__.py +0 -0
  55. package/python/vendor/baostock/common/contants.py +189 -0
  56. package/python/vendor/baostock/common/context.py +4 -0
  57. package/python/vendor/baostock/corpreport/__init__.py +0 -0
  58. package/python/vendor/baostock/corpreport/corp_performance.py +202 -0
  59. package/python/vendor/baostock/data/__init__.py +0 -0
  60. package/python/vendor/baostock/data/messageheader.py +17 -0
  61. package/python/vendor/baostock/data/msg.py +21 -0
  62. package/python/vendor/baostock/data/resultset.py +200 -0
  63. package/python/vendor/baostock/demo/__init__.py +0 -0
  64. package/python/vendor/baostock/demo/demo_A_stock_5mk-data.py +34 -0
  65. package/python/vendor/baostock/demo/demo_A_stock_k_data.py +36 -0
  66. package/python/vendor/baostock/demo/demo_AllStock.py +27 -0
  67. package/python/vendor/baostock/demo/demo_Balance_data.py +22 -0
  68. package/python/vendor/baostock/demo/demo_CashFlow_data.py +22 -0
  69. package/python/vendor/baostock/demo/demo_Dividend_data.py +35 -0
  70. package/python/vendor/baostock/demo/demo_Dupont_data.py +25 -0
  71. package/python/vendor/baostock/demo/demo_Forecast_report.py +24 -0
  72. package/python/vendor/baostock/demo/demo_Growth_data.py +22 -0
  73. package/python/vendor/baostock/demo/demo_Index_k_data.py +39 -0
  74. package/python/vendor/baostock/demo/demo_Operation_data.py +22 -0
  75. package/python/vendor/baostock/demo/demo_PerformanceExpress_report.py +25 -0
  76. package/python/vendor/baostock/demo/demo_Profit_data.py +22 -0
  77. package/python/vendor/baostock/demo/demo_TradeDates.py +27 -0
  78. package/python/vendor/baostock/demo/demo_adjust_factor_data.py +23 -0
  79. package/python/vendor/baostock/demo/demo_assignDayData.py +23 -0
  80. package/python/vendor/baostock/demo/demo_daily_adjust_factor_data.py +28 -0
  81. package/python/vendor/baostock/demo/demo_daily_k_4_AStock.py +28 -0
  82. package/python/vendor/baostock/demo/demo_daily_k_4_ETF.py +28 -0
  83. package/python/vendor/baostock/demo/demo_depositRate_data.py +26 -0
  84. package/python/vendor/baostock/demo/demo_hs300_stocks.py +26 -0
  85. package/python/vendor/baostock/demo/demo_loanRate_data.py +26 -0
  86. package/python/vendor/baostock/demo/demo_moneySupplyDataMonth_data.py +26 -0
  87. package/python/vendor/baostock/demo/demo_moneySupplyDataYear_data.py +26 -0
  88. package/python/vendor/baostock/demo/demo_requiredReserveRatio_data.py +26 -0
  89. package/python/vendor/baostock/demo/demo_set_API_key.py +37 -0
  90. package/python/vendor/baostock/demo/demo_stockBasic_data.py +27 -0
  91. package/python/vendor/baostock/demo/demo_stock_Valuation_indicator_data.py +34 -0
  92. package/python/vendor/baostock/demo/demo_stock_industry.py +26 -0
  93. package/python/vendor/baostock/demo/demo_sz50stocks.py +26 -0
  94. package/python/vendor/baostock/demo/demo_zz500_stock.py +26 -0
  95. package/python/vendor/baostock/evaluation/__init__.py +0 -0
  96. package/python/vendor/baostock/evaluation/season_index.py +758 -0
  97. package/python/vendor/baostock/login/__init__.py +0 -0
  98. package/python/vendor/baostock/login/loginout.py +230 -0
  99. package/python/vendor/baostock/macroscopic/__init__.py +0 -0
  100. package/python/vendor/baostock/macroscopic/economic_data.py +723 -0
  101. package/python/vendor/baostock/metadata/__init__.py +0 -0
  102. package/python/vendor/baostock/metadata/stock_metadata.py +207 -0
  103. package/python/vendor/baostock/security/__init__.py +0 -0
  104. package/python/vendor/baostock/security/history.py +265 -0
  105. package/python/vendor/baostock/security/sectorinfo.py +1024 -0
  106. package/python/vendor/baostock/util/__init__.py +0 -0
  107. package/python/vendor/baostock/util/socketutil.py +97 -0
  108. package/python/vendor/baostock/util/stringutil.py +83 -0
  109. package/python/vendor/et_xmlfile/LICENSE +23 -0
  110. package/python/vendor/et_xmlfile/LICENSE.python +298 -0
  111. package/python/vendor/et_xmlfile/__init__.py +8 -0
  112. package/python/vendor/et_xmlfile/incremental_tree.py +917 -0
  113. package/python/vendor/et_xmlfile/xmlfile.py +158 -0
  114. package/python/vendor/openpyxl/LICENSE +23 -0
  115. package/python/vendor/openpyxl/__init__.py +19 -0
  116. package/python/vendor/openpyxl/_constants.py +13 -0
  117. package/python/vendor/openpyxl/cell/__init__.py +4 -0
  118. package/python/vendor/openpyxl/cell/_writer.py +136 -0
  119. package/python/vendor/openpyxl/cell/cell.py +332 -0
  120. package/python/vendor/openpyxl/cell/read_only.py +136 -0
  121. package/python/vendor/openpyxl/cell/rich_text.py +202 -0
  122. package/python/vendor/openpyxl/cell/text.py +184 -0
  123. package/python/vendor/openpyxl/chart/_3d.py +105 -0
  124. package/python/vendor/openpyxl/chart/__init__.py +19 -0
  125. package/python/vendor/openpyxl/chart/_chart.py +199 -0
  126. package/python/vendor/openpyxl/chart/area_chart.py +106 -0
  127. package/python/vendor/openpyxl/chart/axis.py +401 -0
  128. package/python/vendor/openpyxl/chart/bar_chart.py +144 -0
  129. package/python/vendor/openpyxl/chart/bubble_chart.py +67 -0
  130. package/python/vendor/openpyxl/chart/chartspace.py +195 -0
  131. package/python/vendor/openpyxl/chart/data_source.py +246 -0
  132. package/python/vendor/openpyxl/chart/descriptors.py +43 -0
  133. package/python/vendor/openpyxl/chart/error_bar.py +62 -0
  134. package/python/vendor/openpyxl/chart/label.py +127 -0
  135. package/python/vendor/openpyxl/chart/layout.py +74 -0
  136. package/python/vendor/openpyxl/chart/legend.py +75 -0
  137. package/python/vendor/openpyxl/chart/line_chart.py +129 -0
  138. package/python/vendor/openpyxl/chart/marker.py +90 -0
  139. package/python/vendor/openpyxl/chart/picture.py +35 -0
  140. package/python/vendor/openpyxl/chart/pie_chart.py +177 -0
  141. package/python/vendor/openpyxl/chart/pivot.py +65 -0
  142. package/python/vendor/openpyxl/chart/plotarea.py +162 -0
  143. package/python/vendor/openpyxl/chart/print_settings.py +57 -0
  144. package/python/vendor/openpyxl/chart/radar_chart.py +55 -0
  145. package/python/vendor/openpyxl/chart/reader.py +32 -0
  146. package/python/vendor/openpyxl/chart/reference.py +124 -0
  147. package/python/vendor/openpyxl/chart/scatter_chart.py +53 -0
  148. package/python/vendor/openpyxl/chart/series.py +197 -0
  149. package/python/vendor/openpyxl/chart/series_factory.py +41 -0
  150. package/python/vendor/openpyxl/chart/shapes.py +89 -0
  151. package/python/vendor/openpyxl/chart/stock_chart.py +54 -0
  152. package/python/vendor/openpyxl/chart/surface_chart.py +119 -0
  153. package/python/vendor/openpyxl/chart/text.py +78 -0
  154. package/python/vendor/openpyxl/chart/title.py +76 -0
  155. package/python/vendor/openpyxl/chart/trendline.py +98 -0
  156. package/python/vendor/openpyxl/chart/updown_bars.py +31 -0
  157. package/python/vendor/openpyxl/chartsheet/__init__.py +3 -0
  158. package/python/vendor/openpyxl/chartsheet/chartsheet.py +107 -0
  159. package/python/vendor/openpyxl/chartsheet/custom.py +61 -0
  160. package/python/vendor/openpyxl/chartsheet/properties.py +28 -0
  161. package/python/vendor/openpyxl/chartsheet/protection.py +41 -0
  162. package/python/vendor/openpyxl/chartsheet/publish.py +58 -0
  163. package/python/vendor/openpyxl/chartsheet/relation.py +97 -0
  164. package/python/vendor/openpyxl/chartsheet/views.py +51 -0
  165. package/python/vendor/openpyxl/comments/__init__.py +4 -0
  166. package/python/vendor/openpyxl/comments/author.py +21 -0
  167. package/python/vendor/openpyxl/comments/comment_sheet.py +211 -0
  168. package/python/vendor/openpyxl/comments/comments.py +62 -0
  169. package/python/vendor/openpyxl/comments/shape_writer.py +112 -0
  170. package/python/vendor/openpyxl/compat/__init__.py +54 -0
  171. package/python/vendor/openpyxl/compat/abc.py +8 -0
  172. package/python/vendor/openpyxl/compat/numbers.py +43 -0
  173. package/python/vendor/openpyxl/compat/product.py +17 -0
  174. package/python/vendor/openpyxl/compat/singleton.py +40 -0
  175. package/python/vendor/openpyxl/compat/strings.py +25 -0
  176. package/python/vendor/openpyxl/descriptors/__init__.py +58 -0
  177. package/python/vendor/openpyxl/descriptors/base.py +272 -0
  178. package/python/vendor/openpyxl/descriptors/container.py +41 -0
  179. package/python/vendor/openpyxl/descriptors/excel.py +112 -0
  180. package/python/vendor/openpyxl/descriptors/namespace.py +12 -0
  181. package/python/vendor/openpyxl/descriptors/nested.py +129 -0
  182. package/python/vendor/openpyxl/descriptors/sequence.py +136 -0
  183. package/python/vendor/openpyxl/descriptors/serialisable.py +240 -0
  184. package/python/vendor/openpyxl/descriptors/slots.py +18 -0
  185. package/python/vendor/openpyxl/drawing/__init__.py +4 -0
  186. package/python/vendor/openpyxl/drawing/colors.py +435 -0
  187. package/python/vendor/openpyxl/drawing/connector.py +144 -0
  188. package/python/vendor/openpyxl/drawing/drawing.py +92 -0
  189. package/python/vendor/openpyxl/drawing/effect.py +407 -0
  190. package/python/vendor/openpyxl/drawing/fill.py +425 -0
  191. package/python/vendor/openpyxl/drawing/geometry.py +584 -0
  192. package/python/vendor/openpyxl/drawing/graphic.py +177 -0
  193. package/python/vendor/openpyxl/drawing/image.py +65 -0
  194. package/python/vendor/openpyxl/drawing/line.py +144 -0
  195. package/python/vendor/openpyxl/drawing/picture.py +144 -0
  196. package/python/vendor/openpyxl/drawing/properties.py +174 -0
  197. package/python/vendor/openpyxl/drawing/relation.py +17 -0
  198. package/python/vendor/openpyxl/drawing/spreadsheet_drawing.py +382 -0
  199. package/python/vendor/openpyxl/drawing/text.py +717 -0
  200. package/python/vendor/openpyxl/drawing/xdr.py +33 -0
  201. package/python/vendor/openpyxl/formatting/__init__.py +3 -0
  202. package/python/vendor/openpyxl/formatting/formatting.py +114 -0
  203. package/python/vendor/openpyxl/formatting/rule.py +291 -0
  204. package/python/vendor/openpyxl/formula/__init__.py +3 -0
  205. package/python/vendor/openpyxl/formula/tokenizer.py +446 -0
  206. package/python/vendor/openpyxl/formula/translate.py +166 -0
  207. package/python/vendor/openpyxl/packaging/__init__.py +3 -0
  208. package/python/vendor/openpyxl/packaging/core.py +115 -0
  209. package/python/vendor/openpyxl/packaging/custom.py +289 -0
  210. package/python/vendor/openpyxl/packaging/extended.py +137 -0
  211. package/python/vendor/openpyxl/packaging/interface.py +56 -0
  212. package/python/vendor/openpyxl/packaging/manifest.py +194 -0
  213. package/python/vendor/openpyxl/packaging/relationship.py +158 -0
  214. package/python/vendor/openpyxl/packaging/workbook.py +185 -0
  215. package/python/vendor/openpyxl/pivot/__init__.py +1 -0
  216. package/python/vendor/openpyxl/pivot/cache.py +965 -0
  217. package/python/vendor/openpyxl/pivot/fields.py +326 -0
  218. package/python/vendor/openpyxl/pivot/record.py +111 -0
  219. package/python/vendor/openpyxl/pivot/table.py +1261 -0
  220. package/python/vendor/openpyxl/reader/__init__.py +1 -0
  221. package/python/vendor/openpyxl/reader/drawings.py +71 -0
  222. package/python/vendor/openpyxl/reader/excel.py +349 -0
  223. package/python/vendor/openpyxl/reader/strings.py +44 -0
  224. package/python/vendor/openpyxl/reader/workbook.py +133 -0
  225. package/python/vendor/openpyxl/styles/__init__.py +11 -0
  226. package/python/vendor/openpyxl/styles/alignment.py +62 -0
  227. package/python/vendor/openpyxl/styles/borders.py +103 -0
  228. package/python/vendor/openpyxl/styles/builtins.py +1397 -0
  229. package/python/vendor/openpyxl/styles/cell_style.py +206 -0
  230. package/python/vendor/openpyxl/styles/colors.py +172 -0
  231. package/python/vendor/openpyxl/styles/differential.py +95 -0
  232. package/python/vendor/openpyxl/styles/fills.py +224 -0
  233. package/python/vendor/openpyxl/styles/fonts.py +113 -0
  234. package/python/vendor/openpyxl/styles/named_styles.py +282 -0
  235. package/python/vendor/openpyxl/styles/numbers.py +200 -0
  236. package/python/vendor/openpyxl/styles/protection.py +17 -0
  237. package/python/vendor/openpyxl/styles/proxy.py +62 -0
  238. package/python/vendor/openpyxl/styles/styleable.py +151 -0
  239. package/python/vendor/openpyxl/styles/stylesheet.py +274 -0
  240. package/python/vendor/openpyxl/styles/table.py +94 -0
  241. package/python/vendor/openpyxl/utils/__init__.py +17 -0
  242. package/python/vendor/openpyxl/utils/bound_dictionary.py +26 -0
  243. package/python/vendor/openpyxl/utils/cell.py +240 -0
  244. package/python/vendor/openpyxl/utils/dataframe.py +87 -0
  245. package/python/vendor/openpyxl/utils/datetime.py +140 -0
  246. package/python/vendor/openpyxl/utils/escape.py +43 -0
  247. package/python/vendor/openpyxl/utils/exceptions.py +34 -0
  248. package/python/vendor/openpyxl/utils/formulas.py +24 -0
  249. package/python/vendor/openpyxl/utils/indexed_list.py +49 -0
  250. package/python/vendor/openpyxl/utils/inference.py +60 -0
  251. package/python/vendor/openpyxl/utils/protection.py +22 -0
  252. package/python/vendor/openpyxl/utils/units.py +108 -0
  253. package/python/vendor/openpyxl/workbook/__init__.py +4 -0
  254. package/python/vendor/openpyxl/workbook/_writer.py +197 -0
  255. package/python/vendor/openpyxl/workbook/child.py +166 -0
  256. package/python/vendor/openpyxl/workbook/defined_name.py +189 -0
  257. package/python/vendor/openpyxl/workbook/external_link/__init__.py +3 -0
  258. package/python/vendor/openpyxl/workbook/external_link/external.py +190 -0
  259. package/python/vendor/openpyxl/workbook/external_reference.py +18 -0
  260. package/python/vendor/openpyxl/workbook/function_group.py +36 -0
  261. package/python/vendor/openpyxl/workbook/properties.py +151 -0
  262. package/python/vendor/openpyxl/workbook/protection.py +163 -0
  263. package/python/vendor/openpyxl/workbook/smart_tags.py +56 -0
  264. package/python/vendor/openpyxl/workbook/views.py +155 -0
  265. package/python/vendor/openpyxl/workbook/web.py +98 -0
  266. package/python/vendor/openpyxl/workbook/workbook.py +438 -0
  267. package/python/vendor/openpyxl/worksheet/__init__.py +1 -0
  268. package/python/vendor/openpyxl/worksheet/_read_only.py +190 -0
  269. package/python/vendor/openpyxl/worksheet/_reader.py +472 -0
  270. package/python/vendor/openpyxl/worksheet/_write_only.py +160 -0
  271. package/python/vendor/openpyxl/worksheet/_writer.py +390 -0
  272. package/python/vendor/openpyxl/worksheet/cell_range.py +512 -0
  273. package/python/vendor/openpyxl/worksheet/cell_watch.py +34 -0
  274. package/python/vendor/openpyxl/worksheet/controls.py +107 -0
  275. package/python/vendor/openpyxl/worksheet/copier.py +70 -0
  276. package/python/vendor/openpyxl/worksheet/custom.py +35 -0
  277. package/python/vendor/openpyxl/worksheet/datavalidation.py +202 -0
  278. package/python/vendor/openpyxl/worksheet/dimensions.py +306 -0
  279. package/python/vendor/openpyxl/worksheet/drawing.py +14 -0
  280. package/python/vendor/openpyxl/worksheet/errors.py +93 -0
  281. package/python/vendor/openpyxl/worksheet/filters.py +486 -0
  282. package/python/vendor/openpyxl/worksheet/formula.py +51 -0
  283. package/python/vendor/openpyxl/worksheet/header_footer.py +270 -0
  284. package/python/vendor/openpyxl/worksheet/hyperlink.py +46 -0
  285. package/python/vendor/openpyxl/worksheet/merge.py +141 -0
  286. package/python/vendor/openpyxl/worksheet/ole.py +133 -0
  287. package/python/vendor/openpyxl/worksheet/page.py +174 -0
  288. package/python/vendor/openpyxl/worksheet/pagebreak.py +94 -0
  289. package/python/vendor/openpyxl/worksheet/picture.py +8 -0
  290. package/python/vendor/openpyxl/worksheet/print_settings.py +184 -0
  291. package/python/vendor/openpyxl/worksheet/properties.py +97 -0
  292. package/python/vendor/openpyxl/worksheet/protection.py +120 -0
  293. package/python/vendor/openpyxl/worksheet/related.py +17 -0
  294. package/python/vendor/openpyxl/worksheet/scenario.py +105 -0
  295. package/python/vendor/openpyxl/worksheet/smart_tag.py +78 -0
  296. package/python/vendor/openpyxl/worksheet/table.py +385 -0
  297. package/python/vendor/openpyxl/worksheet/views.py +155 -0
  298. package/python/vendor/openpyxl/worksheet/worksheet.py +907 -0
  299. package/python/vendor/openpyxl/writer/__init__.py +1 -0
  300. package/python/vendor/openpyxl/writer/excel.py +295 -0
  301. package/python/vendor/openpyxl/writer/theme.py +291 -0
  302. package/python/vendor/openpyxl/xml/__init__.py +42 -0
  303. package/python/vendor/openpyxl/xml/constants.py +129 -0
  304. package/python/vendor/openpyxl/xml/functions.py +87 -0
  305. package/watchlist/package.json +1 -1
@@ -0,0 +1 @@
1
+ # Copyright (c) 2010-2024 openpyxl
@@ -0,0 +1,295 @@
1
+ # Copyright (c) 2010-2024 openpyxl
2
+
3
+
4
+ # Python stdlib imports
5
+ import datetime
6
+ import re
7
+ from zipfile import ZipFile, ZIP_DEFLATED
8
+
9
+ # package imports
10
+ from openpyxl.utils.exceptions import InvalidFileException
11
+ from openpyxl.xml.constants import (
12
+ ARC_ROOT_RELS,
13
+ ARC_WORKBOOK_RELS,
14
+ ARC_APP,
15
+ ARC_CORE,
16
+ ARC_CUSTOM,
17
+ CPROPS_TYPE,
18
+ ARC_THEME,
19
+ ARC_STYLE,
20
+ ARC_WORKBOOK,
21
+ )
22
+ from openpyxl.drawing.spreadsheet_drawing import SpreadsheetDrawing
23
+ from openpyxl.xml.functions import tostring, fromstring
24
+ from openpyxl.packaging.manifest import Manifest
25
+ from openpyxl.packaging.relationship import (
26
+ get_rels_path,
27
+ RelationshipList,
28
+ Relationship,
29
+ )
30
+ from openpyxl.comments.comment_sheet import CommentSheet
31
+ from openpyxl.styles.stylesheet import write_stylesheet
32
+ from openpyxl.worksheet._writer import WorksheetWriter
33
+ from openpyxl.workbook._writer import WorkbookWriter
34
+ from .theme import theme_xml
35
+
36
+
37
+ class ExcelWriter:
38
+ """Write a workbook object to an Excel file."""
39
+
40
+ def __init__(self, workbook, archive):
41
+ self._archive = archive
42
+ self.workbook = workbook
43
+ self.manifest = Manifest()
44
+ self.vba_modified = set()
45
+ self._tables = []
46
+ self._charts = []
47
+ self._images = []
48
+ self._drawings = []
49
+ self._comments = []
50
+ self._pivots = []
51
+
52
+
53
+ def write_data(self):
54
+ from openpyxl.packaging.extended import ExtendedProperties
55
+ """Write the various xml files into the zip archive."""
56
+ # cleanup all worksheets
57
+ archive = self._archive
58
+
59
+ props = ExtendedProperties()
60
+ archive.writestr(ARC_APP, tostring(props.to_tree()))
61
+
62
+ archive.writestr(ARC_CORE, tostring(self.workbook.properties.to_tree()))
63
+ if self.workbook.loaded_theme:
64
+ archive.writestr(ARC_THEME, self.workbook.loaded_theme)
65
+ else:
66
+ archive.writestr(ARC_THEME, theme_xml)
67
+
68
+ if len(self.workbook.custom_doc_props) >= 1:
69
+ archive.writestr(ARC_CUSTOM, tostring(self.workbook.custom_doc_props.to_tree()))
70
+ class CustomOverride():
71
+ path = "/" + ARC_CUSTOM #PartName
72
+ mime_type = CPROPS_TYPE #ContentType
73
+
74
+ custom_override = CustomOverride()
75
+ self.manifest.append(custom_override)
76
+
77
+ self._write_worksheets()
78
+ self._write_chartsheets()
79
+ self._write_images()
80
+ self._write_charts()
81
+
82
+ self._write_external_links()
83
+
84
+ stylesheet = write_stylesheet(self.workbook)
85
+ archive.writestr(ARC_STYLE, tostring(stylesheet))
86
+
87
+ writer = WorkbookWriter(self.workbook)
88
+ archive.writestr(ARC_ROOT_RELS, writer.write_root_rels())
89
+ archive.writestr(ARC_WORKBOOK, writer.write())
90
+ archive.writestr(ARC_WORKBOOK_RELS, writer.write_rels())
91
+
92
+ self._merge_vba()
93
+
94
+ self.manifest._write(archive, self.workbook)
95
+
96
+ def _merge_vba(self):
97
+ """
98
+ If workbook contains macros then extract associated files from cache
99
+ of old file and add to archive
100
+ """
101
+ ARC_VBA = re.compile("|".join(
102
+ ('xl/vba', r'xl/drawings/.*vmlDrawing\d\.vml',
103
+ 'xl/ctrlProps', 'customUI', 'xl/activeX', r'xl/media/.*\.emf')
104
+ )
105
+ )
106
+
107
+ if self.workbook.vba_archive:
108
+ for name in set(self.workbook.vba_archive.namelist()) - self.vba_modified:
109
+ if ARC_VBA.match(name):
110
+ self._archive.writestr(name, self.workbook.vba_archive.read(name))
111
+
112
+
113
+ def _write_images(self):
114
+ # delegate to object
115
+ for img in self._images:
116
+ self._archive.writestr(img.path[1:], img._data())
117
+
118
+
119
+ def _write_charts(self):
120
+ # delegate to object
121
+ if len(self._charts) != len(set(self._charts)):
122
+ raise InvalidFileException("The same chart cannot be used in more than one worksheet")
123
+ for chart in self._charts:
124
+ self._archive.writestr(chart.path[1:], tostring(chart._write()))
125
+ self.manifest.append(chart)
126
+
127
+
128
+ def _write_drawing(self, drawing):
129
+ """
130
+ Write a drawing
131
+ """
132
+ self._drawings.append(drawing)
133
+ drawing._id = len(self._drawings)
134
+ for chart in drawing.charts:
135
+ self._charts.append(chart)
136
+ chart._id = len(self._charts)
137
+ for img in drawing.images:
138
+ self._images.append(img)
139
+ img._id = len(self._images)
140
+ rels_path = get_rels_path(drawing.path)[1:]
141
+ self._archive.writestr(drawing.path[1:], tostring(drawing._write()))
142
+ self._archive.writestr(rels_path, tostring(drawing._write_rels()))
143
+ self.manifest.append(drawing)
144
+
145
+
146
+ def _write_chartsheets(self):
147
+ for idx, sheet in enumerate(self.workbook.chartsheets, 1):
148
+
149
+ sheet._id = idx
150
+ xml = tostring(sheet.to_tree())
151
+
152
+ self._archive.writestr(sheet.path[1:], xml)
153
+ self.manifest.append(sheet)
154
+
155
+ if sheet._drawing:
156
+ self._write_drawing(sheet._drawing)
157
+
158
+ rel = Relationship(type="drawing", Target=sheet._drawing.path)
159
+ rels = RelationshipList()
160
+ rels.append(rel)
161
+ tree = rels.to_tree()
162
+
163
+ rels_path = get_rels_path(sheet.path[1:])
164
+ self._archive.writestr(rels_path, tostring(tree))
165
+
166
+
167
+ def _write_comment(self, ws):
168
+
169
+ cs = CommentSheet.from_comments(ws._comments)
170
+ self._comments.append(cs)
171
+ cs._id = len(self._comments)
172
+ self._archive.writestr(cs.path[1:], tostring(cs.to_tree()))
173
+ self.manifest.append(cs)
174
+
175
+ if ws.legacy_drawing is None or self.workbook.vba_archive is None:
176
+ ws.legacy_drawing = 'xl/drawings/commentsDrawing{0}.vml'.format(cs._id)
177
+ vml = None
178
+ else:
179
+ vml = fromstring(self.workbook.vba_archive.read(ws.legacy_drawing))
180
+
181
+ vml = cs.write_shapes(vml)
182
+
183
+ self._archive.writestr(ws.legacy_drawing, vml)
184
+ self.vba_modified.add(ws.legacy_drawing)
185
+
186
+ comment_rel = Relationship(Id="comments", type=cs._rel_type, Target=cs.path)
187
+ ws._rels.append(comment_rel)
188
+
189
+
190
+ def write_worksheet(self, ws):
191
+ ws._drawing = SpreadsheetDrawing()
192
+ ws._drawing.charts = ws._charts
193
+ ws._drawing.images = ws._images
194
+ if self.workbook.write_only:
195
+ if not ws.closed:
196
+ ws.close()
197
+ writer = ws._writer
198
+ else:
199
+ writer = WorksheetWriter(ws)
200
+ writer.write()
201
+
202
+ ws._rels = writer._rels
203
+ self._archive.write(writer.out, ws.path[1:])
204
+ self.manifest.append(ws)
205
+ writer.cleanup()
206
+
207
+
208
+ def _write_worksheets(self):
209
+
210
+ pivot_caches = set()
211
+
212
+ for idx, ws in enumerate(self.workbook.worksheets, 1):
213
+
214
+ ws._id = idx
215
+ self.write_worksheet(ws)
216
+
217
+ if ws._drawing:
218
+ self._write_drawing(ws._drawing)
219
+
220
+ for r in ws._rels:
221
+ if "drawing" in r.Type:
222
+ r.Target = ws._drawing.path
223
+
224
+ if ws._comments:
225
+ self._write_comment(ws)
226
+
227
+ if ws.legacy_drawing is not None:
228
+ shape_rel = Relationship(type="vmlDrawing", Id="anysvml",
229
+ Target="/" + ws.legacy_drawing)
230
+ ws._rels.append(shape_rel)
231
+
232
+ for t in ws._tables.values():
233
+ self._tables.append(t)
234
+ t.id = len(self._tables)
235
+ t._write(self._archive)
236
+ self.manifest.append(t)
237
+ ws._rels.get(t._rel_id).Target = t.path
238
+
239
+ for p in ws._pivots:
240
+ if p.cache not in pivot_caches:
241
+ pivot_caches.add(p.cache)
242
+ p.cache._id = len(pivot_caches)
243
+
244
+ self._pivots.append(p)
245
+ p._id = len(self._pivots)
246
+ p._write(self._archive, self.manifest)
247
+ self.workbook._pivots.append(p)
248
+ r = Relationship(Type=p.rel_type, Target=p.path)
249
+ ws._rels.append(r)
250
+
251
+ if ws._rels:
252
+ tree = ws._rels.to_tree()
253
+ rels_path = get_rels_path(ws.path)[1:]
254
+ self._archive.writestr(rels_path, tostring(tree))
255
+
256
+
257
+ def _write_external_links(self):
258
+ # delegate to object
259
+ """Write links to external workbooks"""
260
+ wb = self.workbook
261
+ for idx, link in enumerate(wb._external_links, 1):
262
+ link._id = idx
263
+ rels_path = get_rels_path(link.path[1:])
264
+
265
+ xml = link.to_tree()
266
+ self._archive.writestr(link.path[1:], tostring(xml))
267
+ rels = RelationshipList()
268
+ rels.append(link.file_link)
269
+ self._archive.writestr(rels_path, tostring(rels.to_tree()))
270
+ self.manifest.append(link)
271
+
272
+
273
+ def save(self):
274
+ """Write data into the archive."""
275
+ self.write_data()
276
+ self._archive.close()
277
+
278
+
279
+ def save_workbook(workbook, filename):
280
+ """Save the given workbook on the filesystem under the name filename.
281
+
282
+ :param workbook: the workbook to save
283
+ :type workbook: :class:`openpyxl.workbook.Workbook`
284
+
285
+ :param filename: the path to which save the workbook
286
+ :type filename: string
287
+
288
+ :rtype: bool
289
+
290
+ """
291
+ archive = ZipFile(filename, 'w', ZIP_DEFLATED, allowZip64=True)
292
+ workbook.properties.modified = datetime.datetime.now(tz=datetime.timezone.utc).replace(tzinfo=None)
293
+ writer = ExcelWriter(workbook, archive)
294
+ writer.save()
295
+ return True
@@ -0,0 +1,291 @@
1
+ # Copyright (c) 2010-2024 openpyxl
2
+
3
+ """Write the theme xml based on a fixed string."""
4
+
5
+
6
+ theme_xml = """<?xml version="1.0"?>
7
+ <a:theme xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" name="Office Theme">
8
+ <a:themeElements>
9
+ <a:clrScheme name="Office">
10
+ <a:dk1>
11
+ <a:sysClr val="windowText" lastClr="000000"/>
12
+ </a:dk1>
13
+ <a:lt1>
14
+ <a:sysClr val="window" lastClr="FFFFFF"/>
15
+ </a:lt1>
16
+ <a:dk2>
17
+ <a:srgbClr val="1F497D"/>
18
+ </a:dk2>
19
+ <a:lt2>
20
+ <a:srgbClr val="EEECE1"/>
21
+ </a:lt2>
22
+ <a:accent1>
23
+ <a:srgbClr val="4F81BD"/>
24
+ </a:accent1>
25
+ <a:accent2>
26
+ <a:srgbClr val="C0504D"/>
27
+ </a:accent2>
28
+ <a:accent3>
29
+ <a:srgbClr val="9BBB59"/>
30
+ </a:accent3>
31
+ <a:accent4>
32
+ <a:srgbClr val="8064A2"/>
33
+ </a:accent4>
34
+ <a:accent5>
35
+ <a:srgbClr val="4BACC6"/>
36
+ </a:accent5>
37
+ <a:accent6>
38
+ <a:srgbClr val="F79646"/>
39
+ </a:accent6>
40
+ <a:hlink>
41
+ <a:srgbClr val="0000FF"/>
42
+ </a:hlink>
43
+ <a:folHlink>
44
+ <a:srgbClr val="800080"/>
45
+ </a:folHlink>
46
+ </a:clrScheme>
47
+ <a:fontScheme name="Office">
48
+ <a:majorFont>
49
+ <a:latin typeface="Cambria"/>
50
+ <a:ea typeface=""/>
51
+ <a:cs typeface=""/>
52
+ <a:font script="Jpan" typeface="&#xFF2D;&#xFF33; &#xFF30;&#x30B4;&#x30B7;&#x30C3;&#x30AF;"/>
53
+ <a:font script="Hang" typeface="&#xB9D1;&#xC740; &#xACE0;&#xB515;"/>
54
+ <a:font script="Hans" typeface="&#x5B8B;&#x4F53;"/>
55
+ <a:font script="Hant" typeface="&#x65B0;&#x7D30;&#x660E;&#x9AD4;"/>
56
+ <a:font script="Arab" typeface="Times New Roman"/>
57
+ <a:font script="Hebr" typeface="Times New Roman"/>
58
+ <a:font script="Thai" typeface="Tahoma"/>
59
+ <a:font script="Ethi" typeface="Nyala"/>
60
+ <a:font script="Beng" typeface="Vrinda"/>
61
+ <a:font script="Gujr" typeface="Shruti"/>
62
+ <a:font script="Khmr" typeface="MoolBoran"/>
63
+ <a:font script="Knda" typeface="Tunga"/>
64
+ <a:font script="Guru" typeface="Raavi"/>
65
+ <a:font script="Cans" typeface="Euphemia"/>
66
+ <a:font script="Cher" typeface="Plantagenet Cherokee"/>
67
+ <a:font script="Yiii" typeface="Microsoft Yi Baiti"/>
68
+ <a:font script="Tibt" typeface="Microsoft Himalaya"/>
69
+ <a:font script="Thaa" typeface="MV Boli"/>
70
+ <a:font script="Deva" typeface="Mangal"/>
71
+ <a:font script="Telu" typeface="Gautami"/>
72
+ <a:font script="Taml" typeface="Latha"/>
73
+ <a:font script="Syrc" typeface="Estrangelo Edessa"/>
74
+ <a:font script="Orya" typeface="Kalinga"/>
75
+ <a:font script="Mlym" typeface="Kartika"/>
76
+ <a:font script="Laoo" typeface="DokChampa"/>
77
+ <a:font script="Sinh" typeface="Iskoola Pota"/>
78
+ <a:font script="Mong" typeface="Mongolian Baiti"/>
79
+ <a:font script="Viet" typeface="Times New Roman"/>
80
+ <a:font script="Uigh" typeface="Microsoft Uighur"/>
81
+ </a:majorFont>
82
+ <a:minorFont>
83
+ <a:latin typeface="Calibri"/>
84
+ <a:ea typeface=""/>
85
+ <a:cs typeface=""/>
86
+ <a:font script="Jpan" typeface="&#xFF2D;&#xFF33; &#xFF30;&#x30B4;&#x30B7;&#x30C3;&#x30AF;"/>
87
+ <a:font script="Hang" typeface="&#xB9D1;&#xC740; &#xACE0;&#xB515;"/>
88
+ <a:font script="Hans" typeface="&#x5B8B;&#x4F53;"/>
89
+ <a:font script="Hant" typeface="&#x65B0;&#x7D30;&#x660E;&#x9AD4;"/>
90
+ <a:font script="Arab" typeface="Arial"/>
91
+ <a:font script="Hebr" typeface="Arial"/>
92
+ <a:font script="Thai" typeface="Tahoma"/>
93
+ <a:font script="Ethi" typeface="Nyala"/>
94
+ <a:font script="Beng" typeface="Vrinda"/>
95
+ <a:font script="Gujr" typeface="Shruti"/>
96
+ <a:font script="Khmr" typeface="DaunPenh"/>
97
+ <a:font script="Knda" typeface="Tunga"/>
98
+ <a:font script="Guru" typeface="Raavi"/>
99
+ <a:font script="Cans" typeface="Euphemia"/>
100
+ <a:font script="Cher" typeface="Plantagenet Cherokee"/>
101
+ <a:font script="Yiii" typeface="Microsoft Yi Baiti"/>
102
+ <a:font script="Tibt" typeface="Microsoft Himalaya"/>
103
+ <a:font script="Thaa" typeface="MV Boli"/>
104
+ <a:font script="Deva" typeface="Mangal"/>
105
+ <a:font script="Telu" typeface="Gautami"/>
106
+ <a:font script="Taml" typeface="Latha"/>
107
+ <a:font script="Syrc" typeface="Estrangelo Edessa"/>
108
+ <a:font script="Orya" typeface="Kalinga"/>
109
+ <a:font script="Mlym" typeface="Kartika"/>
110
+ <a:font script="Laoo" typeface="DokChampa"/>
111
+ <a:font script="Sinh" typeface="Iskoola Pota"/>
112
+ <a:font script="Mong" typeface="Mongolian Baiti"/>
113
+ <a:font script="Viet" typeface="Arial"/>
114
+ <a:font script="Uigh" typeface="Microsoft Uighur"/>
115
+ </a:minorFont>
116
+ </a:fontScheme>
117
+ <a:fmtScheme name="Office">
118
+ <a:fillStyleLst>
119
+ <a:solidFill>
120
+ <a:schemeClr val="phClr"/>
121
+ </a:solidFill>
122
+ <a:gradFill rotWithShape="1">
123
+ <a:gsLst>
124
+ <a:gs pos="0">
125
+ <a:schemeClr val="phClr">
126
+ <a:tint val="50000"/>
127
+ <a:satMod val="300000"/>
128
+ </a:schemeClr>
129
+ </a:gs>
130
+ <a:gs pos="35000">
131
+ <a:schemeClr val="phClr">
132
+ <a:tint val="37000"/>
133
+ <a:satMod val="300000"/>
134
+ </a:schemeClr>
135
+ </a:gs>
136
+ <a:gs pos="100000">
137
+ <a:schemeClr val="phClr">
138
+ <a:tint val="15000"/>
139
+ <a:satMod val="350000"/>
140
+ </a:schemeClr>
141
+ </a:gs>
142
+ </a:gsLst>
143
+ <a:lin ang="16200000" scaled="1"/>
144
+ </a:gradFill>
145
+ <a:gradFill rotWithShape="1">
146
+ <a:gsLst>
147
+ <a:gs pos="0">
148
+ <a:schemeClr val="phClr">
149
+ <a:shade val="51000"/>
150
+ <a:satMod val="130000"/>
151
+ </a:schemeClr>
152
+ </a:gs>
153
+ <a:gs pos="80000">
154
+ <a:schemeClr val="phClr">
155
+ <a:shade val="93000"/>
156
+ <a:satMod val="130000"/>
157
+ </a:schemeClr>
158
+ </a:gs>
159
+ <a:gs pos="100000">
160
+ <a:schemeClr val="phClr">
161
+ <a:shade val="94000"/>
162
+ <a:satMod val="135000"/>
163
+ </a:schemeClr>
164
+ </a:gs>
165
+ </a:gsLst>
166
+ <a:lin ang="16200000" scaled="0"/>
167
+ </a:gradFill>
168
+ </a:fillStyleLst>
169
+ <a:lnStyleLst>
170
+ <a:ln w="9525" cap="flat" cmpd="sng" algn="ctr">
171
+ <a:solidFill>
172
+ <a:schemeClr val="phClr">
173
+ <a:shade val="95000"/>
174
+ <a:satMod val="105000"/>
175
+ </a:schemeClr>
176
+ </a:solidFill>
177
+ <a:prstDash val="solid"/>
178
+ </a:ln>
179
+ <a:ln w="25400" cap="flat" cmpd="sng" algn="ctr">
180
+ <a:solidFill>
181
+ <a:schemeClr val="phClr"/>
182
+ </a:solidFill>
183
+ <a:prstDash val="solid"/>
184
+ </a:ln>
185
+ <a:ln w="38100" cap="flat" cmpd="sng" algn="ctr">
186
+ <a:solidFill>
187
+ <a:schemeClr val="phClr"/>
188
+ </a:solidFill>
189
+ <a:prstDash val="solid"/>
190
+ </a:ln>
191
+ </a:lnStyleLst>
192
+ <a:effectStyleLst>
193
+ <a:effectStyle>
194
+ <a:effectLst>
195
+ <a:outerShdw blurRad="40000" dist="20000" dir="5400000" rotWithShape="0">
196
+ <a:srgbClr val="000000">
197
+ <a:alpha val="38000"/>
198
+ </a:srgbClr>
199
+ </a:outerShdw>
200
+ </a:effectLst>
201
+ </a:effectStyle>
202
+ <a:effectStyle>
203
+ <a:effectLst>
204
+ <a:outerShdw blurRad="40000" dist="23000" dir="5400000" rotWithShape="0">
205
+ <a:srgbClr val="000000">
206
+ <a:alpha val="35000"/>
207
+ </a:srgbClr>
208
+ </a:outerShdw>
209
+ </a:effectLst>
210
+ </a:effectStyle>
211
+ <a:effectStyle>
212
+ <a:effectLst>
213
+ <a:outerShdw blurRad="40000" dist="23000" dir="5400000" rotWithShape="0">
214
+ <a:srgbClr val="000000">
215
+ <a:alpha val="35000"/>
216
+ </a:srgbClr>
217
+ </a:outerShdw>
218
+ </a:effectLst>
219
+ <a:scene3d>
220
+ <a:camera prst="orthographicFront">
221
+ <a:rot lat="0" lon="0" rev="0"/>
222
+ </a:camera>
223
+ <a:lightRig rig="threePt" dir="t">
224
+ <a:rot lat="0" lon="0" rev="1200000"/>
225
+ </a:lightRig>
226
+ </a:scene3d>
227
+ <a:sp3d>
228
+ <a:bevelT w="63500" h="25400"/>
229
+ </a:sp3d>
230
+ </a:effectStyle>
231
+ </a:effectStyleLst>
232
+ <a:bgFillStyleLst>
233
+ <a:solidFill>
234
+ <a:schemeClr val="phClr"/>
235
+ </a:solidFill>
236
+ <a:gradFill rotWithShape="1">
237
+ <a:gsLst>
238
+ <a:gs pos="0">
239
+ <a:schemeClr val="phClr">
240
+ <a:tint val="40000"/>
241
+ <a:satMod val="350000"/>
242
+ </a:schemeClr>
243
+ </a:gs>
244
+ <a:gs pos="40000">
245
+ <a:schemeClr val="phClr">
246
+ <a:tint val="45000"/>
247
+ <a:shade val="99000"/>
248
+ <a:satMod val="350000"/>
249
+ </a:schemeClr>
250
+ </a:gs>
251
+ <a:gs pos="100000">
252
+ <a:schemeClr val="phClr">
253
+ <a:shade val="20000"/>
254
+ <a:satMod val="255000"/>
255
+ </a:schemeClr>
256
+ </a:gs>
257
+ </a:gsLst>
258
+ <a:path path="circle">
259
+ <a:fillToRect l="50000" t="-80000" r="50000" b="180000"/>
260
+ </a:path>
261
+ </a:gradFill>
262
+ <a:gradFill rotWithShape="1">
263
+ <a:gsLst>
264
+ <a:gs pos="0">
265
+ <a:schemeClr val="phClr">
266
+ <a:tint val="80000"/>
267
+ <a:satMod val="300000"/>
268
+ </a:schemeClr>
269
+ </a:gs>
270
+ <a:gs pos="100000">
271
+ <a:schemeClr val="phClr">
272
+ <a:shade val="30000"/>
273
+ <a:satMod val="200000"/>
274
+ </a:schemeClr>
275
+ </a:gs>
276
+ </a:gsLst>
277
+ <a:path path="circle">
278
+ <a:fillToRect l="50000" t="50000" r="50000" b="50000"/>
279
+ </a:path>
280
+ </a:gradFill>
281
+ </a:bgFillStyleLst>
282
+ </a:fmtScheme>
283
+ </a:themeElements>
284
+ <a:objectDefaults/>
285
+ <a:extraClrSchemeLst/>
286
+ </a:theme>
287
+ """
288
+
289
+ def write_theme():
290
+ """Write the theme xml."""
291
+ return theme_xml
@@ -0,0 +1,42 @@
1
+ # Copyright (c) 2010-2024 openpyxl
2
+
3
+
4
+ """Collection of XML resources compatible across different Python versions"""
5
+ import os
6
+
7
+
8
+ def lxml_available():
9
+ try:
10
+ from lxml.etree import LXML_VERSION
11
+ LXML = LXML_VERSION >= (3, 3, 1, 0)
12
+ if not LXML:
13
+ import warnings
14
+ warnings.warn("The installed version of lxml is too old to be used with openpyxl")
15
+ return False # we have it, but too old
16
+ else:
17
+ return True # we have it, and recent enough
18
+ except ImportError:
19
+ return False # we don't even have it
20
+
21
+
22
+ def lxml_env_set():
23
+ return os.environ.get("OPENPYXL_LXML", "True") == "True"
24
+
25
+
26
+ LXML = lxml_available() and lxml_env_set()
27
+
28
+
29
+ def defusedxml_available():
30
+ try:
31
+ import defusedxml # noqa
32
+ except ImportError:
33
+ return False
34
+ else:
35
+ return True
36
+
37
+
38
+ def defusedxml_env_set():
39
+ return os.environ.get("OPENPYXL_DEFUSEDXML", "True") == "True"
40
+
41
+
42
+ DEFUSEDXML = defusedxml_available() and defusedxml_env_set()