@v587d/capital-generation 2.28.0 → 2.30.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +59 -0
- package/README.md +5 -4
- 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/tools.js +7 -7
- package/lib/host-version.d.ts +9 -0
- package/lib/host-version.js +57 -0
- 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/runtime-entry.js +8 -0
- 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 +514 -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 +6 -3
- 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,211 @@
|
|
|
1
|
+
# Copyright (c) 2010-2024 openpyxl
|
|
2
|
+
|
|
3
|
+
## Incomplete!
|
|
4
|
+
from openpyxl.descriptors.serialisable import Serialisable
|
|
5
|
+
from openpyxl.descriptors import (
|
|
6
|
+
Typed,
|
|
7
|
+
Integer,
|
|
8
|
+
Set,
|
|
9
|
+
String,
|
|
10
|
+
Bool,
|
|
11
|
+
)
|
|
12
|
+
from openpyxl.descriptors.excel import Guid, ExtensionList
|
|
13
|
+
from openpyxl.descriptors.sequence import NestedSequence
|
|
14
|
+
|
|
15
|
+
from openpyxl.utils.indexed_list import IndexedList
|
|
16
|
+
from openpyxl.xml.constants import SHEET_MAIN_NS
|
|
17
|
+
|
|
18
|
+
from openpyxl.cell.text import Text
|
|
19
|
+
from .author import AuthorList
|
|
20
|
+
from .comments import Comment
|
|
21
|
+
from .shape_writer import ShapeWriter
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class Properties(Serialisable):
|
|
25
|
+
|
|
26
|
+
locked = Bool(allow_none=True)
|
|
27
|
+
defaultSize = Bool(allow_none=True)
|
|
28
|
+
_print = Bool(allow_none=True)
|
|
29
|
+
disabled = Bool(allow_none=True)
|
|
30
|
+
uiObject = Bool(allow_none=True)
|
|
31
|
+
autoFill = Bool(allow_none=True)
|
|
32
|
+
autoLine = Bool(allow_none=True)
|
|
33
|
+
altText = String(allow_none=True)
|
|
34
|
+
textHAlign = Set(values=(['left', 'center', 'right', 'justify', 'distributed']))
|
|
35
|
+
textVAlign = Set(values=(['top', 'center', 'bottom', 'justify', 'distributed']))
|
|
36
|
+
lockText = Bool(allow_none=True)
|
|
37
|
+
justLastX = Bool(allow_none=True)
|
|
38
|
+
autoScale = Bool(allow_none=True)
|
|
39
|
+
rowHidden = Bool(allow_none=True)
|
|
40
|
+
colHidden = Bool(allow_none=True)
|
|
41
|
+
# anchor = Typed(expected_type=ObjectAnchor, )
|
|
42
|
+
|
|
43
|
+
__elements__ = ('anchor',)
|
|
44
|
+
|
|
45
|
+
def __init__(self,
|
|
46
|
+
locked=None,
|
|
47
|
+
defaultSize=None,
|
|
48
|
+
_print=None,
|
|
49
|
+
disabled=None,
|
|
50
|
+
uiObject=None,
|
|
51
|
+
autoFill=None,
|
|
52
|
+
autoLine=None,
|
|
53
|
+
altText=None,
|
|
54
|
+
textHAlign=None,
|
|
55
|
+
textVAlign=None,
|
|
56
|
+
lockText=None,
|
|
57
|
+
justLastX=None,
|
|
58
|
+
autoScale=None,
|
|
59
|
+
rowHidden=None,
|
|
60
|
+
colHidden=None,
|
|
61
|
+
anchor=None,
|
|
62
|
+
):
|
|
63
|
+
self.locked = locked
|
|
64
|
+
self.defaultSize = defaultSize
|
|
65
|
+
self._print = _print
|
|
66
|
+
self.disabled = disabled
|
|
67
|
+
self.uiObject = uiObject
|
|
68
|
+
self.autoFill = autoFill
|
|
69
|
+
self.autoLine = autoLine
|
|
70
|
+
self.altText = altText
|
|
71
|
+
self.textHAlign = textHAlign
|
|
72
|
+
self.textVAlign = textVAlign
|
|
73
|
+
self.lockText = lockText
|
|
74
|
+
self.justLastX = justLastX
|
|
75
|
+
self.autoScale = autoScale
|
|
76
|
+
self.rowHidden = rowHidden
|
|
77
|
+
self.colHidden = colHidden
|
|
78
|
+
self.anchor = anchor
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
class CommentRecord(Serialisable):
|
|
82
|
+
|
|
83
|
+
tagname = "comment"
|
|
84
|
+
|
|
85
|
+
ref = String()
|
|
86
|
+
authorId = Integer()
|
|
87
|
+
guid = Guid(allow_none=True)
|
|
88
|
+
shapeId = Integer(allow_none=True)
|
|
89
|
+
text = Typed(expected_type=Text)
|
|
90
|
+
commentPr = Typed(expected_type=Properties, allow_none=True)
|
|
91
|
+
author = String(allow_none=True)
|
|
92
|
+
|
|
93
|
+
__elements__ = ('text', 'commentPr')
|
|
94
|
+
__attrs__ = ('ref', 'authorId', 'guid', 'shapeId')
|
|
95
|
+
|
|
96
|
+
def __init__(self,
|
|
97
|
+
ref="",
|
|
98
|
+
authorId=0,
|
|
99
|
+
guid=None,
|
|
100
|
+
shapeId=0,
|
|
101
|
+
text=None,
|
|
102
|
+
commentPr=None,
|
|
103
|
+
author=None,
|
|
104
|
+
height=79,
|
|
105
|
+
width=144
|
|
106
|
+
):
|
|
107
|
+
self.ref = ref
|
|
108
|
+
self.authorId = authorId
|
|
109
|
+
self.guid = guid
|
|
110
|
+
self.shapeId = shapeId
|
|
111
|
+
if text is None:
|
|
112
|
+
text = Text()
|
|
113
|
+
self.text = text
|
|
114
|
+
self.commentPr = commentPr
|
|
115
|
+
self.author = author
|
|
116
|
+
self.height = height
|
|
117
|
+
self.width = width
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
@classmethod
|
|
121
|
+
def from_cell(cls, cell):
|
|
122
|
+
"""
|
|
123
|
+
Class method to convert cell comment
|
|
124
|
+
"""
|
|
125
|
+
comment = cell._comment
|
|
126
|
+
ref = cell.coordinate
|
|
127
|
+
self = cls(ref=ref, author=comment.author)
|
|
128
|
+
self.text.t = comment.content
|
|
129
|
+
self.height = comment.height
|
|
130
|
+
self.width = comment.width
|
|
131
|
+
return self
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
@property
|
|
135
|
+
def content(self):
|
|
136
|
+
"""
|
|
137
|
+
Remove all inline formatting and stuff
|
|
138
|
+
"""
|
|
139
|
+
return self.text.content
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
class CommentSheet(Serialisable):
|
|
143
|
+
|
|
144
|
+
tagname = "comments"
|
|
145
|
+
|
|
146
|
+
authors = Typed(expected_type=AuthorList)
|
|
147
|
+
commentList = NestedSequence(expected_type=CommentRecord, count=0)
|
|
148
|
+
extLst = Typed(expected_type=ExtensionList, allow_none=True)
|
|
149
|
+
|
|
150
|
+
_id = None
|
|
151
|
+
_path = "/xl/comments/comment{0}.xml"
|
|
152
|
+
mime_type = "application/vnd.openxmlformats-officedocument.spreadsheetml.comments+xml"
|
|
153
|
+
_rel_type = "comments"
|
|
154
|
+
_rel_id = None
|
|
155
|
+
|
|
156
|
+
__elements__ = ('authors', 'commentList')
|
|
157
|
+
|
|
158
|
+
def __init__(self,
|
|
159
|
+
authors=None,
|
|
160
|
+
commentList=None,
|
|
161
|
+
extLst=None,
|
|
162
|
+
):
|
|
163
|
+
self.authors = authors
|
|
164
|
+
self.commentList = commentList
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
def to_tree(self):
|
|
168
|
+
tree = super().to_tree()
|
|
169
|
+
tree.set("xmlns", SHEET_MAIN_NS)
|
|
170
|
+
return tree
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
@property
|
|
174
|
+
def comments(self):
|
|
175
|
+
"""
|
|
176
|
+
Return a dictionary of comments keyed by coord
|
|
177
|
+
"""
|
|
178
|
+
authors = self.authors.author
|
|
179
|
+
|
|
180
|
+
for c in self.commentList:
|
|
181
|
+
yield c.ref, Comment(c.content, authors[c.authorId], c.height, c.width)
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
@classmethod
|
|
185
|
+
def from_comments(cls, comments):
|
|
186
|
+
"""
|
|
187
|
+
Create a comment sheet from a list of comments for a particular worksheet
|
|
188
|
+
"""
|
|
189
|
+
authors = IndexedList()
|
|
190
|
+
|
|
191
|
+
# dedupe authors and get indexes
|
|
192
|
+
for comment in comments:
|
|
193
|
+
comment.authorId = authors.add(comment.author)
|
|
194
|
+
|
|
195
|
+
return cls(authors=AuthorList(authors), commentList=comments)
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
def write_shapes(self, vml=None):
|
|
199
|
+
"""
|
|
200
|
+
Create the VML for comments
|
|
201
|
+
"""
|
|
202
|
+
sw = ShapeWriter(self.comments)
|
|
203
|
+
return sw.write(vml)
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
@property
|
|
207
|
+
def path(self):
|
|
208
|
+
"""
|
|
209
|
+
Return path within the archive
|
|
210
|
+
"""
|
|
211
|
+
return self._path.format(self._id)
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# Copyright (c) 2010-2024 openpyxl
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class Comment:
|
|
5
|
+
|
|
6
|
+
_parent = None
|
|
7
|
+
|
|
8
|
+
def __init__(self, text, author, height=79, width=144):
|
|
9
|
+
self.content = text
|
|
10
|
+
self.author = author
|
|
11
|
+
self.height = height
|
|
12
|
+
self.width = width
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
@property
|
|
16
|
+
def parent(self):
|
|
17
|
+
return self._parent
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def __eq__(self, other):
|
|
21
|
+
return (
|
|
22
|
+
self.content == other.content
|
|
23
|
+
and self.author == other.author
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
def __repr__(self):
|
|
27
|
+
return "Comment: {0} by {1}".format(self.content, self.author)
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def __copy__(self):
|
|
31
|
+
"""Create a detached copy of this comment."""
|
|
32
|
+
clone = self.__class__(self.content, self.author, self.height, self.width)
|
|
33
|
+
return clone
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def bind(self, cell):
|
|
37
|
+
"""
|
|
38
|
+
Bind comment to a particular cell
|
|
39
|
+
"""
|
|
40
|
+
if cell is not None and self._parent is not None and self._parent != cell:
|
|
41
|
+
fmt = "Comment already assigned to {0} in worksheet {1}. Cannot assign a comment to more than one cell"
|
|
42
|
+
raise AttributeError(fmt.format(cell.coordinate, cell.parent.title))
|
|
43
|
+
self._parent = cell
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def unbind(self):
|
|
47
|
+
"""
|
|
48
|
+
Unbind a comment from a cell
|
|
49
|
+
"""
|
|
50
|
+
self._parent = None
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
@property
|
|
54
|
+
def text(self):
|
|
55
|
+
"""
|
|
56
|
+
Any comment text stripped of all formatting.
|
|
57
|
+
"""
|
|
58
|
+
return self.content
|
|
59
|
+
|
|
60
|
+
@text.setter
|
|
61
|
+
def text(self, value):
|
|
62
|
+
self.content = value
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
# Copyright (c) 2010-2024 openpyxl
|
|
2
|
+
|
|
3
|
+
from openpyxl.xml.functions import (
|
|
4
|
+
Element,
|
|
5
|
+
SubElement,
|
|
6
|
+
tostring,
|
|
7
|
+
)
|
|
8
|
+
|
|
9
|
+
from openpyxl.utils import coordinate_to_tuple
|
|
10
|
+
|
|
11
|
+
vmlns = "urn:schemas-microsoft-com:vml"
|
|
12
|
+
officens = "urn:schemas-microsoft-com:office:office"
|
|
13
|
+
excelns = "urn:schemas-microsoft-com:office:excel"
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class ShapeWriter:
|
|
17
|
+
"""
|
|
18
|
+
Create VML for comments
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
vml = None
|
|
22
|
+
vml_path = None
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def __init__(self, comments):
|
|
26
|
+
self.comments = comments
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def add_comment_shapetype(self, root):
|
|
30
|
+
shape_layout = SubElement(root, "{%s}shapelayout" % officens,
|
|
31
|
+
{"{%s}ext" % vmlns: "edit"})
|
|
32
|
+
SubElement(shape_layout,
|
|
33
|
+
"{%s}idmap" % officens,
|
|
34
|
+
{"{%s}ext" % vmlns: "edit", "data": "1"})
|
|
35
|
+
shape_type = SubElement(root,
|
|
36
|
+
"{%s}shapetype" % vmlns,
|
|
37
|
+
{"id": "_x0000_t202",
|
|
38
|
+
"coordsize": "21600,21600",
|
|
39
|
+
"{%s}spt" % officens: "202",
|
|
40
|
+
"path": "m,l,21600r21600,l21600,xe"})
|
|
41
|
+
SubElement(shape_type, "{%s}stroke" % vmlns, {"joinstyle": "miter"})
|
|
42
|
+
SubElement(shape_type,
|
|
43
|
+
"{%s}path" % vmlns,
|
|
44
|
+
{"gradientshapeok": "t",
|
|
45
|
+
"{%s}connecttype" % officens: "rect"})
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def add_comment_shape(self, root, idx, coord, height, width):
|
|
49
|
+
row, col = coordinate_to_tuple(coord)
|
|
50
|
+
row -= 1
|
|
51
|
+
col -= 1
|
|
52
|
+
shape = _shape_factory(row, col, height, width)
|
|
53
|
+
|
|
54
|
+
shape.set('id', "_x0000_s%04d" % idx)
|
|
55
|
+
root.append(shape)
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def write(self, root):
|
|
59
|
+
|
|
60
|
+
if not hasattr(root, "findall"):
|
|
61
|
+
root = Element("xml")
|
|
62
|
+
|
|
63
|
+
# Remove any existing comment shapes
|
|
64
|
+
comments = root.findall("{%s}shape[@type='#_x0000_t202']" % vmlns)
|
|
65
|
+
for c in comments:
|
|
66
|
+
root.remove(c)
|
|
67
|
+
|
|
68
|
+
# check whether comments shape type already exists
|
|
69
|
+
shape_types = root.find("{%s}shapetype[@id='_x0000_t202']" % vmlns)
|
|
70
|
+
if shape_types is None:
|
|
71
|
+
self.add_comment_shapetype(root)
|
|
72
|
+
|
|
73
|
+
for idx, (coord, comment) in enumerate(self.comments, 1026):
|
|
74
|
+
self.add_comment_shape(root, idx, coord, comment.height, comment.width)
|
|
75
|
+
|
|
76
|
+
return tostring(root)
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
def _shape_factory(row, column, height, width):
|
|
80
|
+
style = ("position:absolute; "
|
|
81
|
+
"margin-left:59.25pt;"
|
|
82
|
+
"margin-top:1.5pt;"
|
|
83
|
+
"width:{width}px;"
|
|
84
|
+
"height:{height}px;"
|
|
85
|
+
"z-index:1;"
|
|
86
|
+
"visibility:hidden").format(height=height,
|
|
87
|
+
width=width)
|
|
88
|
+
attrs = {
|
|
89
|
+
"type": "#_x0000_t202",
|
|
90
|
+
"style": style,
|
|
91
|
+
"fillcolor": "#ffffe1",
|
|
92
|
+
"{%s}insetmode" % officens: "auto"
|
|
93
|
+
}
|
|
94
|
+
shape = Element("{%s}shape" % vmlns, attrs)
|
|
95
|
+
|
|
96
|
+
SubElement(shape, "{%s}fill" % vmlns,
|
|
97
|
+
{"color2": "#ffffe1"})
|
|
98
|
+
SubElement(shape, "{%s}shadow" % vmlns,
|
|
99
|
+
{"color": "black", "obscured": "t"})
|
|
100
|
+
SubElement(shape, "{%s}path" % vmlns,
|
|
101
|
+
{"{%s}connecttype" % officens: "none"})
|
|
102
|
+
textbox = SubElement(shape, "{%s}textbox" % vmlns,
|
|
103
|
+
{"style": "mso-direction-alt:auto"})
|
|
104
|
+
SubElement(textbox, "div", {"style": "text-align:left"})
|
|
105
|
+
client_data = SubElement(shape, "{%s}ClientData" % excelns,
|
|
106
|
+
{"ObjectType": "Note"})
|
|
107
|
+
SubElement(client_data, "{%s}MoveWithCells" % excelns)
|
|
108
|
+
SubElement(client_data, "{%s}SizeWithCells" % excelns)
|
|
109
|
+
SubElement(client_data, "{%s}AutoFill" % excelns).text = "False"
|
|
110
|
+
SubElement(client_data, "{%s}Row" % excelns).text = str(row)
|
|
111
|
+
SubElement(client_data, "{%s}Column" % excelns).text = str(column)
|
|
112
|
+
return shape
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# Copyright (c) 2010-2024 openpyxl
|
|
2
|
+
|
|
3
|
+
from .numbers import NUMERIC_TYPES
|
|
4
|
+
from .strings import safe_string
|
|
5
|
+
|
|
6
|
+
import warnings
|
|
7
|
+
from functools import wraps
|
|
8
|
+
import inspect
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class DummyCode:
|
|
12
|
+
|
|
13
|
+
pass
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
# from https://github.com/tantale/deprecated/blob/master/deprecated/__init__.py
|
|
17
|
+
# with an enhancement to update docstrings of deprecated functions
|
|
18
|
+
string_types = (type(b''), type(u''))
|
|
19
|
+
def deprecated(reason):
|
|
20
|
+
|
|
21
|
+
if isinstance(reason, string_types):
|
|
22
|
+
|
|
23
|
+
def decorator(func1):
|
|
24
|
+
|
|
25
|
+
if inspect.isclass(func1):
|
|
26
|
+
fmt1 = "Call to deprecated class {name} ({reason})."
|
|
27
|
+
else:
|
|
28
|
+
fmt1 = "Call to deprecated function {name} ({reason})."
|
|
29
|
+
|
|
30
|
+
@wraps(func1)
|
|
31
|
+
def new_func1(*args, **kwargs):
|
|
32
|
+
#warnings.simplefilter('default', DeprecationWarning)
|
|
33
|
+
warnings.warn(
|
|
34
|
+
fmt1.format(name=func1.__name__, reason=reason),
|
|
35
|
+
category=DeprecationWarning,
|
|
36
|
+
stacklevel=2
|
|
37
|
+
)
|
|
38
|
+
return func1(*args, **kwargs)
|
|
39
|
+
|
|
40
|
+
# Enhance docstring with a deprecation note
|
|
41
|
+
deprecationNote = "\n\n.. note::\n Deprecated: " + reason
|
|
42
|
+
if new_func1.__doc__:
|
|
43
|
+
new_func1.__doc__ += deprecationNote
|
|
44
|
+
else:
|
|
45
|
+
new_func1.__doc__ = deprecationNote
|
|
46
|
+
return new_func1
|
|
47
|
+
|
|
48
|
+
return decorator
|
|
49
|
+
|
|
50
|
+
elif inspect.isclass(reason) or inspect.isfunction(reason):
|
|
51
|
+
raise TypeError("Reason for deprecation must be supplied")
|
|
52
|
+
|
|
53
|
+
else:
|
|
54
|
+
raise TypeError(repr(type(reason)))
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# Copyright (c) 2010-2024 openpyxl
|
|
2
|
+
|
|
3
|
+
from decimal import Decimal
|
|
4
|
+
|
|
5
|
+
NUMERIC_TYPES = (int, float, Decimal)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
try:
|
|
9
|
+
import numpy
|
|
10
|
+
NUMPY = True
|
|
11
|
+
except ImportError:
|
|
12
|
+
NUMPY = False
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
if NUMPY:
|
|
16
|
+
NUMERIC_TYPES = NUMERIC_TYPES + (numpy.short,
|
|
17
|
+
numpy.ushort,
|
|
18
|
+
numpy.intc,
|
|
19
|
+
numpy.uintc,
|
|
20
|
+
numpy.int_,
|
|
21
|
+
numpy.uint,
|
|
22
|
+
numpy.longlong,
|
|
23
|
+
numpy.ulonglong,
|
|
24
|
+
numpy.half,
|
|
25
|
+
numpy.float16,
|
|
26
|
+
numpy.single,
|
|
27
|
+
numpy.double,
|
|
28
|
+
numpy.longdouble,
|
|
29
|
+
numpy.int8,
|
|
30
|
+
numpy.int16,
|
|
31
|
+
numpy.int32,
|
|
32
|
+
numpy.int64,
|
|
33
|
+
numpy.uint8,
|
|
34
|
+
numpy.uint16,
|
|
35
|
+
numpy.uint32,
|
|
36
|
+
numpy.uint64,
|
|
37
|
+
numpy.intp,
|
|
38
|
+
numpy.uintp,
|
|
39
|
+
numpy.float32,
|
|
40
|
+
numpy.float64,
|
|
41
|
+
numpy.bool_,
|
|
42
|
+
numpy.floating,
|
|
43
|
+
numpy.integer)
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Copyright (c) 2010-2024 openpyxl
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
math.prod equivalent for < Python 3.8
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
import functools
|
|
8
|
+
import operator
|
|
9
|
+
|
|
10
|
+
def product(sequence):
|
|
11
|
+
return functools.reduce(operator.mul, sequence)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
try:
|
|
15
|
+
from math import prod
|
|
16
|
+
except ImportError:
|
|
17
|
+
prod = product
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# Copyright (c) 2010-2024 openpyxl
|
|
2
|
+
|
|
3
|
+
import weakref
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class Singleton(type):
|
|
7
|
+
"""
|
|
8
|
+
Singleton metaclass
|
|
9
|
+
Based on Python Cookbook 3rd Edition Recipe 9.13
|
|
10
|
+
Only one instance of a class can exist. Does not work with __slots__
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
def __init__(self, *args, **kw):
|
|
14
|
+
super().__init__(*args, **kw)
|
|
15
|
+
self.__instance = None
|
|
16
|
+
|
|
17
|
+
def __call__(self, *args, **kw):
|
|
18
|
+
if self.__instance is None:
|
|
19
|
+
self.__instance = super().__call__(*args, **kw)
|
|
20
|
+
return self.__instance
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class Cached(type):
|
|
24
|
+
"""
|
|
25
|
+
Caching metaclass
|
|
26
|
+
Child classes will only create new instances of themselves if
|
|
27
|
+
one doesn't already exist. Does not work with __slots__
|
|
28
|
+
"""
|
|
29
|
+
|
|
30
|
+
def __init__(self, *args, **kw):
|
|
31
|
+
super().__init__(*args, **kw)
|
|
32
|
+
self.__cache = weakref.WeakValueDictionary()
|
|
33
|
+
|
|
34
|
+
def __call__(self, *args):
|
|
35
|
+
if args in self.__cache:
|
|
36
|
+
return self.__cache[args]
|
|
37
|
+
|
|
38
|
+
obj = super().__call__(*args)
|
|
39
|
+
self.__cache[args] = obj
|
|
40
|
+
return obj
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# Copyright (c) 2010-2024 openpyxl
|
|
2
|
+
|
|
3
|
+
from datetime import datetime
|
|
4
|
+
from math import isnan, isinf
|
|
5
|
+
import sys
|
|
6
|
+
|
|
7
|
+
VER = sys.version_info
|
|
8
|
+
|
|
9
|
+
from .numbers import NUMERIC_TYPES
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def safe_string(value):
|
|
13
|
+
"""Safely and consistently format numeric values"""
|
|
14
|
+
if isinstance(value, NUMERIC_TYPES):
|
|
15
|
+
if isnan(value) or isinf(value):
|
|
16
|
+
value = ""
|
|
17
|
+
else:
|
|
18
|
+
value = "%.16g" % value
|
|
19
|
+
elif value is None:
|
|
20
|
+
value = "none"
|
|
21
|
+
elif isinstance(value, datetime):
|
|
22
|
+
value = value.isoformat()
|
|
23
|
+
elif not isinstance(value, str):
|
|
24
|
+
value = str(value)
|
|
25
|
+
return value
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# Copyright (c) 2010-2024 openpyxl
|
|
2
|
+
|
|
3
|
+
from .base import *
|
|
4
|
+
from .sequence import Sequence
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class MetaStrict(type):
|
|
8
|
+
|
|
9
|
+
def __new__(cls, clsname, bases, methods):
|
|
10
|
+
for k, v in methods.items():
|
|
11
|
+
if isinstance(v, Descriptor):
|
|
12
|
+
v.name = k
|
|
13
|
+
return type.__new__(cls, clsname, bases, methods)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class Strict(metaclass=MetaStrict):
|
|
17
|
+
|
|
18
|
+
pass
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class MetaSerialisable(type):
|
|
22
|
+
|
|
23
|
+
def __new__(cls, clsname, bases, methods):
|
|
24
|
+
attrs = []
|
|
25
|
+
nested = []
|
|
26
|
+
elements = []
|
|
27
|
+
namespaced = []
|
|
28
|
+
for k, v in methods.items():
|
|
29
|
+
if isinstance(v, Descriptor):
|
|
30
|
+
ns= getattr(v, 'namespace', None)
|
|
31
|
+
if ns:
|
|
32
|
+
namespaced.append((k, "{%s}%s" % (ns, k)))
|
|
33
|
+
if getattr(v, 'nested', False):
|
|
34
|
+
nested.append(k)
|
|
35
|
+
elements.append(k)
|
|
36
|
+
elif isinstance(v, Sequence):
|
|
37
|
+
elements.append(k)
|
|
38
|
+
elif isinstance(v, Typed):
|
|
39
|
+
if hasattr(v.expected_type, 'to_tree'):
|
|
40
|
+
elements.append(k)
|
|
41
|
+
elif isinstance(v.expected_type, tuple):
|
|
42
|
+
if any((hasattr(el, "to_tree") for el in v.expected_type)):
|
|
43
|
+
# don't bind elements as attrs
|
|
44
|
+
continue
|
|
45
|
+
else:
|
|
46
|
+
attrs.append(k)
|
|
47
|
+
else:
|
|
48
|
+
if not isinstance(v, Alias):
|
|
49
|
+
attrs.append(k)
|
|
50
|
+
|
|
51
|
+
if methods.get('__attrs__') is None:
|
|
52
|
+
methods['__attrs__'] = tuple(attrs)
|
|
53
|
+
methods['__namespaced__'] = tuple(namespaced)
|
|
54
|
+
if methods.get('__nested__') is None:
|
|
55
|
+
methods['__nested__'] = tuple(sorted(nested))
|
|
56
|
+
if methods.get('__elements__') is None:
|
|
57
|
+
methods['__elements__'] = tuple(sorted(elements))
|
|
58
|
+
return MetaStrict.__new__(cls, clsname, bases, methods)
|