@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.
- package/CHANGELOG.md +58 -0
- package/README.md +3 -3
- package/THIRD_PARTY_NOTICES.md +16 -0
- package/automation/package.json +1 -1
- package/chart-ui/package.json +1 -1
- package/config/package.json +1 -1
- package/lib/collector-runtime.js +56 -1
- package/lib/data-collector/catalog-taxonomy.d.ts +1 -1
- package/lib/data-collector/catalog-taxonomy.js +33 -0
- package/lib/data-collector/dataset-tools.js +4 -2
- package/lib/data-collector/describe.d.ts +2 -0
- package/lib/data-collector/describe.js +2 -0
- package/lib/data-collector/store.d.ts +11 -0
- package/lib/data-collector/store.js +80 -1
- package/lib/data-collector/tools.d.ts +1 -1
- package/lib/data-collector/tools.js +10 -9
- package/lib/python-runtime/errors.d.ts +1 -1
- package/lib/python-runtime/errors.js +2 -0
- package/lib/python-runtime/manager.d.ts +28 -1
- package/lib/python-runtime/manager.js +141 -5
- package/lib/python-runtime/probe.d.ts +24 -0
- package/lib/python-runtime/probe.js +66 -50
- package/lib/sources/csindex-http.d.ts +4 -0
- package/lib/sources/csindex-http.js +233 -0
- package/lib/sources/eastmoney-http.js +1504 -1
- package/lib/sources/fuyao-rest.js +168 -8
- package/lib/sources/official-http.d.ts +4 -0
- package/lib/sources/official-http.js +477 -0
- package/lib/sources/python-remote.d.ts +25 -0
- package/lib/sources/python-remote.js +461 -0
- package/lib/sources/sina-http.d.ts +2 -0
- package/lib/sources/sina-http.js +484 -0
- package/lib/sources/tencent-http.js +23 -8
- package/lib/sources/ths-http.d.ts +2 -0
- package/lib/sources/ths-http.js +517 -0
- package/lib/time/tools.js +19 -0
- package/lib/web-retriever/local-fetch.d.ts +1 -1
- package/lib/web-retriever/local-fetch.js +1 -1
- package/lib/web-retriever/sources.d.ts +7 -0
- package/lib/web-retriever/sources.js +46 -21
- package/lib/web-retriever/throttle.d.ts +8 -0
- package/lib/web-retriever/throttle.js +13 -0
- package/lib/web-retriever/tools.js +1 -1
- package/lib/web-retriever/wind-client.d.ts +1 -1
- package/lib/web-retriever/wind-client.js +1 -1
- package/package.json +1 -1
- package/preset/capital-generation/agent.patch.yml +7 -5
- package/preset/capital-generation/skills/capital-data-protocol/SKILL.md +16 -16
- package/python/scripts/baostock_stock_basic.py +129 -0
- package/python/scripts/baostock_valuation_history.py +141 -0
- package/python/scripts/pbc_social_financing.py +291 -0
- package/python/vendor/baostock/LICENSE +19 -0
- package/python/vendor/baostock/__init__.py +42 -0
- package/python/vendor/baostock/common/__init__.py +0 -0
- package/python/vendor/baostock/common/contants.py +189 -0
- package/python/vendor/baostock/common/context.py +4 -0
- package/python/vendor/baostock/corpreport/__init__.py +0 -0
- package/python/vendor/baostock/corpreport/corp_performance.py +202 -0
- package/python/vendor/baostock/data/__init__.py +0 -0
- package/python/vendor/baostock/data/messageheader.py +17 -0
- package/python/vendor/baostock/data/msg.py +21 -0
- package/python/vendor/baostock/data/resultset.py +200 -0
- package/python/vendor/baostock/demo/__init__.py +0 -0
- package/python/vendor/baostock/demo/demo_A_stock_5mk-data.py +34 -0
- package/python/vendor/baostock/demo/demo_A_stock_k_data.py +36 -0
- package/python/vendor/baostock/demo/demo_AllStock.py +27 -0
- package/python/vendor/baostock/demo/demo_Balance_data.py +22 -0
- package/python/vendor/baostock/demo/demo_CashFlow_data.py +22 -0
- package/python/vendor/baostock/demo/demo_Dividend_data.py +35 -0
- package/python/vendor/baostock/demo/demo_Dupont_data.py +25 -0
- package/python/vendor/baostock/demo/demo_Forecast_report.py +24 -0
- package/python/vendor/baostock/demo/demo_Growth_data.py +22 -0
- package/python/vendor/baostock/demo/demo_Index_k_data.py +39 -0
- package/python/vendor/baostock/demo/demo_Operation_data.py +22 -0
- package/python/vendor/baostock/demo/demo_PerformanceExpress_report.py +25 -0
- package/python/vendor/baostock/demo/demo_Profit_data.py +22 -0
- package/python/vendor/baostock/demo/demo_TradeDates.py +27 -0
- package/python/vendor/baostock/demo/demo_adjust_factor_data.py +23 -0
- package/python/vendor/baostock/demo/demo_assignDayData.py +23 -0
- package/python/vendor/baostock/demo/demo_daily_adjust_factor_data.py +28 -0
- package/python/vendor/baostock/demo/demo_daily_k_4_AStock.py +28 -0
- package/python/vendor/baostock/demo/demo_daily_k_4_ETF.py +28 -0
- package/python/vendor/baostock/demo/demo_depositRate_data.py +26 -0
- package/python/vendor/baostock/demo/demo_hs300_stocks.py +26 -0
- package/python/vendor/baostock/demo/demo_loanRate_data.py +26 -0
- package/python/vendor/baostock/demo/demo_moneySupplyDataMonth_data.py +26 -0
- package/python/vendor/baostock/demo/demo_moneySupplyDataYear_data.py +26 -0
- package/python/vendor/baostock/demo/demo_requiredReserveRatio_data.py +26 -0
- package/python/vendor/baostock/demo/demo_set_API_key.py +37 -0
- package/python/vendor/baostock/demo/demo_stockBasic_data.py +27 -0
- package/python/vendor/baostock/demo/demo_stock_Valuation_indicator_data.py +34 -0
- package/python/vendor/baostock/demo/demo_stock_industry.py +26 -0
- package/python/vendor/baostock/demo/demo_sz50stocks.py +26 -0
- package/python/vendor/baostock/demo/demo_zz500_stock.py +26 -0
- package/python/vendor/baostock/evaluation/__init__.py +0 -0
- package/python/vendor/baostock/evaluation/season_index.py +758 -0
- package/python/vendor/baostock/login/__init__.py +0 -0
- package/python/vendor/baostock/login/loginout.py +230 -0
- package/python/vendor/baostock/macroscopic/__init__.py +0 -0
- package/python/vendor/baostock/macroscopic/economic_data.py +723 -0
- package/python/vendor/baostock/metadata/__init__.py +0 -0
- package/python/vendor/baostock/metadata/stock_metadata.py +207 -0
- package/python/vendor/baostock/security/__init__.py +0 -0
- package/python/vendor/baostock/security/history.py +265 -0
- package/python/vendor/baostock/security/sectorinfo.py +1024 -0
- package/python/vendor/baostock/util/__init__.py +0 -0
- package/python/vendor/baostock/util/socketutil.py +97 -0
- package/python/vendor/baostock/util/stringutil.py +83 -0
- package/python/vendor/et_xmlfile/LICENSE +23 -0
- package/python/vendor/et_xmlfile/LICENSE.python +298 -0
- package/python/vendor/et_xmlfile/__init__.py +8 -0
- package/python/vendor/et_xmlfile/incremental_tree.py +917 -0
- package/python/vendor/et_xmlfile/xmlfile.py +158 -0
- package/python/vendor/openpyxl/LICENSE +23 -0
- package/python/vendor/openpyxl/__init__.py +19 -0
- package/python/vendor/openpyxl/_constants.py +13 -0
- package/python/vendor/openpyxl/cell/__init__.py +4 -0
- package/python/vendor/openpyxl/cell/_writer.py +136 -0
- package/python/vendor/openpyxl/cell/cell.py +332 -0
- package/python/vendor/openpyxl/cell/read_only.py +136 -0
- package/python/vendor/openpyxl/cell/rich_text.py +202 -0
- package/python/vendor/openpyxl/cell/text.py +184 -0
- package/python/vendor/openpyxl/chart/_3d.py +105 -0
- package/python/vendor/openpyxl/chart/__init__.py +19 -0
- package/python/vendor/openpyxl/chart/_chart.py +199 -0
- package/python/vendor/openpyxl/chart/area_chart.py +106 -0
- package/python/vendor/openpyxl/chart/axis.py +401 -0
- package/python/vendor/openpyxl/chart/bar_chart.py +144 -0
- package/python/vendor/openpyxl/chart/bubble_chart.py +67 -0
- package/python/vendor/openpyxl/chart/chartspace.py +195 -0
- package/python/vendor/openpyxl/chart/data_source.py +246 -0
- package/python/vendor/openpyxl/chart/descriptors.py +43 -0
- package/python/vendor/openpyxl/chart/error_bar.py +62 -0
- package/python/vendor/openpyxl/chart/label.py +127 -0
- package/python/vendor/openpyxl/chart/layout.py +74 -0
- package/python/vendor/openpyxl/chart/legend.py +75 -0
- package/python/vendor/openpyxl/chart/line_chart.py +129 -0
- package/python/vendor/openpyxl/chart/marker.py +90 -0
- package/python/vendor/openpyxl/chart/picture.py +35 -0
- package/python/vendor/openpyxl/chart/pie_chart.py +177 -0
- package/python/vendor/openpyxl/chart/pivot.py +65 -0
- package/python/vendor/openpyxl/chart/plotarea.py +162 -0
- package/python/vendor/openpyxl/chart/print_settings.py +57 -0
- package/python/vendor/openpyxl/chart/radar_chart.py +55 -0
- package/python/vendor/openpyxl/chart/reader.py +32 -0
- package/python/vendor/openpyxl/chart/reference.py +124 -0
- package/python/vendor/openpyxl/chart/scatter_chart.py +53 -0
- package/python/vendor/openpyxl/chart/series.py +197 -0
- package/python/vendor/openpyxl/chart/series_factory.py +41 -0
- package/python/vendor/openpyxl/chart/shapes.py +89 -0
- package/python/vendor/openpyxl/chart/stock_chart.py +54 -0
- package/python/vendor/openpyxl/chart/surface_chart.py +119 -0
- package/python/vendor/openpyxl/chart/text.py +78 -0
- package/python/vendor/openpyxl/chart/title.py +76 -0
- package/python/vendor/openpyxl/chart/trendline.py +98 -0
- package/python/vendor/openpyxl/chart/updown_bars.py +31 -0
- package/python/vendor/openpyxl/chartsheet/__init__.py +3 -0
- package/python/vendor/openpyxl/chartsheet/chartsheet.py +107 -0
- package/python/vendor/openpyxl/chartsheet/custom.py +61 -0
- package/python/vendor/openpyxl/chartsheet/properties.py +28 -0
- package/python/vendor/openpyxl/chartsheet/protection.py +41 -0
- package/python/vendor/openpyxl/chartsheet/publish.py +58 -0
- package/python/vendor/openpyxl/chartsheet/relation.py +97 -0
- package/python/vendor/openpyxl/chartsheet/views.py +51 -0
- package/python/vendor/openpyxl/comments/__init__.py +4 -0
- package/python/vendor/openpyxl/comments/author.py +21 -0
- package/python/vendor/openpyxl/comments/comment_sheet.py +211 -0
- package/python/vendor/openpyxl/comments/comments.py +62 -0
- package/python/vendor/openpyxl/comments/shape_writer.py +112 -0
- package/python/vendor/openpyxl/compat/__init__.py +54 -0
- package/python/vendor/openpyxl/compat/abc.py +8 -0
- package/python/vendor/openpyxl/compat/numbers.py +43 -0
- package/python/vendor/openpyxl/compat/product.py +17 -0
- package/python/vendor/openpyxl/compat/singleton.py +40 -0
- package/python/vendor/openpyxl/compat/strings.py +25 -0
- package/python/vendor/openpyxl/descriptors/__init__.py +58 -0
- package/python/vendor/openpyxl/descriptors/base.py +272 -0
- package/python/vendor/openpyxl/descriptors/container.py +41 -0
- package/python/vendor/openpyxl/descriptors/excel.py +112 -0
- package/python/vendor/openpyxl/descriptors/namespace.py +12 -0
- package/python/vendor/openpyxl/descriptors/nested.py +129 -0
- package/python/vendor/openpyxl/descriptors/sequence.py +136 -0
- package/python/vendor/openpyxl/descriptors/serialisable.py +240 -0
- package/python/vendor/openpyxl/descriptors/slots.py +18 -0
- package/python/vendor/openpyxl/drawing/__init__.py +4 -0
- package/python/vendor/openpyxl/drawing/colors.py +435 -0
- package/python/vendor/openpyxl/drawing/connector.py +144 -0
- package/python/vendor/openpyxl/drawing/drawing.py +92 -0
- package/python/vendor/openpyxl/drawing/effect.py +407 -0
- package/python/vendor/openpyxl/drawing/fill.py +425 -0
- package/python/vendor/openpyxl/drawing/geometry.py +584 -0
- package/python/vendor/openpyxl/drawing/graphic.py +177 -0
- package/python/vendor/openpyxl/drawing/image.py +65 -0
- package/python/vendor/openpyxl/drawing/line.py +144 -0
- package/python/vendor/openpyxl/drawing/picture.py +144 -0
- package/python/vendor/openpyxl/drawing/properties.py +174 -0
- package/python/vendor/openpyxl/drawing/relation.py +17 -0
- package/python/vendor/openpyxl/drawing/spreadsheet_drawing.py +382 -0
- package/python/vendor/openpyxl/drawing/text.py +717 -0
- package/python/vendor/openpyxl/drawing/xdr.py +33 -0
- package/python/vendor/openpyxl/formatting/__init__.py +3 -0
- package/python/vendor/openpyxl/formatting/formatting.py +114 -0
- package/python/vendor/openpyxl/formatting/rule.py +291 -0
- package/python/vendor/openpyxl/formula/__init__.py +3 -0
- package/python/vendor/openpyxl/formula/tokenizer.py +446 -0
- package/python/vendor/openpyxl/formula/translate.py +166 -0
- package/python/vendor/openpyxl/packaging/__init__.py +3 -0
- package/python/vendor/openpyxl/packaging/core.py +115 -0
- package/python/vendor/openpyxl/packaging/custom.py +289 -0
- package/python/vendor/openpyxl/packaging/extended.py +137 -0
- package/python/vendor/openpyxl/packaging/interface.py +56 -0
- package/python/vendor/openpyxl/packaging/manifest.py +194 -0
- package/python/vendor/openpyxl/packaging/relationship.py +158 -0
- package/python/vendor/openpyxl/packaging/workbook.py +185 -0
- package/python/vendor/openpyxl/pivot/__init__.py +1 -0
- package/python/vendor/openpyxl/pivot/cache.py +965 -0
- package/python/vendor/openpyxl/pivot/fields.py +326 -0
- package/python/vendor/openpyxl/pivot/record.py +111 -0
- package/python/vendor/openpyxl/pivot/table.py +1261 -0
- package/python/vendor/openpyxl/reader/__init__.py +1 -0
- package/python/vendor/openpyxl/reader/drawings.py +71 -0
- package/python/vendor/openpyxl/reader/excel.py +349 -0
- package/python/vendor/openpyxl/reader/strings.py +44 -0
- package/python/vendor/openpyxl/reader/workbook.py +133 -0
- package/python/vendor/openpyxl/styles/__init__.py +11 -0
- package/python/vendor/openpyxl/styles/alignment.py +62 -0
- package/python/vendor/openpyxl/styles/borders.py +103 -0
- package/python/vendor/openpyxl/styles/builtins.py +1397 -0
- package/python/vendor/openpyxl/styles/cell_style.py +206 -0
- package/python/vendor/openpyxl/styles/colors.py +172 -0
- package/python/vendor/openpyxl/styles/differential.py +95 -0
- package/python/vendor/openpyxl/styles/fills.py +224 -0
- package/python/vendor/openpyxl/styles/fonts.py +113 -0
- package/python/vendor/openpyxl/styles/named_styles.py +282 -0
- package/python/vendor/openpyxl/styles/numbers.py +200 -0
- package/python/vendor/openpyxl/styles/protection.py +17 -0
- package/python/vendor/openpyxl/styles/proxy.py +62 -0
- package/python/vendor/openpyxl/styles/styleable.py +151 -0
- package/python/vendor/openpyxl/styles/stylesheet.py +274 -0
- package/python/vendor/openpyxl/styles/table.py +94 -0
- package/python/vendor/openpyxl/utils/__init__.py +17 -0
- package/python/vendor/openpyxl/utils/bound_dictionary.py +26 -0
- package/python/vendor/openpyxl/utils/cell.py +240 -0
- package/python/vendor/openpyxl/utils/dataframe.py +87 -0
- package/python/vendor/openpyxl/utils/datetime.py +140 -0
- package/python/vendor/openpyxl/utils/escape.py +43 -0
- package/python/vendor/openpyxl/utils/exceptions.py +34 -0
- package/python/vendor/openpyxl/utils/formulas.py +24 -0
- package/python/vendor/openpyxl/utils/indexed_list.py +49 -0
- package/python/vendor/openpyxl/utils/inference.py +60 -0
- package/python/vendor/openpyxl/utils/protection.py +22 -0
- package/python/vendor/openpyxl/utils/units.py +108 -0
- package/python/vendor/openpyxl/workbook/__init__.py +4 -0
- package/python/vendor/openpyxl/workbook/_writer.py +197 -0
- package/python/vendor/openpyxl/workbook/child.py +166 -0
- package/python/vendor/openpyxl/workbook/defined_name.py +189 -0
- package/python/vendor/openpyxl/workbook/external_link/__init__.py +3 -0
- package/python/vendor/openpyxl/workbook/external_link/external.py +190 -0
- package/python/vendor/openpyxl/workbook/external_reference.py +18 -0
- package/python/vendor/openpyxl/workbook/function_group.py +36 -0
- package/python/vendor/openpyxl/workbook/properties.py +151 -0
- package/python/vendor/openpyxl/workbook/protection.py +163 -0
- package/python/vendor/openpyxl/workbook/smart_tags.py +56 -0
- package/python/vendor/openpyxl/workbook/views.py +155 -0
- package/python/vendor/openpyxl/workbook/web.py +98 -0
- package/python/vendor/openpyxl/workbook/workbook.py +438 -0
- package/python/vendor/openpyxl/worksheet/__init__.py +1 -0
- package/python/vendor/openpyxl/worksheet/_read_only.py +190 -0
- package/python/vendor/openpyxl/worksheet/_reader.py +472 -0
- package/python/vendor/openpyxl/worksheet/_write_only.py +160 -0
- package/python/vendor/openpyxl/worksheet/_writer.py +390 -0
- package/python/vendor/openpyxl/worksheet/cell_range.py +512 -0
- package/python/vendor/openpyxl/worksheet/cell_watch.py +34 -0
- package/python/vendor/openpyxl/worksheet/controls.py +107 -0
- package/python/vendor/openpyxl/worksheet/copier.py +70 -0
- package/python/vendor/openpyxl/worksheet/custom.py +35 -0
- package/python/vendor/openpyxl/worksheet/datavalidation.py +202 -0
- package/python/vendor/openpyxl/worksheet/dimensions.py +306 -0
- package/python/vendor/openpyxl/worksheet/drawing.py +14 -0
- package/python/vendor/openpyxl/worksheet/errors.py +93 -0
- package/python/vendor/openpyxl/worksheet/filters.py +486 -0
- package/python/vendor/openpyxl/worksheet/formula.py +51 -0
- package/python/vendor/openpyxl/worksheet/header_footer.py +270 -0
- package/python/vendor/openpyxl/worksheet/hyperlink.py +46 -0
- package/python/vendor/openpyxl/worksheet/merge.py +141 -0
- package/python/vendor/openpyxl/worksheet/ole.py +133 -0
- package/python/vendor/openpyxl/worksheet/page.py +174 -0
- package/python/vendor/openpyxl/worksheet/pagebreak.py +94 -0
- package/python/vendor/openpyxl/worksheet/picture.py +8 -0
- package/python/vendor/openpyxl/worksheet/print_settings.py +184 -0
- package/python/vendor/openpyxl/worksheet/properties.py +97 -0
- package/python/vendor/openpyxl/worksheet/protection.py +120 -0
- package/python/vendor/openpyxl/worksheet/related.py +17 -0
- package/python/vendor/openpyxl/worksheet/scenario.py +105 -0
- package/python/vendor/openpyxl/worksheet/smart_tag.py +78 -0
- package/python/vendor/openpyxl/worksheet/table.py +385 -0
- package/python/vendor/openpyxl/worksheet/views.py +155 -0
- package/python/vendor/openpyxl/worksheet/worksheet.py +907 -0
- package/python/vendor/openpyxl/writer/__init__.py +1 -0
- package/python/vendor/openpyxl/writer/excel.py +295 -0
- package/python/vendor/openpyxl/writer/theme.py +291 -0
- package/python/vendor/openpyxl/xml/__init__.py +42 -0
- package/python/vendor/openpyxl/xml/constants.py +129 -0
- package/python/vendor/openpyxl/xml/functions.py +87 -0
- package/watchlist/package.json +1 -1
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# Copyright (c) 2010-2024 openpyxl
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
Spreadsheet Drawing has some copies of Drawing ML elements
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from .geometry import Point2D, PositiveSize2D, Transform2D
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class XDRPoint2D(Point2D):
|
|
11
|
+
|
|
12
|
+
namespace = None
|
|
13
|
+
x = Point2D.x
|
|
14
|
+
y = Point2D.y
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class XDRPositiveSize2D(PositiveSize2D):
|
|
18
|
+
|
|
19
|
+
namespace = None
|
|
20
|
+
cx = PositiveSize2D.cx
|
|
21
|
+
cy = PositiveSize2D.cy
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class XDRTransform2D(Transform2D):
|
|
25
|
+
|
|
26
|
+
namespace = None
|
|
27
|
+
rot = Transform2D.rot
|
|
28
|
+
flipH = Transform2D.flipH
|
|
29
|
+
flipV = Transform2D.flipV
|
|
30
|
+
off = Transform2D.off
|
|
31
|
+
ext = Transform2D.ext
|
|
32
|
+
chOff = Transform2D.chOff
|
|
33
|
+
chExt = Transform2D.chExt
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
# Copyright (c) 2010-2024 openpyxl
|
|
2
|
+
|
|
3
|
+
from collections import OrderedDict
|
|
4
|
+
|
|
5
|
+
from openpyxl.descriptors import (
|
|
6
|
+
Bool,
|
|
7
|
+
Sequence,
|
|
8
|
+
Alias,
|
|
9
|
+
Convertible,
|
|
10
|
+
)
|
|
11
|
+
from openpyxl.descriptors.serialisable import Serialisable
|
|
12
|
+
|
|
13
|
+
from .rule import Rule
|
|
14
|
+
|
|
15
|
+
from openpyxl.worksheet.cell_range import MultiCellRange
|
|
16
|
+
|
|
17
|
+
class ConditionalFormatting(Serialisable):
|
|
18
|
+
|
|
19
|
+
tagname = "conditionalFormatting"
|
|
20
|
+
|
|
21
|
+
sqref = Convertible(expected_type=MultiCellRange)
|
|
22
|
+
cells = Alias("sqref")
|
|
23
|
+
pivot = Bool(allow_none=True)
|
|
24
|
+
cfRule = Sequence(expected_type=Rule)
|
|
25
|
+
rules = Alias("cfRule")
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def __init__(self, sqref=(), pivot=None, cfRule=(), extLst=None):
|
|
29
|
+
self.sqref = sqref
|
|
30
|
+
self.pivot = pivot
|
|
31
|
+
self.cfRule = cfRule
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def __eq__(self, other):
|
|
35
|
+
if not isinstance(other, self.__class__):
|
|
36
|
+
return False
|
|
37
|
+
return self.sqref == other.sqref
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def __hash__(self):
|
|
41
|
+
return hash(self.sqref)
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def __repr__(self):
|
|
45
|
+
return "<{cls} {cells}>".format(cls=self.__class__.__name__, cells=self.sqref)
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def __contains__(self, coord):
|
|
49
|
+
"""
|
|
50
|
+
Check whether a certain cell is affected by the formatting
|
|
51
|
+
"""
|
|
52
|
+
return coord in self.sqref
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
class ConditionalFormattingList:
|
|
56
|
+
"""Conditional formatting rules."""
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def __init__(self):
|
|
60
|
+
self._cf_rules = OrderedDict()
|
|
61
|
+
self.max_priority = 0
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def add(self, range_string, cfRule):
|
|
65
|
+
"""Add a rule such as ColorScaleRule, FormulaRule or CellIsRule
|
|
66
|
+
|
|
67
|
+
The priority will be added automatically.
|
|
68
|
+
"""
|
|
69
|
+
cf = range_string
|
|
70
|
+
if isinstance(range_string, str):
|
|
71
|
+
cf = ConditionalFormatting(range_string)
|
|
72
|
+
if not isinstance(cfRule, Rule):
|
|
73
|
+
raise ValueError("Only instances of openpyxl.formatting.rule.Rule may be added")
|
|
74
|
+
rule = cfRule
|
|
75
|
+
self.max_priority += 1
|
|
76
|
+
if not rule.priority:
|
|
77
|
+
rule.priority = self.max_priority
|
|
78
|
+
|
|
79
|
+
self._cf_rules.setdefault(cf, []).append(rule)
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
def __bool__(self):
|
|
83
|
+
return bool(self._cf_rules)
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
def __len__(self):
|
|
87
|
+
return len(self._cf_rules)
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
def __iter__(self):
|
|
91
|
+
for cf, rules in self._cf_rules.items():
|
|
92
|
+
cf.rules = rules
|
|
93
|
+
yield cf
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
def __getitem__(self, key):
|
|
97
|
+
"""
|
|
98
|
+
Get the rules for a cell range
|
|
99
|
+
"""
|
|
100
|
+
if isinstance(key, str):
|
|
101
|
+
key = ConditionalFormatting(sqref=key)
|
|
102
|
+
return self._cf_rules[key]
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
def __delitem__(self, key):
|
|
106
|
+
key = ConditionalFormatting(sqref=key)
|
|
107
|
+
del self._cf_rules[key]
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
def __setitem__(self, key, rule):
|
|
111
|
+
"""
|
|
112
|
+
Add a rule for a cell range
|
|
113
|
+
"""
|
|
114
|
+
self.add(key, rule)
|
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
# Copyright (c) 2010-2024 openpyxl
|
|
2
|
+
|
|
3
|
+
from openpyxl.descriptors.serialisable import Serialisable
|
|
4
|
+
from openpyxl.descriptors import (
|
|
5
|
+
Typed,
|
|
6
|
+
String,
|
|
7
|
+
Sequence,
|
|
8
|
+
Bool,
|
|
9
|
+
NoneSet,
|
|
10
|
+
Set,
|
|
11
|
+
Integer,
|
|
12
|
+
Float,
|
|
13
|
+
)
|
|
14
|
+
from openpyxl.descriptors.excel import ExtensionList
|
|
15
|
+
from openpyxl.styles.colors import Color, ColorDescriptor
|
|
16
|
+
from openpyxl.styles.differential import DifferentialStyle
|
|
17
|
+
|
|
18
|
+
from openpyxl.utils.cell import COORD_RE
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class ValueDescriptor(Float):
|
|
22
|
+
"""
|
|
23
|
+
Expected type depends upon type attribute of parent :-(
|
|
24
|
+
|
|
25
|
+
Most values should be numeric BUT they can also be cell references
|
|
26
|
+
"""
|
|
27
|
+
|
|
28
|
+
def __set__(self, instance, value):
|
|
29
|
+
ref = None
|
|
30
|
+
if value is not None and isinstance(value, str):
|
|
31
|
+
ref = COORD_RE.match(value)
|
|
32
|
+
if instance.type == "formula" or ref:
|
|
33
|
+
self.expected_type = str
|
|
34
|
+
else:
|
|
35
|
+
self.expected_type = float
|
|
36
|
+
super().__set__(instance, value)
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
class FormatObject(Serialisable):
|
|
40
|
+
|
|
41
|
+
tagname = "cfvo"
|
|
42
|
+
|
|
43
|
+
type = Set(values=(['num', 'percent', 'max', 'min', 'formula', 'percentile']))
|
|
44
|
+
val = ValueDescriptor(allow_none=True)
|
|
45
|
+
gte = Bool(allow_none=True)
|
|
46
|
+
extLst = Typed(expected_type=ExtensionList, allow_none=True)
|
|
47
|
+
|
|
48
|
+
__elements__ = ()
|
|
49
|
+
|
|
50
|
+
def __init__(self,
|
|
51
|
+
type,
|
|
52
|
+
val=None,
|
|
53
|
+
gte=None,
|
|
54
|
+
extLst=None,
|
|
55
|
+
):
|
|
56
|
+
self.type = type
|
|
57
|
+
self.val = val
|
|
58
|
+
self.gte = gte
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
class RuleType(Serialisable):
|
|
62
|
+
|
|
63
|
+
cfvo = Sequence(expected_type=FormatObject)
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
class IconSet(RuleType):
|
|
67
|
+
|
|
68
|
+
tagname = "iconSet"
|
|
69
|
+
|
|
70
|
+
iconSet = NoneSet(values=(['3Arrows', '3ArrowsGray', '3Flags',
|
|
71
|
+
'3TrafficLights1', '3TrafficLights2', '3Signs', '3Symbols', '3Symbols2',
|
|
72
|
+
'4Arrows', '4ArrowsGray', '4RedToBlack', '4Rating', '4TrafficLights',
|
|
73
|
+
'5Arrows', '5ArrowsGray', '5Rating', '5Quarters']))
|
|
74
|
+
showValue = Bool(allow_none=True)
|
|
75
|
+
percent = Bool(allow_none=True)
|
|
76
|
+
reverse = Bool(allow_none=True)
|
|
77
|
+
|
|
78
|
+
__elements__ = ("cfvo",)
|
|
79
|
+
|
|
80
|
+
def __init__(self,
|
|
81
|
+
iconSet=None,
|
|
82
|
+
showValue=None,
|
|
83
|
+
percent=None,
|
|
84
|
+
reverse=None,
|
|
85
|
+
cfvo=None,
|
|
86
|
+
):
|
|
87
|
+
self.iconSet = iconSet
|
|
88
|
+
self.showValue = showValue
|
|
89
|
+
self.percent = percent
|
|
90
|
+
self.reverse = reverse
|
|
91
|
+
self.cfvo = cfvo
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
class DataBar(RuleType):
|
|
95
|
+
|
|
96
|
+
tagname = "dataBar"
|
|
97
|
+
|
|
98
|
+
minLength = Integer(allow_none=True)
|
|
99
|
+
maxLength = Integer(allow_none=True)
|
|
100
|
+
showValue = Bool(allow_none=True)
|
|
101
|
+
color = ColorDescriptor()
|
|
102
|
+
|
|
103
|
+
__elements__ = ('cfvo', 'color')
|
|
104
|
+
|
|
105
|
+
def __init__(self,
|
|
106
|
+
minLength=None,
|
|
107
|
+
maxLength=None,
|
|
108
|
+
showValue=None,
|
|
109
|
+
cfvo=None,
|
|
110
|
+
color=None,
|
|
111
|
+
):
|
|
112
|
+
self.minLength = minLength
|
|
113
|
+
self.maxLength = maxLength
|
|
114
|
+
self.showValue = showValue
|
|
115
|
+
self.cfvo = cfvo
|
|
116
|
+
self.color = color
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
class ColorScale(RuleType):
|
|
120
|
+
|
|
121
|
+
tagname = "colorScale"
|
|
122
|
+
|
|
123
|
+
color = Sequence(expected_type=Color)
|
|
124
|
+
|
|
125
|
+
__elements__ = ('cfvo', 'color')
|
|
126
|
+
|
|
127
|
+
def __init__(self,
|
|
128
|
+
cfvo=None,
|
|
129
|
+
color=None,
|
|
130
|
+
):
|
|
131
|
+
self.cfvo = cfvo
|
|
132
|
+
self.color = color
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
class Rule(Serialisable):
|
|
136
|
+
|
|
137
|
+
tagname = "cfRule"
|
|
138
|
+
|
|
139
|
+
type = Set(values=(['expression', 'cellIs', 'colorScale', 'dataBar',
|
|
140
|
+
'iconSet', 'top10', 'uniqueValues', 'duplicateValues', 'containsText',
|
|
141
|
+
'notContainsText', 'beginsWith', 'endsWith', 'containsBlanks',
|
|
142
|
+
'notContainsBlanks', 'containsErrors', 'notContainsErrors', 'timePeriod',
|
|
143
|
+
'aboveAverage']))
|
|
144
|
+
dxfId = Integer(allow_none=True)
|
|
145
|
+
priority = Integer()
|
|
146
|
+
stopIfTrue = Bool(allow_none=True)
|
|
147
|
+
aboveAverage = Bool(allow_none=True)
|
|
148
|
+
percent = Bool(allow_none=True)
|
|
149
|
+
bottom = Bool(allow_none=True)
|
|
150
|
+
operator = NoneSet(values=(['lessThan', 'lessThanOrEqual', 'equal',
|
|
151
|
+
'notEqual', 'greaterThanOrEqual', 'greaterThan', 'between', 'notBetween',
|
|
152
|
+
'containsText', 'notContains', 'beginsWith', 'endsWith']))
|
|
153
|
+
text = String(allow_none=True)
|
|
154
|
+
timePeriod = NoneSet(values=(['today', 'yesterday', 'tomorrow', 'last7Days',
|
|
155
|
+
'thisMonth', 'lastMonth', 'nextMonth', 'thisWeek', 'lastWeek',
|
|
156
|
+
'nextWeek']))
|
|
157
|
+
rank = Integer(allow_none=True)
|
|
158
|
+
stdDev = Integer(allow_none=True)
|
|
159
|
+
equalAverage = Bool(allow_none=True)
|
|
160
|
+
formula = Sequence(expected_type=str)
|
|
161
|
+
colorScale = Typed(expected_type=ColorScale, allow_none=True)
|
|
162
|
+
dataBar = Typed(expected_type=DataBar, allow_none=True)
|
|
163
|
+
iconSet = Typed(expected_type=IconSet, allow_none=True)
|
|
164
|
+
extLst = Typed(expected_type=ExtensionList, allow_none=True)
|
|
165
|
+
dxf = Typed(expected_type=DifferentialStyle, allow_none=True)
|
|
166
|
+
|
|
167
|
+
__elements__ = ('colorScale', 'dataBar', 'iconSet', 'formula')
|
|
168
|
+
__attrs__ = ('type', 'rank', 'priority', 'equalAverage', 'operator',
|
|
169
|
+
'aboveAverage', 'dxfId', 'stdDev', 'stopIfTrue', 'timePeriod', 'text',
|
|
170
|
+
'percent', 'bottom')
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
def __init__(self,
|
|
174
|
+
type,
|
|
175
|
+
dxfId=None,
|
|
176
|
+
priority=0,
|
|
177
|
+
stopIfTrue=None,
|
|
178
|
+
aboveAverage=None,
|
|
179
|
+
percent=None,
|
|
180
|
+
bottom=None,
|
|
181
|
+
operator=None,
|
|
182
|
+
text=None,
|
|
183
|
+
timePeriod=None,
|
|
184
|
+
rank=None,
|
|
185
|
+
stdDev=None,
|
|
186
|
+
equalAverage=None,
|
|
187
|
+
formula=(),
|
|
188
|
+
colorScale=None,
|
|
189
|
+
dataBar=None,
|
|
190
|
+
iconSet=None,
|
|
191
|
+
extLst=None,
|
|
192
|
+
dxf=None,
|
|
193
|
+
):
|
|
194
|
+
self.type = type
|
|
195
|
+
self.dxfId = dxfId
|
|
196
|
+
self.priority = priority
|
|
197
|
+
self.stopIfTrue = stopIfTrue
|
|
198
|
+
self.aboveAverage = aboveAverage
|
|
199
|
+
self.percent = percent
|
|
200
|
+
self.bottom = bottom
|
|
201
|
+
self.operator = operator
|
|
202
|
+
self.text = text
|
|
203
|
+
self.timePeriod = timePeriod
|
|
204
|
+
self.rank = rank
|
|
205
|
+
self.stdDev = stdDev
|
|
206
|
+
self.equalAverage = equalAverage
|
|
207
|
+
self.formula = formula
|
|
208
|
+
self.colorScale = colorScale
|
|
209
|
+
self.dataBar = dataBar
|
|
210
|
+
self.iconSet = iconSet
|
|
211
|
+
self.dxf = dxf
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
def ColorScaleRule(start_type=None,
|
|
215
|
+
start_value=None,
|
|
216
|
+
start_color=None,
|
|
217
|
+
mid_type=None,
|
|
218
|
+
mid_value=None,
|
|
219
|
+
mid_color=None,
|
|
220
|
+
end_type=None,
|
|
221
|
+
end_value=None,
|
|
222
|
+
end_color=None):
|
|
223
|
+
|
|
224
|
+
"""Backwards compatibility"""
|
|
225
|
+
formats = []
|
|
226
|
+
if start_type is not None:
|
|
227
|
+
formats.append(FormatObject(type=start_type, val=start_value))
|
|
228
|
+
if mid_type is not None:
|
|
229
|
+
formats.append(FormatObject(type=mid_type, val=mid_value))
|
|
230
|
+
if end_type is not None:
|
|
231
|
+
formats.append(FormatObject(type=end_type, val=end_value))
|
|
232
|
+
colors = []
|
|
233
|
+
for v in (start_color, mid_color, end_color):
|
|
234
|
+
if v is not None:
|
|
235
|
+
if not isinstance(v, Color):
|
|
236
|
+
v = Color(v)
|
|
237
|
+
colors.append(v)
|
|
238
|
+
cs = ColorScale(cfvo=formats, color=colors)
|
|
239
|
+
rule = Rule(type="colorScale", colorScale=cs)
|
|
240
|
+
return rule
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
def FormulaRule(formula=None, stopIfTrue=None, font=None, border=None,
|
|
244
|
+
fill=None):
|
|
245
|
+
"""
|
|
246
|
+
Conditional formatting with custom differential style
|
|
247
|
+
"""
|
|
248
|
+
rule = Rule(type="expression", formula=formula, stopIfTrue=stopIfTrue)
|
|
249
|
+
rule.dxf = DifferentialStyle(font=font, border=border, fill=fill)
|
|
250
|
+
return rule
|
|
251
|
+
|
|
252
|
+
|
|
253
|
+
def CellIsRule(operator=None, formula=None, stopIfTrue=None, font=None, border=None, fill=None):
|
|
254
|
+
"""
|
|
255
|
+
Conditional formatting rule based on cell contents.
|
|
256
|
+
"""
|
|
257
|
+
# Excel doesn't use >, >=, etc, but allow for ease of python development
|
|
258
|
+
expand = {">": "greaterThan", ">=": "greaterThanOrEqual", "<": "lessThan", "<=": "lessThanOrEqual",
|
|
259
|
+
"=": "equal", "==": "equal", "!=": "notEqual"}
|
|
260
|
+
|
|
261
|
+
operator = expand.get(operator, operator)
|
|
262
|
+
|
|
263
|
+
rule = Rule(type='cellIs', operator=operator, formula=formula, stopIfTrue=stopIfTrue)
|
|
264
|
+
rule.dxf = DifferentialStyle(font=font, border=border, fill=fill)
|
|
265
|
+
|
|
266
|
+
return rule
|
|
267
|
+
|
|
268
|
+
|
|
269
|
+
def IconSetRule(icon_style=None, type=None, values=None, showValue=None, percent=None, reverse=None):
|
|
270
|
+
"""
|
|
271
|
+
Convenience function for creating icon set rules
|
|
272
|
+
"""
|
|
273
|
+
cfvo = []
|
|
274
|
+
for val in values:
|
|
275
|
+
cfvo.append(FormatObject(type, val))
|
|
276
|
+
icon_set = IconSet(iconSet=icon_style, cfvo=cfvo, showValue=showValue,
|
|
277
|
+
percent=percent, reverse=reverse)
|
|
278
|
+
rule = Rule(type='iconSet', iconSet=icon_set)
|
|
279
|
+
|
|
280
|
+
return rule
|
|
281
|
+
|
|
282
|
+
|
|
283
|
+
def DataBarRule(start_type=None, start_value=None, end_type=None,
|
|
284
|
+
end_value=None, color=None, showValue=None, minLength=None, maxLength=None):
|
|
285
|
+
start = FormatObject(start_type, start_value)
|
|
286
|
+
end = FormatObject(end_type, end_value)
|
|
287
|
+
data_bar = DataBar(cfvo=[start, end], color=color, showValue=showValue,
|
|
288
|
+
minLength=minLength, maxLength=maxLength)
|
|
289
|
+
rule = Rule(type='dataBar', dataBar=data_bar)
|
|
290
|
+
|
|
291
|
+
return rule
|