@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,158 @@
1
+ from __future__ import absolute_import
2
+ # Copyright (c) 2010-2015 openpyxl
3
+
4
+ """Implements the lxml.etree.xmlfile API using the standard library xml.etree"""
5
+
6
+
7
+ from contextlib import contextmanager
8
+
9
+ from xml.etree.ElementTree import (
10
+ Element,
11
+ _escape_cdata,
12
+ )
13
+
14
+ from . import incremental_tree
15
+
16
+
17
+ class LxmlSyntaxError(Exception):
18
+ pass
19
+
20
+
21
+ class _IncrementalFileWriter(object):
22
+ """Replacement for _IncrementalFileWriter of lxml"""
23
+ def __init__(self, output_file):
24
+ self._element_stack = []
25
+ self._file = output_file
26
+ self._have_root = False
27
+ self.global_nsmap = incremental_tree.current_global_nsmap()
28
+ self.is_html = False
29
+
30
+ @contextmanager
31
+ def element(self, tag, attrib=None, nsmap=None, **_extra):
32
+ """Create a new xml element using a context manager."""
33
+ if nsmap and None in nsmap:
34
+ # Normalise None prefix (lxml's default namespace prefix) -> "", as
35
+ # required for incremental_tree
36
+ if "" in nsmap and nsmap[""] != nsmap[None]:
37
+ raise ValueError(
38
+ 'Found None and "" as default nsmap prefixes with different URIs'
39
+ )
40
+ nsmap = nsmap.copy()
41
+ nsmap[""] = nsmap.pop(None)
42
+
43
+ # __enter__ part
44
+ self._have_root = True
45
+ if attrib is None:
46
+ attrib = {}
47
+ elem = Element(tag, attrib=attrib, **_extra)
48
+ elem.text = ''
49
+ elem.tail = ''
50
+ if self._element_stack:
51
+ is_root = False
52
+ (
53
+ nsmap_scope,
54
+ default_ns_attr_prefix,
55
+ uri_to_prefix,
56
+ ) = self._element_stack[-1]
57
+ else:
58
+ is_root = True
59
+ nsmap_scope = {}
60
+ default_ns_attr_prefix = None
61
+ uri_to_prefix = {}
62
+ (
63
+ tag,
64
+ nsmap_scope,
65
+ default_ns_attr_prefix,
66
+ uri_to_prefix,
67
+ next_remains_root,
68
+ ) = incremental_tree.write_elem_start(
69
+ self._file,
70
+ elem,
71
+ nsmap_scope=nsmap_scope,
72
+ global_nsmap=self.global_nsmap,
73
+ short_empty_elements=False,
74
+ is_html=self.is_html,
75
+ is_root=is_root,
76
+ uri_to_prefix=uri_to_prefix,
77
+ default_ns_attr_prefix=default_ns_attr_prefix,
78
+ new_nsmap=nsmap,
79
+ )
80
+ self._element_stack.append(
81
+ (
82
+ nsmap_scope,
83
+ default_ns_attr_prefix,
84
+ uri_to_prefix,
85
+ )
86
+ )
87
+ yield
88
+
89
+ # __exit__ part
90
+ self._element_stack.pop()
91
+ self._file(f"</{tag}>")
92
+ if elem.tail:
93
+ self._file(_escape_cdata(elem.tail))
94
+
95
+ def write(self, arg):
96
+ """Write a string or subelement."""
97
+
98
+ if isinstance(arg, str):
99
+ # it is not allowed to write a string outside of an element
100
+ if not self._element_stack:
101
+ raise LxmlSyntaxError()
102
+ self._file(_escape_cdata(arg))
103
+
104
+ else:
105
+ if not self._element_stack and self._have_root:
106
+ raise LxmlSyntaxError()
107
+
108
+ if self._element_stack:
109
+ is_root = False
110
+ (
111
+ nsmap_scope,
112
+ default_ns_attr_prefix,
113
+ uri_to_prefix,
114
+ ) = self._element_stack[-1]
115
+ else:
116
+ is_root = True
117
+ nsmap_scope = {}
118
+ default_ns_attr_prefix = None
119
+ uri_to_prefix = {}
120
+ incremental_tree._serialize_ns_xml(
121
+ self._file,
122
+ arg,
123
+ nsmap_scope=nsmap_scope,
124
+ global_nsmap=self.global_nsmap,
125
+ short_empty_elements=True,
126
+ is_html=self.is_html,
127
+ is_root=is_root,
128
+ uri_to_prefix=uri_to_prefix,
129
+ default_ns_attr_prefix=default_ns_attr_prefix,
130
+ )
131
+
132
+ def __enter__(self):
133
+ pass
134
+
135
+ def __exit__(self, type, value, traceback):
136
+ # without root the xml document is incomplete
137
+ if not self._have_root:
138
+ raise LxmlSyntaxError()
139
+
140
+
141
+ class xmlfile(object):
142
+ """Context manager that can replace lxml.etree.xmlfile."""
143
+ def __init__(self, output_file, buffered=False, encoding="utf-8", close=False):
144
+ self._file = output_file
145
+ self._close = close
146
+ self.encoding = encoding
147
+ self.writer_cm = None
148
+
149
+ def __enter__(self):
150
+ self.writer_cm = incremental_tree._get_writer(self._file, encoding=self.encoding)
151
+ writer, declared_encoding = self.writer_cm.__enter__()
152
+ return _IncrementalFileWriter(writer)
153
+
154
+ def __exit__(self, type, value, traceback):
155
+ if self.writer_cm:
156
+ self.writer_cm.__exit__(type, value, traceback)
157
+ if self._close:
158
+ self._file.close()
@@ -0,0 +1,23 @@
1
+ This software is under the MIT Licence
2
+ ======================================
3
+
4
+ Copyright (c) 2010 openpyxl
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a
7
+ copy of this software and associated documentation files (the
8
+ "Software"), to deal in the Software without restriction, including
9
+ without limitation the rights to use, copy, modify, merge, publish,
10
+ distribute, sublicense, and/or sell copies of the Software, and to
11
+ permit persons to whom the Software is furnished to do so, subject to
12
+ the following conditions:
13
+
14
+ The above copyright notice and this permission notice shall be included
15
+ in all copies or substantial portions of the Software.
16
+
17
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,19 @@
1
+ # Copyright (c) 2010-2024 openpyxl
2
+
3
+ DEBUG = False
4
+
5
+ from openpyxl.compat.numbers import NUMPY
6
+ from openpyxl.xml import DEFUSEDXML, LXML
7
+ from openpyxl.workbook import Workbook
8
+ from openpyxl.reader.excel import load_workbook as open
9
+ from openpyxl.reader.excel import load_workbook
10
+ import openpyxl._constants as constants
11
+
12
+ # Expose constants especially the version number
13
+
14
+ __author__ = constants.__author__
15
+ __author_email__ = constants.__author_email__
16
+ __license__ = constants.__license__
17
+ __maintainer_email__ = constants.__maintainer_email__
18
+ __url__ = constants.__url__
19
+ __version__ = constants.__version__
@@ -0,0 +1,13 @@
1
+ # Copyright (c) 2010-2024 openpyxl
2
+
3
+ """
4
+ Package metadata
5
+ """
6
+
7
+ __author__ = "See AUTHORS"
8
+ __author_email__ = "charlie.clark@clark-consulting.eu"
9
+ __license__ = "MIT"
10
+ __maintainer_email__ = "openpyxl-users@googlegroups.com"
11
+ __url__ = "https://openpyxl.readthedocs.io"
12
+ __version__ = "3.1.5"
13
+ __python__ = "3.8"
@@ -0,0 +1,4 @@
1
+ # Copyright (c) 2010-2024 openpyxl
2
+
3
+ from .cell import Cell, WriteOnlyCell, MergedCell
4
+ from .read_only import ReadOnlyCell
@@ -0,0 +1,136 @@
1
+ # Copyright (c) 2010-2024 openpyxl
2
+
3
+ from openpyxl.compat import safe_string
4
+ from openpyxl.xml.functions import Element, SubElement, whitespace, XML_NS
5
+ from openpyxl import LXML
6
+ from openpyxl.utils.datetime import to_excel, to_ISO8601
7
+ from datetime import timedelta
8
+
9
+ from openpyxl.worksheet.formula import DataTableFormula, ArrayFormula
10
+ from openpyxl.cell.rich_text import CellRichText
11
+
12
+ def _set_attributes(cell, styled=None):
13
+ """
14
+ Set coordinate and datatype
15
+ """
16
+ coordinate = cell.coordinate
17
+ attrs = {'r': coordinate}
18
+ if styled:
19
+ attrs['s'] = f"{cell.style_id}"
20
+
21
+ if cell.data_type == "s":
22
+ attrs['t'] = "inlineStr"
23
+ elif cell.data_type != 'f':
24
+ attrs['t'] = cell.data_type
25
+
26
+ value = cell._value
27
+
28
+ if cell.data_type == "d":
29
+ if hasattr(value, "tzinfo") and value.tzinfo is not None:
30
+ raise TypeError("Excel does not support timezones in datetimes. "
31
+ "The tzinfo in the datetime/time object must be set to None.")
32
+
33
+ if cell.parent.parent.iso_dates and not isinstance(value, timedelta):
34
+ value = to_ISO8601(value)
35
+ else:
36
+ attrs['t'] = "n"
37
+ value = to_excel(value, cell.parent.parent.epoch)
38
+
39
+ if cell.hyperlink:
40
+ cell.parent._hyperlinks.append(cell.hyperlink)
41
+
42
+ return value, attrs
43
+
44
+
45
+ def etree_write_cell(xf, worksheet, cell, styled=None):
46
+
47
+ value, attributes = _set_attributes(cell, styled)
48
+
49
+ el = Element("c", attributes)
50
+ if value is None or value == "":
51
+ xf.write(el)
52
+ return
53
+
54
+ if cell.data_type == 'f':
55
+ attrib = {}
56
+
57
+ if isinstance(value, ArrayFormula):
58
+ attrib = dict(value)
59
+ value = value.text
60
+
61
+ elif isinstance(value, DataTableFormula):
62
+ attrib = dict(value)
63
+ value = None
64
+
65
+ formula = SubElement(el, 'f', attrib)
66
+ if value is not None and not attrib.get('t') == "dataTable":
67
+ formula.text = value[1:]
68
+ value = None
69
+
70
+ if cell.data_type == 's':
71
+ if isinstance(value, CellRichText):
72
+ el.append(value.to_tree())
73
+ else:
74
+ inline_string = Element("is")
75
+ text = Element('t')
76
+ text.text = value
77
+ whitespace(text)
78
+ inline_string.append(text)
79
+ el.append(inline_string)
80
+
81
+ else:
82
+ cell_content = SubElement(el, 'v')
83
+ if value is not None:
84
+ cell_content.text = safe_string(value)
85
+
86
+ xf.write(el)
87
+
88
+
89
+ def lxml_write_cell(xf, worksheet, cell, styled=False):
90
+ value, attributes = _set_attributes(cell, styled)
91
+
92
+ if value == '' or value is None:
93
+ with xf.element("c", attributes):
94
+ return
95
+
96
+ with xf.element('c', attributes):
97
+ if cell.data_type == 'f':
98
+ attrib = {}
99
+
100
+ if isinstance(value, ArrayFormula):
101
+ attrib = dict(value)
102
+ value = value.text
103
+
104
+ elif isinstance(value, DataTableFormula):
105
+ attrib = dict(value)
106
+ value = None
107
+
108
+ with xf.element('f', attrib):
109
+ if value is not None and not attrib.get('t') == "dataTable":
110
+ xf.write(value[1:])
111
+ value = None
112
+
113
+ if cell.data_type == 's':
114
+ if isinstance(value, CellRichText):
115
+ el = value.to_tree()
116
+ xf.write(el)
117
+ else:
118
+ with xf.element("is"):
119
+ if isinstance(value, str):
120
+ attrs = {}
121
+ if value != value.strip():
122
+ attrs["{%s}space" % XML_NS] = "preserve"
123
+ el = Element("t", attrs) # lxml can't handle xml-ns
124
+ el.text = value
125
+ xf.write(el)
126
+
127
+ else:
128
+ with xf.element("v"):
129
+ if value is not None:
130
+ xf.write(safe_string(value))
131
+
132
+
133
+ if LXML:
134
+ write_cell = lxml_write_cell
135
+ else:
136
+ write_cell = etree_write_cell
@@ -0,0 +1,332 @@
1
+ # Copyright (c) 2010-2024 openpyxl
2
+
3
+ """Manage individual cells in a spreadsheet.
4
+
5
+ The Cell class is required to know its value and type, display options,
6
+ and any other features of an Excel cell. Utilities for referencing
7
+ cells using Excel's 'A1' column/row nomenclature are also provided.
8
+
9
+ """
10
+
11
+ __docformat__ = "restructuredtext en"
12
+
13
+ # Python stdlib imports
14
+ from copy import copy
15
+ import datetime
16
+ import re
17
+
18
+
19
+ from openpyxl.compat import (
20
+ NUMERIC_TYPES,
21
+ )
22
+
23
+ from openpyxl.utils.exceptions import IllegalCharacterError
24
+
25
+ from openpyxl.utils import get_column_letter
26
+ from openpyxl.styles import numbers, is_date_format
27
+ from openpyxl.styles.styleable import StyleableObject
28
+ from openpyxl.worksheet.hyperlink import Hyperlink
29
+ from openpyxl.worksheet.formula import DataTableFormula, ArrayFormula
30
+ from openpyxl.cell.rich_text import CellRichText
31
+
32
+ # constants
33
+
34
+ TIME_TYPES = (datetime.datetime, datetime.date, datetime.time, datetime.timedelta)
35
+ TIME_FORMATS = {
36
+ datetime.datetime:numbers.FORMAT_DATE_DATETIME,
37
+ datetime.date:numbers.FORMAT_DATE_YYYYMMDD2,
38
+ datetime.time:numbers.FORMAT_DATE_TIME6,
39
+ datetime.timedelta:numbers.FORMAT_DATE_TIMEDELTA,
40
+ }
41
+
42
+ STRING_TYPES = (str, bytes, CellRichText)
43
+ KNOWN_TYPES = NUMERIC_TYPES + TIME_TYPES + STRING_TYPES + (bool, type(None))
44
+
45
+ ILLEGAL_CHARACTERS_RE = re.compile(r'[\000-\010]|[\013-\014]|[\016-\037]')
46
+ ERROR_CODES = ('#NULL!', '#DIV/0!', '#VALUE!', '#REF!', '#NAME?', '#NUM!',
47
+ '#N/A')
48
+
49
+ TYPE_STRING = 's'
50
+ TYPE_FORMULA = 'f'
51
+ TYPE_NUMERIC = 'n'
52
+ TYPE_BOOL = 'b'
53
+ TYPE_NULL = 'n'
54
+ TYPE_INLINE = 'inlineStr'
55
+ TYPE_ERROR = 'e'
56
+ TYPE_FORMULA_CACHE_STRING = 'str'
57
+
58
+ VALID_TYPES = (TYPE_STRING, TYPE_FORMULA, TYPE_NUMERIC, TYPE_BOOL,
59
+ TYPE_NULL, TYPE_INLINE, TYPE_ERROR, TYPE_FORMULA_CACHE_STRING)
60
+
61
+
62
+ _TYPES = {int:'n', float:'n', str:'s', bool:'b'}
63
+
64
+
65
+ def get_type(t, value):
66
+ if isinstance(value, NUMERIC_TYPES):
67
+ dt = 'n'
68
+ elif isinstance(value, STRING_TYPES):
69
+ dt = 's'
70
+ elif isinstance(value, TIME_TYPES):
71
+ dt = 'd'
72
+ elif isinstance(value, (DataTableFormula, ArrayFormula)):
73
+ dt = 'f'
74
+ else:
75
+ return
76
+ _TYPES[t] = dt
77
+ return dt
78
+
79
+
80
+ def get_time_format(t):
81
+ value = TIME_FORMATS.get(t)
82
+ if value:
83
+ return value
84
+ for base in t.mro()[1:]:
85
+ value = TIME_FORMATS.get(base)
86
+ if value:
87
+ TIME_FORMATS[t] = value
88
+ return value
89
+ raise ValueError("Could not get time format for {0!r}".format(value))
90
+
91
+
92
+ class Cell(StyleableObject):
93
+ """Describes cell associated properties.
94
+
95
+ Properties of interest include style, type, value, and address.
96
+
97
+ """
98
+ __slots__ = (
99
+ 'row',
100
+ 'column',
101
+ '_value',
102
+ 'data_type',
103
+ 'parent',
104
+ '_hyperlink',
105
+ '_comment',
106
+ )
107
+
108
+ def __init__(self, worksheet, row=None, column=None, value=None, style_array=None):
109
+ super().__init__(worksheet, style_array)
110
+ self.row = row
111
+ """Row number of this cell (1-based)"""
112
+ self.column = column
113
+ """Column number of this cell (1-based)"""
114
+ # _value is the stored value, while value is the displayed value
115
+ self._value = None
116
+ self._hyperlink = None
117
+ self.data_type = 'n'
118
+ if value is not None:
119
+ self.value = value
120
+ self._comment = None
121
+
122
+
123
+ @property
124
+ def coordinate(self):
125
+ """This cell's coordinate (ex. 'A5')"""
126
+ col = get_column_letter(self.column)
127
+ return f"{col}{self.row}"
128
+
129
+
130
+ @property
131
+ def col_idx(self):
132
+ """The numerical index of the column"""
133
+ return self.column
134
+
135
+
136
+ @property
137
+ def column_letter(self):
138
+ return get_column_letter(self.column)
139
+
140
+
141
+ @property
142
+ def encoding(self):
143
+ return self.parent.encoding
144
+
145
+ @property
146
+ def base_date(self):
147
+ return self.parent.parent.epoch
148
+
149
+
150
+ def __repr__(self):
151
+ return "<Cell {0!r}.{1}>".format(self.parent.title, self.coordinate)
152
+
153
+ def check_string(self, value):
154
+ """Check string coding, length, and line break character"""
155
+ if value is None:
156
+ return
157
+ # convert to str string
158
+ if not isinstance(value, str):
159
+ value = str(value, self.encoding)
160
+ value = str(value)
161
+ # string must never be longer than 32,767 characters
162
+ # truncate if necessary
163
+ value = value[:32767]
164
+ if next(ILLEGAL_CHARACTERS_RE.finditer(value), None):
165
+ raise IllegalCharacterError(f"{value} cannot be used in worksheets.")
166
+ return value
167
+
168
+ def check_error(self, value):
169
+ """Tries to convert Error" else N/A"""
170
+ try:
171
+ return str(value)
172
+ except UnicodeDecodeError:
173
+ return u'#N/A'
174
+
175
+
176
+ def _bind_value(self, value):
177
+ """Given a value, infer the correct data type"""
178
+
179
+ self.data_type = "n"
180
+ t = type(value)
181
+ try:
182
+ dt = _TYPES[t]
183
+ except KeyError:
184
+ dt = get_type(t, value)
185
+
186
+ if dt is None and value is not None:
187
+ raise ValueError("Cannot convert {0!r} to Excel".format(value))
188
+
189
+ if dt:
190
+ self.data_type = dt
191
+
192
+ if dt == 'd':
193
+ if not is_date_format(self.number_format):
194
+ self.number_format = get_time_format(t)
195
+
196
+ elif dt == "s" and not isinstance(value, CellRichText):
197
+ value = self.check_string(value)
198
+ if len(value) > 1 and value.startswith("="):
199
+ self.data_type = 'f'
200
+ elif value in ERROR_CODES:
201
+ self.data_type = 'e'
202
+
203
+ self._value = value
204
+
205
+
206
+ @property
207
+ def value(self):
208
+ """Get or set the value held in the cell.
209
+
210
+ :type: depends on the value (string, float, int or
211
+ :class:`datetime.datetime`)
212
+ """
213
+ return self._value
214
+
215
+ @value.setter
216
+ def value(self, value):
217
+ """Set the value and infer type and display options."""
218
+ self._bind_value(value)
219
+
220
+ @property
221
+ def internal_value(self):
222
+ """Always returns the value for excel."""
223
+ return self._value
224
+
225
+ @property
226
+ def hyperlink(self):
227
+ """Return the hyperlink target or an empty string"""
228
+ return self._hyperlink
229
+
230
+
231
+ @hyperlink.setter
232
+ def hyperlink(self, val):
233
+ """Set value and display for hyperlinks in a cell.
234
+ Automatically sets the `value` of the cell with link text,
235
+ but you can modify it afterwards by setting the `value`
236
+ property, and the hyperlink will remain.
237
+ Hyperlink is removed if set to ``None``."""
238
+ if val is None:
239
+ self._hyperlink = None
240
+ else:
241
+ if not isinstance(val, Hyperlink):
242
+ val = Hyperlink(ref="", target=val)
243
+ val.ref = self.coordinate
244
+ self._hyperlink = val
245
+ if self._value is None:
246
+ self.value = val.target or val.location
247
+
248
+
249
+ @property
250
+ def is_date(self):
251
+ """True if the value is formatted as a date
252
+
253
+ :type: bool
254
+ """
255
+ return self.data_type == 'd' or (
256
+ self.data_type == 'n' and is_date_format(self.number_format)
257
+ )
258
+
259
+
260
+ def offset(self, row=0, column=0):
261
+ """Returns a cell location relative to this cell.
262
+
263
+ :param row: number of rows to offset
264
+ :type row: int
265
+
266
+ :param column: number of columns to offset
267
+ :type column: int
268
+
269
+ :rtype: :class:`openpyxl.cell.Cell`
270
+ """
271
+ offset_column = self.col_idx + column
272
+ offset_row = self.row + row
273
+ return self.parent.cell(column=offset_column, row=offset_row)
274
+
275
+
276
+ @property
277
+ def comment(self):
278
+ """ Returns the comment associated with this cell
279
+
280
+ :type: :class:`openpyxl.comments.Comment`
281
+ """
282
+ return self._comment
283
+
284
+
285
+ @comment.setter
286
+ def comment(self, value):
287
+ """
288
+ Assign a comment to a cell
289
+ """
290
+
291
+ if value is not None:
292
+ if value.parent:
293
+ value = copy(value)
294
+ value.bind(self)
295
+ elif value is None and self._comment:
296
+ self._comment.unbind()
297
+ self._comment = value
298
+
299
+
300
+ class MergedCell(StyleableObject):
301
+
302
+ """
303
+ Describes the properties of a cell in a merged cell and helps to
304
+ display the borders of the merged cell.
305
+
306
+ The value of a MergedCell is always None.
307
+ """
308
+
309
+ __slots__ = ('row', 'column')
310
+
311
+ _value = None
312
+ data_type = "n"
313
+ comment = None
314
+ hyperlink = None
315
+
316
+
317
+ def __init__(self, worksheet, row=None, column=None):
318
+ super().__init__(worksheet)
319
+ self.row = row
320
+ self.column = column
321
+
322
+
323
+ def __repr__(self):
324
+ return "<MergedCell {0!r}.{1}>".format(self.parent.title, self.coordinate)
325
+
326
+ coordinate = Cell.coordinate
327
+ _comment = comment
328
+ value = _value
329
+
330
+
331
+ def WriteOnlyCell(ws=None, value=None):
332
+ return Cell(worksheet=ws, column=1, row=1, value=value)