arelle-release 2.37.47__py3-none-any.whl → 2.37.49__py3-none-any.whl
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.
Potentially problematic release.
This version of arelle-release might be problematic. Click here for more details.
- arelle/CntlrCmdLine.py +5 -1
- arelle/ModelObjectFactory.py +18 -2
- arelle/_version.py +2 -2
- arelle/plugin/validate/EDINET/Constants.py +6 -0
- arelle/plugin/validate/EDINET/PluginValidationDataExtension.py +134 -7
- arelle/plugin/validate/EDINET/Statement.py +139 -0
- arelle/plugin/validate/EDINET/rules/contexts.py +5 -10
- arelle/plugin/validate/EDINET/rules/edinet.py +89 -51
- arelle/plugin/validate/EDINET/rules/gfm.py +41 -0
- {arelle_release-2.37.47.dist-info → arelle_release-2.37.49.dist-info}/METADATA +3 -1
- {arelle_release-2.37.47.dist-info → arelle_release-2.37.49.dist-info}/RECORD +15 -99
- arelle/archive/CustomLogger.py +0 -43
- arelle/archive/LoadEFMvalidate.py +0 -32
- arelle/archive/LoadSavePreLbCsv.py +0 -26
- arelle/archive/LoadValidate.cs +0 -31
- arelle/archive/LoadValidate.py +0 -36
- arelle/archive/LoadValidateCmdLine.java +0 -69
- arelle/archive/LoadValidatePostedZip.java +0 -57
- arelle/archive/LoadValidateWebService.java +0 -34
- arelle/archive/SaveTableToExelle.py +0 -140
- arelle/archive/TR3toTR4.py +0 -88
- arelle/archive/plugin/ESEF_2022/__init__.py +0 -47
- arelle/archive/plugin/bigInstance.py +0 -394
- arelle/archive/plugin/cmdWebServerExtension.py +0 -43
- arelle/archive/plugin/crashTest.py +0 -38
- arelle/archive/plugin/functionsXmlCreation.py +0 -106
- arelle/archive/plugin/hello_i18n.pot +0 -26
- arelle/archive/plugin/hello_i18n.py +0 -32
- arelle/archive/plugin/importTestChild1.py +0 -21
- arelle/archive/plugin/importTestChild2.py +0 -22
- arelle/archive/plugin/importTestGrandchild1.py +0 -21
- arelle/archive/plugin/importTestGrandchild2.py +0 -21
- arelle/archive/plugin/importTestImported1.py +0 -23
- arelle/archive/plugin/importTestImported11.py +0 -22
- arelle/archive/plugin/importTestParent.py +0 -48
- arelle/archive/plugin/instanceInfo.py +0 -306
- arelle/archive/plugin/loadFromOIM-2018.py +0 -1282
- arelle/archive/plugin/locale/fr/LC_MESSAGES/hello_i18n.po +0 -25
- arelle/archive/plugin/objectmaker.py +0 -285
- arelle/archive/plugin/packagedImportTest/__init__.py +0 -47
- arelle/archive/plugin/packagedImportTest/importTestChild1.py +0 -21
- arelle/archive/plugin/packagedImportTest/importTestChild2.py +0 -22
- arelle/archive/plugin/packagedImportTest/importTestGrandchild1.py +0 -21
- arelle/archive/plugin/packagedImportTest/importTestGrandchild2.py +0 -21
- arelle/archive/plugin/packagedImportTest/importTestImported1.py +0 -24
- arelle/archive/plugin/packagedImportTest/importTestImported11.py +0 -21
- arelle/archive/plugin/packagedImportTest/subdir/importTestImported111.py +0 -21
- arelle/archive/plugin/packagedImportTest/subdir/subsubdir/importTestImported1111.py +0 -21
- arelle/archive/plugin/sakaCalendar.py +0 -215
- arelle/archive/plugin/saveInstanceInfoset.py +0 -121
- arelle/archive/plugin/sphinx/FormulaGenerator.py +0 -823
- arelle/archive/plugin/sphinx/SphinxContext.py +0 -404
- arelle/archive/plugin/sphinx/SphinxEvaluator.py +0 -783
- arelle/archive/plugin/sphinx/SphinxMethods.py +0 -1287
- arelle/archive/plugin/sphinx/SphinxParser.py +0 -1093
- arelle/archive/plugin/sphinx/SphinxValidator.py +0 -163
- arelle/archive/plugin/sphinx/US-GAAP Ratios Example.xsr +0 -52
- arelle/archive/plugin/sphinx/__init__.py +0 -285
- arelle/archive/plugin/streamingExtensions.py +0 -335
- arelle/archive/plugin/updateTableLB.py +0 -242
- arelle/archive/plugin/validate/SBRnl/CustomLoader.py +0 -19
- arelle/archive/plugin/validate/SBRnl/DTS.py +0 -305
- arelle/archive/plugin/validate/SBRnl/Dimensions.py +0 -357
- arelle/archive/plugin/validate/SBRnl/Document.py +0 -799
- arelle/archive/plugin/validate/SBRnl/Filing.py +0 -467
- arelle/archive/plugin/validate/SBRnl/__init__.py +0 -75
- arelle/archive/plugin/validate/SBRnl/config.xml +0 -26
- arelle/archive/plugin/validate/SBRnl/sbr-nl-taxonomies.xml +0 -754
- arelle/archive/plugin/validate/USBestPractices.py +0 -570
- arelle/archive/plugin/validate/USCorpAction.py +0 -557
- arelle/archive/plugin/validate/USSecTagging.py +0 -337
- arelle/archive/plugin/validate/XDC/__init__.py +0 -77
- arelle/archive/plugin/validate/XDC/config.xml +0 -20
- arelle/archive/plugin/validate/XFsyntax/__init__.py +0 -64
- arelle/archive/plugin/validate/XFsyntax/xf.py +0 -2227
- arelle/archive/plugin/validate/calc2.py +0 -536
- arelle/archive/plugin/validateSchemaLxml.py +0 -156
- arelle/archive/plugin/validateTableInfoset.py +0 -52
- arelle/archive/us-gaap-dei-docType-extraction-frm.xml +0 -90
- arelle/archive/us-gaap-dei-ratio-cash-frm.xml +0 -150
- arelle/examples/plugin/formulaSuiteConverter.py +0 -212
- arelle/examples/plugin/functionsCustom.py +0 -59
- arelle/examples/plugin/hello_dolly.py +0 -64
- arelle/examples/plugin/multi.py +0 -58
- arelle/examples/plugin/rssSaveOim.py +0 -96
- arelle/examples/plugin/validate/XYZ/DisclosureSystems.py +0 -2
- arelle/examples/plugin/validate/XYZ/PluginValidationDataExtension.py +0 -10
- arelle/examples/plugin/validate/XYZ/ValidationPluginExtension.py +0 -50
- arelle/examples/plugin/validate/XYZ/__init__.py +0 -75
- arelle/examples/plugin/validate/XYZ/resources/config.xml +0 -16
- arelle/examples/plugin/validate/XYZ/rules/__init__.py +0 -0
- arelle/examples/plugin/validate/XYZ/rules/rules01.py +0 -110
- arelle/examples/plugin/validate/XYZ/rules/rules02.py +0 -59
- arelle/scripts-macOS/startWebServer.command +0 -3
- arelle/scripts-unix/startWebServer.sh +0 -1
- arelle/scripts-windows/startWebServer.bat +0 -5
- {arelle_release-2.37.47.dist-info → arelle_release-2.37.49.dist-info}/WHEEL +0 -0
- {arelle_release-2.37.47.dist-info → arelle_release-2.37.49.dist-info}/entry_points.txt +0 -0
- {arelle_release-2.37.47.dist-info → arelle_release-2.37.49.dist-info}/licenses/LICENSE.md +0 -0
- {arelle_release-2.37.47.dist-info → arelle_release-2.37.49.dist-info}/top_level.txt +0 -0
|
@@ -1,163 +0,0 @@
|
|
|
1
|
-
'''
|
|
2
|
-
sphinxValidator validates Sphinx language expressions in the context of an XBRL DTS and instance.
|
|
3
|
-
|
|
4
|
-
See COPYRIGHT.md for copyright information.
|
|
5
|
-
|
|
6
|
-
Sphinx is a Rules Language for XBRL described by a Sphinx 2 Primer
|
|
7
|
-
(c) Copyright 2012 CoreFiling, Oxford UK.
|
|
8
|
-
Sphinx copyright applies to the Sphinx language, not to this software.
|
|
9
|
-
Workiva, Inc. conveys neither rights nor license for the Sphinx language.
|
|
10
|
-
'''
|
|
11
|
-
|
|
12
|
-
from arelle.ModelValue import QName
|
|
13
|
-
from .SphinxParser import (astBinaryOperation, astSourceFile, astNamespaceDeclaration, astRuleBasePrecondition,
|
|
14
|
-
astConstant, astNamespaceDeclaration, astStringLiteral,
|
|
15
|
-
astHyperspaceExpression, astHyperspaceAxis,
|
|
16
|
-
astFunctionDeclaration, astFunctionReference, astNode,
|
|
17
|
-
astPreconditionDeclaration, astPreconditionReference,
|
|
18
|
-
astFormulaRule, astReportRule, astValidationRule, astWith,
|
|
19
|
-
namedAxes
|
|
20
|
-
)
|
|
21
|
-
|
|
22
|
-
def validate(logMessage, sphinxContext):
|
|
23
|
-
modelXbrl = sphinxContext.modelXbrl
|
|
24
|
-
hasDTS = modelXbrl is not None
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
if hasDTS:
|
|
28
|
-
# if no formulas loaded, set
|
|
29
|
-
if not hasattr(modelXbrl, "modelFormulaEqualityDefinitions"):
|
|
30
|
-
modelXbrl.modelFormulaEqualityDefinitions = {}
|
|
31
|
-
|
|
32
|
-
import logging
|
|
33
|
-
initialErrorCount = modelXbrl.logCount.get(logging._checkLevel('ERROR'), 0)
|
|
34
|
-
|
|
35
|
-
# must also have default dimensions loaded
|
|
36
|
-
from arelle import ValidateXbrlDimensions
|
|
37
|
-
ValidateXbrlDimensions.loadDimensionDefaults(modelXbrl)
|
|
38
|
-
|
|
39
|
-
sphinxContext.ruleBasePreconditionNodes = []
|
|
40
|
-
sphinxContext.preconditionNodes = {}
|
|
41
|
-
|
|
42
|
-
# accumulate definitions
|
|
43
|
-
for prog in sphinxContext.sphinxProgs:
|
|
44
|
-
for node in prog:
|
|
45
|
-
if isinstance(node, astRuleBasePrecondition):
|
|
46
|
-
sphinxContext.ruleBasePreconditionNodes.append(node)
|
|
47
|
-
elif isinstance(node, astPreconditionDeclaration):
|
|
48
|
-
sphinxContext.preconditionNodes[node.name] = node
|
|
49
|
-
elif isinstance(node, astFunctionDeclaration):
|
|
50
|
-
sphinxContext.functions[node.name] = node
|
|
51
|
-
elif isinstance(node, astConstant):
|
|
52
|
-
sphinxContext.constants[node.constantName] = node
|
|
53
|
-
node.value = None # compute dynamically on first reference
|
|
54
|
-
if node.tagName:
|
|
55
|
-
sphinxContext.taggedConstants[node.tagName] = node
|
|
56
|
-
|
|
57
|
-
# check references
|
|
58
|
-
def checkNodes(nodes, inMacro=False):
|
|
59
|
-
if not nodes: return
|
|
60
|
-
for node in nodes:
|
|
61
|
-
if node is None:
|
|
62
|
-
continue
|
|
63
|
-
elif isinstance(node, (list,set)):
|
|
64
|
-
checkNodes(node, inMacro)
|
|
65
|
-
elif isinstance(node, astPreconditionReference):
|
|
66
|
-
for name in node.names:
|
|
67
|
-
if name not in sphinxContext.preconditionNodes:
|
|
68
|
-
logMessage("ERROR", "sphinxCompiler:preconditionReferenceI",
|
|
69
|
-
_("Precondition reference is not defined %(name)s"),
|
|
70
|
-
sourceFileLine=node.sourceFileLine,
|
|
71
|
-
name=name)
|
|
72
|
-
elif isinstance(node, (astFormulaRule, astReportRule, astValidationRule)):
|
|
73
|
-
checkNodes((node.precondition, node.severity,
|
|
74
|
-
node.variableAssignments,
|
|
75
|
-
node.expr, node.message), inMacro)
|
|
76
|
-
sphinxContext.rules.append(node)
|
|
77
|
-
if node.severity:
|
|
78
|
-
severity = node.severity
|
|
79
|
-
if isinstance(severity, astFunctionReference):
|
|
80
|
-
severity = severity.name
|
|
81
|
-
if (severity not in ("error", "warning", "info") and
|
|
82
|
-
(isinstance(node, astFormulaRule) and severity not in sphinxContext.functions)):
|
|
83
|
-
logMessage("ERROR", "sphinxCompiler:ruleSeverity",
|
|
84
|
-
_("Rule %(name)s severity is not recognized: %(severity)s"),
|
|
85
|
-
sourceFileLine=node.sourceFileLine,
|
|
86
|
-
name=node.name,
|
|
87
|
-
severity=node.severity)
|
|
88
|
-
if isinstance(node, astFormulaRule) and not hasFormulaOp(node):
|
|
89
|
-
logMessage("ERROR", "sphinxCompiler:formulaSyntax",
|
|
90
|
-
_("Formula %(name)s missing \":=\" operation"),
|
|
91
|
-
sourceFileLine=node.sourceFileLine,
|
|
92
|
-
name=node.name)
|
|
93
|
-
elif isinstance(node, astHyperspaceExpression) and hasDTS:
|
|
94
|
-
# check axes
|
|
95
|
-
for axis in node.axes:
|
|
96
|
-
if isinstance(axis.aspect, QName):
|
|
97
|
-
concept = modelXbrl.qnameConcepts.get(axis)
|
|
98
|
-
if concept is None or not concept.isDimensionItem:
|
|
99
|
-
logMessage("ERROR", "sphinxCompiler:axisNotDimension",
|
|
100
|
-
_("Axis is not a dimension in the DTS %(qname)s"),
|
|
101
|
-
sourceFileLine=node.sourceFileLine,
|
|
102
|
-
qname=axis)
|
|
103
|
-
elif axis not in sphinxContext.dimensionIsExplicit:
|
|
104
|
-
sphinxContext.dimensionIsExplicit[axis] = concept.isExplicitDimension
|
|
105
|
-
elif isinstance(axis.aspect, astNode):
|
|
106
|
-
if not inMacro:
|
|
107
|
-
logMessage("ERROR", "sphinxCompiler:axisDisallowed",
|
|
108
|
-
_("Hypercube axis aspect not static %(aspect)s"),
|
|
109
|
-
sourceFileLine=node.sourceFileLine,
|
|
110
|
-
aspect=axis.aspect)
|
|
111
|
-
elif (axis.aspect not in {"unit", "segment", "scenario"} and
|
|
112
|
-
isinstance(axis.restriction, (list, tuple))):
|
|
113
|
-
for restrictionValue in axis.restriction:
|
|
114
|
-
if isinstance(restrictionValue, QName) and not restrictionValue in modelXbrl.qnameConcepts:
|
|
115
|
-
logMessage("ERROR", "sphinxCompiler:axisNotDimension",
|
|
116
|
-
_("Hypercube value not in the DTS %(qname)s"),
|
|
117
|
-
sourceFileLine=node.sourceFileLine,
|
|
118
|
-
qname=restrictionValue)
|
|
119
|
-
checkNodes((axis.whereExpr,), inMacro)
|
|
120
|
-
elif isinstance(node, astWith):
|
|
121
|
-
node.axes = {}
|
|
122
|
-
def checkWithAxes(withNode):
|
|
123
|
-
if isinstance(withNode, astHyperspaceExpression):
|
|
124
|
-
checkNodes((withNode,), inMacro)
|
|
125
|
-
node.axes.update(withNode.axes)
|
|
126
|
-
else:
|
|
127
|
-
logMessage("ERROR", "sphinxCompiler:withRestrictionError",
|
|
128
|
-
_("With restriction is not a single hyperspace expression"),
|
|
129
|
-
sourceFileLine=withNode.sourceFileLine)
|
|
130
|
-
checkWithAxes(node.restrictionExpr)
|
|
131
|
-
checkNodes((node.variableAssignments, node.bodyExpr,), inMacro)
|
|
132
|
-
elif isinstance(node, astNode):
|
|
133
|
-
nestedMacro = inMacro or (isinstance(node, astFunctionDeclaration) and
|
|
134
|
-
node.functionType == "macro")
|
|
135
|
-
checkNodes([expr
|
|
136
|
-
for expr in node.__dict__.values()
|
|
137
|
-
if isinstance(expr, (astNode, list, set))],
|
|
138
|
-
nestedMacro)
|
|
139
|
-
|
|
140
|
-
for prog in sphinxContext.sphinxProgs:
|
|
141
|
-
checkNodes(prog)
|
|
142
|
-
|
|
143
|
-
if len(sphinxContext.ruleBasePreconditionNodes) > 1:
|
|
144
|
-
logMessage("ERROR", "sphinxCompiler:multipleRuleBaseDeclarations",
|
|
145
|
-
_("Multiple rule-base declarations %(preconditions)s"),
|
|
146
|
-
sourceFileLines=[node.sourceFileLine for node in sphinxContext.ruleBasePreconditionNodes],
|
|
147
|
-
preconditions=", ".join(str(r) for r in sphinxContext.ruleBasePreconditionNodes))
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
if hasDTS:
|
|
151
|
-
# if no errors in checking sphinx
|
|
152
|
-
if initialErrorCount == modelXbrl.logCount.get(logging._checkLevel('ERROR'), 0):
|
|
153
|
-
from .SphinxEvaluator import evaluateRuleBase
|
|
154
|
-
evaluateRuleBase(sphinxContext)
|
|
155
|
-
|
|
156
|
-
def hasFormulaOp(node):
|
|
157
|
-
if isinstance(node, astBinaryOperation) and node.op == ":=":
|
|
158
|
-
return True
|
|
159
|
-
for exprName in ("expr", "leftExpr", "rightExpr", "bodyExpr"):
|
|
160
|
-
if hasattr(node,exprName):
|
|
161
|
-
if hasFormulaOp( getattr(node, exprName) ):
|
|
162
|
-
return True
|
|
163
|
-
return False
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* This file is part of the XBRL-US ratios.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
xmlns:dei="http://xbrl.sec.gov/dei/2012-01-31"
|
|
6
|
-
xmlns="http://fasb.org/us-gaap/2012-01-31"
|
|
7
|
-
|
|
8
|
-
/*
|
|
9
|
-
* References on XBRL-US Ratios:
|
|
10
|
-
* (1) http://web.ku.edu/~eycarat/myssi/_pdf/2-Debreceny-XBRL%20Ratios%2020101213.pdf
|
|
11
|
-
* Debreceney, et al, 2011 KU XBRL Conference
|
|
12
|
-
* (2) http://www.xbrlsite.com/Demos/Ontologies/2011-04-15/US-GAAP-KeyRatios.xml
|
|
13
|
-
* Hoffman, C, 2009
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
report EntityRegistrantName
|
|
17
|
-
dei:EntityRegistrantName[]
|
|
18
|
-
|
|
19
|
-
report DocumentType
|
|
20
|
-
dei:DocumentType[]
|
|
21
|
-
|
|
22
|
-
report DocumentPeriodEndDate
|
|
23
|
-
dei:DocumentPeriodEndDate[]
|
|
24
|
-
|
|
25
|
-
report CurrentRatio
|
|
26
|
-
AssetsCurrent[] / LiabilitiesCurrent[]
|
|
27
|
-
|
|
28
|
-
report WorkingCapital
|
|
29
|
-
AssetsCurrent[] - LiabilitiesCurrent[]
|
|
30
|
-
|
|
31
|
-
report CashRatio
|
|
32
|
-
(CashAndCashEquivalentsAtCarryingValue[] +
|
|
33
|
-
MarketableSecuritiesCurrent[]) /
|
|
34
|
-
LiabilitiesCurrent[]
|
|
35
|
-
|
|
36
|
-
report DebtEquity
|
|
37
|
-
(LiabilitiesCurrent[] + AccountsPayableInterestBearingNoncurrent[]) /
|
|
38
|
-
(AssetsCurrent[] + LiabilitiesCurrent[])
|
|
39
|
-
|
|
40
|
-
report ReturnOnEquity
|
|
41
|
-
ROE = NetIncomeLoss[];
|
|
42
|
-
$ROE /
|
|
43
|
-
(AssetsCurrent[period=$ROE::period::end-date] +
|
|
44
|
-
LiabilitiesCurrent[period=$ROE::period::end-date])
|
|
45
|
-
|
|
46
|
-
report SalesToAccountsReceivable
|
|
47
|
-
Revenue = NetIncomeLoss[];
|
|
48
|
-
$Revenue / AccountsReceivableNetCurrent[period=$Revenue::period::end-date]
|
|
49
|
-
|
|
50
|
-
report SalesToFixedAssets
|
|
51
|
-
Revenue = NetIncomeLoss[];
|
|
52
|
-
$Revenue / PropertyPlantAndEquipmentNet[period=$Revenue::period::end-date]
|
|
@@ -1,285 +0,0 @@
|
|
|
1
|
-
'''
|
|
2
|
-
sphinx is an example of a package plug-in to both GUI menu and command line/web service
|
|
3
|
-
that compiles a Sphinx Rules file into an XBRL Formula Linkbase either to be saved or to
|
|
4
|
-
be directly executed by Arelle XBRL Formula processing.
|
|
5
|
-
|
|
6
|
-
This plug-in is a python package, and can be loaded by referencing the containing
|
|
7
|
-
directory (usually, "sphinx"), and selecting this "__init__.py" file within the sphinx
|
|
8
|
-
directory (such as in a file chooser).
|
|
9
|
-
|
|
10
|
-
See COPYRIGHT.md for copyright information.
|
|
11
|
-
|
|
12
|
-
Sphinx is a Rules Language for XBRL described by a Sphinx 2 Primer
|
|
13
|
-
(c) Copyright 2012 CoreFiling, Oxford UK.
|
|
14
|
-
Sphinx copyright applies to the Sphinx language, not to this software.
|
|
15
|
-
Workiva, Inc. conveys neither rights nor license for the Sphinx language.
|
|
16
|
-
'''
|
|
17
|
-
|
|
18
|
-
import time, os, io, sys
|
|
19
|
-
from arelle.ModelValue import qname
|
|
20
|
-
from arelle import XmlUtil
|
|
21
|
-
from arelle.Version import authorLabel, copyrightLabel
|
|
22
|
-
|
|
23
|
-
logMessage = None
|
|
24
|
-
|
|
25
|
-
def sphinxFilesDialog(cntlr):
|
|
26
|
-
# get multiple file names of the sphinx files
|
|
27
|
-
sphinxFiles = cntlr.uiFileDialog("open",
|
|
28
|
-
multiple=True, # expect multiple sphinx files
|
|
29
|
-
title=_("arelle - Open sphinx rules files"),
|
|
30
|
-
initialdir=cntlr.config.setdefault("sphinxRulesFileDir","."),
|
|
31
|
-
filetypes=[(_("Sphinx files .xsr"), "*.xsr"), (_("Sphinx archives .xrb"), "*.xrb")],
|
|
32
|
-
defaultextension=".xsr")
|
|
33
|
-
if not sphinxFiles:
|
|
34
|
-
return None
|
|
35
|
-
cntlr.config["sphinxRulesFileDir"] = os.path.dirname(sphinxFiles[0])
|
|
36
|
-
cntlr.saveConfig()
|
|
37
|
-
return sphinxFiles
|
|
38
|
-
|
|
39
|
-
def generatedFormulasDirDialog(cntlr):
|
|
40
|
-
from tkinter.filedialog import askdirectory
|
|
41
|
-
generatedFormulasDir = askdirectory(parent=cntlr.parent,
|
|
42
|
-
initialdir=cntlr.config.setdefault("sphinxGeneratedFormulasDir","."),
|
|
43
|
-
title='Please select a directory for formulas generated from sphinx')
|
|
44
|
-
cntlr.config["sphinxGeneratedFormulasDir"] = generatedFormulasDir
|
|
45
|
-
cntlr.saveConfig()
|
|
46
|
-
return generatedFormulasDir
|
|
47
|
-
|
|
48
|
-
def sphinxFilesOpenMenuEntender(cntlr, menu, *args, **kwargs):
|
|
49
|
-
|
|
50
|
-
def sphinxFileMenuCommand():
|
|
51
|
-
from arelle import ModelDocument
|
|
52
|
-
import os, sys, traceback
|
|
53
|
-
if not cntlr.modelManager.modelXbrl or cntlr.modelManager.modelXbrl.modelDocument.type not in (
|
|
54
|
-
ModelDocument.Type.SCHEMA, ModelDocument.Type.LINKBASE, ModelDocument.Type.INSTANCE, ModelDocument.Type.INLINEXBRL):
|
|
55
|
-
import tkinter.messagebox
|
|
56
|
-
tkinter.messagebox.showwarning(_("arelle - Warning"),
|
|
57
|
-
_("Import requires an opened DTS"), parent=cntlr.parent)
|
|
58
|
-
return False
|
|
59
|
-
modelXbrl = cntlr.modelManager.modelXbrl
|
|
60
|
-
sphinxFiles = sphinxFilesDialog(cntlr)
|
|
61
|
-
if not sphinxFiles:
|
|
62
|
-
return False
|
|
63
|
-
def backgroundParseSphinxFiles():
|
|
64
|
-
try:
|
|
65
|
-
from .SphinxParser import parse
|
|
66
|
-
sphinxProgs = parse(cntlr, modelXbrl.log, sphinxFiles)
|
|
67
|
-
try:
|
|
68
|
-
modelXbrl.sphinxContext.sphinxProgs.update(sphinxProgs) # add to previously loaded progs
|
|
69
|
-
except AttributeError:
|
|
70
|
-
from .SphinxContext import SphinxContext
|
|
71
|
-
modelXbrl.sphinxContext = SphinxContext(sphinxProgs, modelXbrl) # first sphinxProgs for DTS
|
|
72
|
-
except Exception as ex:
|
|
73
|
-
cntlr.addToLog(
|
|
74
|
-
_("[exception] Sphinx Compiling Exception: %(error)s \n%(traceback)s") %
|
|
75
|
-
{"error": ex,
|
|
76
|
-
"exc_info": True,
|
|
77
|
-
"traceback": traceback.format_tb(sys.exc_info()[2])})
|
|
78
|
-
import threading
|
|
79
|
-
thread = threading.Thread(target=backgroundParseSphinxFiles)
|
|
80
|
-
thread.daemon = True
|
|
81
|
-
thread.start()
|
|
82
|
-
|
|
83
|
-
# Extend menu with an item for the savedts plugin
|
|
84
|
-
menu.add_command(label="Import Sphinx files...",
|
|
85
|
-
underline=0,
|
|
86
|
-
command=sphinxFileMenuCommand)
|
|
87
|
-
|
|
88
|
-
def sphinxToLBMenuEntender(cntlr, menu, *args, **kwargs):
|
|
89
|
-
|
|
90
|
-
def sphinxToLBMenuCommand():
|
|
91
|
-
import os, sys, traceback
|
|
92
|
-
from .FormulaGenerator import generateFormulaLB
|
|
93
|
-
|
|
94
|
-
sphinxFiles = sphinxFilesDialog(cntlr)
|
|
95
|
-
if not sphinxFiles:
|
|
96
|
-
return False
|
|
97
|
-
generatedFormulasDir = generatedFormulasDirDialog(cntlr)
|
|
98
|
-
if not generatedFormulasDir:
|
|
99
|
-
return False
|
|
100
|
-
|
|
101
|
-
def backgroundSphinxGenerateFormula():
|
|
102
|
-
try:
|
|
103
|
-
generateFormulaLB(cntlr, sphinxFiles, generatedFormulasDir)
|
|
104
|
-
except Exception as ex:
|
|
105
|
-
cntlr.addToLog(
|
|
106
|
-
_("[exception] Sphinx Compiling Exception: %(error)s \n%(traceback)s") %
|
|
107
|
-
{"error": ex,
|
|
108
|
-
"exc_info": True,
|
|
109
|
-
"traceback": traceback.format_tb(sys.exc_info()[2])})
|
|
110
|
-
import threading
|
|
111
|
-
thread = threading.Thread(target=backgroundSphinxGenerateFormula)
|
|
112
|
-
thread.daemon = True
|
|
113
|
-
thread.start()
|
|
114
|
-
|
|
115
|
-
# Extend menu with an item for the savedts plugin
|
|
116
|
-
menu.add_command(label="Compile Sphinx to Formula",
|
|
117
|
-
underline=0,
|
|
118
|
-
command=sphinxToLBMenuCommand)
|
|
119
|
-
|
|
120
|
-
def sphinxToLBCommandLineOptionExtender(parser, *args, **kwargs):
|
|
121
|
-
# extend command line options to import sphinx files into DTS for validation
|
|
122
|
-
parser.add_option("--import-sphinx",
|
|
123
|
-
action="store",
|
|
124
|
-
dest="sphinxFilesForValidation",
|
|
125
|
-
help=_("Import sphinx files to the DTS for validation. "
|
|
126
|
-
"Multiple file names are separated by a '|' character. "))
|
|
127
|
-
|
|
128
|
-
# extend command line options with a generate sphinx into formula linkbase option
|
|
129
|
-
parser.add_option("--generate-sphinx-formula-linkbase",
|
|
130
|
-
action="store",
|
|
131
|
-
dest="sphinxFilesForFormulaLinkbase",
|
|
132
|
-
help=_("Generate an XBRL formula linkbase from sphinx files. "
|
|
133
|
-
"Multiple file names are separated by a '|' character. "
|
|
134
|
-
"Files may be xrb archives, xsr source files, or directories of same. "))
|
|
135
|
-
parser.add_option("--generated-sphinx-formulas-directory",
|
|
136
|
-
action="store",
|
|
137
|
-
dest="generatedSphinxFormulasDirectory",
|
|
138
|
-
help=_("Generated XBRL formula linkbases directory. "
|
|
139
|
-
"(If absent, formula linkbases save in sphinx files directory.) "))
|
|
140
|
-
|
|
141
|
-
def sphinxToLBCommandLineUtilityRun(cntlr, options, *args, **kwargs):
|
|
142
|
-
# extend XBRL-loaded run processing for this option
|
|
143
|
-
if getattr(options, "sphinxFilesForFormulaLinkbase", None):
|
|
144
|
-
from .FormulaGenerator import generateFormulaLB
|
|
145
|
-
generateFormulaLB(cntlr,
|
|
146
|
-
options.sphinxFilesForFormulaLinkbase.split("|"),
|
|
147
|
-
options.generatedSphinxFormulasDirectory)
|
|
148
|
-
|
|
149
|
-
def sphinxCommandLineLoader(cntlr, options, modelXbrl, *args, **kwargs):
|
|
150
|
-
# DTS loaded, add in sphinx files if any
|
|
151
|
-
if getattr(options, "sphinxFilesForValidation", None):
|
|
152
|
-
from .SphinxParser import parse
|
|
153
|
-
from .SphinxContext import SphinxContext
|
|
154
|
-
sphinxProgs = parse(cntlr, modelXbrl.log, options.sphinxFilesForValidation.split('|'))
|
|
155
|
-
modelXbrl.sphinxContext = SphinxContext(sphinxProgs, modelXbrl)
|
|
156
|
-
|
|
157
|
-
def sphinxValidater(val, *args, **kwargs):
|
|
158
|
-
if hasattr(val.modelXbrl, "sphinxContext"):
|
|
159
|
-
# sphinx is loaded, last step in validation
|
|
160
|
-
from .SphinxValidator import validate
|
|
161
|
-
validate(val.modelXbrl.log, val.modelXbrl.sphinxContext)
|
|
162
|
-
|
|
163
|
-
def sphinxTestcaseVariationReadMeFirstUris(modelTestcaseVariation, *args, **kwargs):
|
|
164
|
-
xbrlElement = XmlUtil.descendant(modelTestcaseVariation, 'http://www.corefiling.com/sphinx-conformance-harness/2.0', "xbrl")
|
|
165
|
-
if xbrlElement is not None:
|
|
166
|
-
modelTestcaseVariation._readMeFirstUris.append(xbrlElement.textValue)
|
|
167
|
-
return True # found it
|
|
168
|
-
return False # not a sphinx test case variation
|
|
169
|
-
|
|
170
|
-
def sphinxTestcaseVariationExpectedResult(modelTestcaseVariation, *args, **kwargs):
|
|
171
|
-
issueElement = XmlUtil.descendant(modelTestcaseVariation, 'http://www.corefiling.com/sphinx-conformance-harness/2.0', "issue")
|
|
172
|
-
if issueElement is not None:
|
|
173
|
-
return issueElement.get("errorCode")
|
|
174
|
-
return None # no issue or not a sphinx test case variation
|
|
175
|
-
|
|
176
|
-
def sphinxTestcasesStart(cntlr, options, testcasesModelXbrl, *args, **kwargs):
|
|
177
|
-
if options and getattr(options, "sphinxFilesForValidation", None): # command line mode
|
|
178
|
-
testcasesModelXbrl.sphinxFilesList = options.sphinxFilesForValidation.split('|')
|
|
179
|
-
elif (cntlr.hasGui and
|
|
180
|
-
testcasesModelXbrl.modelDocument.xmlRootElement.qname.namespaceURI == 'http://www.corefiling.com/sphinx-conformance-harness/2.0' and
|
|
181
|
-
not hasattr(testcasesModelXbrl, "sphinxFilesList")):
|
|
182
|
-
testcasesModelXbrl.sphinxFilesList = sphinxFilesDialog(cntlr)
|
|
183
|
-
|
|
184
|
-
def sphinxTestcaseVariationXbrlLoaded(testcasesModelXbrl, instanceModelXbrl, *args, **kwargs):
|
|
185
|
-
# variation has been loaded, may need sphinx rules loaded if interactive
|
|
186
|
-
try:
|
|
187
|
-
sphinxFilesList = testcasesModelXbrl.sphinxFilesList
|
|
188
|
-
# load sphinx
|
|
189
|
-
from .SphinxParser import parse
|
|
190
|
-
sphinxProgs = parse(testcasesModelXbrl.modelManager.cntlr, instanceModelXbrl.log, sphinxFilesList)
|
|
191
|
-
from .SphinxContext import SphinxContext
|
|
192
|
-
instanceModelXbrl.sphinxContext = SphinxContext(sphinxProgs, instanceModelXbrl) # first sphinxProgs for DTS
|
|
193
|
-
except AttributeError:
|
|
194
|
-
pass # no sphinx
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
def sphinxTestcaseVariationExpectedSeverity(modelTestcaseVariation, *args, **kwargs):
|
|
198
|
-
issueElement = XmlUtil.descendant(modelTestcaseVariation, 'http://www.corefiling.com/sphinx-conformance-harness/2.0', "issue")
|
|
199
|
-
if issueElement is not None:
|
|
200
|
-
return issueElement.get("severity")
|
|
201
|
-
return None # no issue or not a sphinx test case variation
|
|
202
|
-
|
|
203
|
-
def sphinxDialogRssWatchFileChoices(dialog, frame, row, options, cntlr, openFileImage, openDatabaseImage, *args, **kwargs):
|
|
204
|
-
from tkinter import PhotoImage, N, S, E, W
|
|
205
|
-
try:
|
|
206
|
-
from tkinter.ttk import Button
|
|
207
|
-
except ImportError:
|
|
208
|
-
from ttk import Button
|
|
209
|
-
from arelle.CntlrWinTooltip import ToolTip
|
|
210
|
-
from arelle.UiUtil import gridCell, label
|
|
211
|
-
# add sphinx formulas to RSS dialog
|
|
212
|
-
def chooseSphinxFiles():
|
|
213
|
-
sphinxFilesList = cntlr.uiFileDialog("open",
|
|
214
|
-
multiple=True, # expect multiple sphinx files
|
|
215
|
-
title=_("arelle - Select sphinx rules file"),
|
|
216
|
-
initialdir=cntlr.config.setdefault("rssWatchSphinxRulesFilesDir","."),
|
|
217
|
-
filetypes=[(_("Sphinx files .xsr"), "*.xsr"), (_("Sphinx archives .xrb"), "*.xrb")],
|
|
218
|
-
defaultextension=".xsr")
|
|
219
|
-
if sphinxFilesList:
|
|
220
|
-
dialog.options["rssWatchSphinxRulesFilesDir"] = os.path.dirname(sphinxFilesList[0])
|
|
221
|
-
sphinxFilesPipeSeparated = '|'.join(sphinxFilesList)
|
|
222
|
-
dialog.options["sphinxRulesFiles"] = sphinxFilesPipeSeparated
|
|
223
|
-
dialog.cellSphinxFiles.setValue(sphinxFilesPipeSeparated)
|
|
224
|
-
else: # deleted
|
|
225
|
-
dialog.options.pop("sphinxRulesFiles", "") # remove entry
|
|
226
|
-
label(frame, 1, row, "Sphinx rules:")
|
|
227
|
-
dialog.cellSphinxFiles = gridCell(frame,2, row, options.get("sphinxRulesFiles",""))
|
|
228
|
-
ToolTip(dialog.cellSphinxFiles, text=_("Select a sphinx rules (file(s) or archive(s)) to to evaluate each filing. "
|
|
229
|
-
"The results are recorded in the log file. "), wraplength=240)
|
|
230
|
-
chooseFormulaFileButton = Button(frame, image=openFileImage, width=12, command=chooseSphinxFiles)
|
|
231
|
-
chooseFormulaFileButton.grid(row=row, column=3, sticky=W)
|
|
232
|
-
|
|
233
|
-
def sphinxDialogRssWatchValidateChoices(dialog, frame, row, *args, **kwargs):
|
|
234
|
-
from arelle.UiUtil import checkbox
|
|
235
|
-
dialog.checkboxes += (
|
|
236
|
-
checkbox(frame, 2, row,
|
|
237
|
-
"Sphinx rules",
|
|
238
|
-
"validateSphinxRules"),
|
|
239
|
-
)
|
|
240
|
-
|
|
241
|
-
def sphinxRssWatchHasWatchAction(rssWatchOptions, *args, **kwargs):
|
|
242
|
-
return rssWatchOptions.get("sphinxRulesFiles") and rssWatchOptions.get("validateSphinxRules")
|
|
243
|
-
|
|
244
|
-
def sphinxRssDoWatchAction(modelXbrl, rssWatchOptions, rssItem, *args, **kwargs):
|
|
245
|
-
sphinxFiles = rssWatchOptions.get("sphinxRulesFiles")
|
|
246
|
-
if sphinxFiles:
|
|
247
|
-
from .SphinxParser import parse
|
|
248
|
-
sphinxProgs = parse(modelXbrl.modelManager.cntlr, modelXbrl.log, sphinxFiles.split('|'))
|
|
249
|
-
from .SphinxContext import SphinxContext
|
|
250
|
-
modelXbrl.sphinxContext = SphinxContext(sphinxProgs, modelXbrl) # first sphinxProgs for DTS
|
|
251
|
-
# sphinx is loaded, last step in validation
|
|
252
|
-
from .SphinxValidator import validate
|
|
253
|
-
validate(modelXbrl.log, modelXbrl.sphinxContext)
|
|
254
|
-
|
|
255
|
-
# plugin changes to model object factor classes
|
|
256
|
-
from arelle.ModelTestcaseObject import ModelTestcaseVariation
|
|
257
|
-
sphinxModelObjectElementSubstitutionClasses = (
|
|
258
|
-
(qname("{http://www.corefiling.com/sphinx-conformance-harness/2.0}variation"), ModelTestcaseVariation),
|
|
259
|
-
)
|
|
260
|
-
|
|
261
|
-
__pluginInfo__ = {
|
|
262
|
-
'name': 'Sphinx 2.0 Processor',
|
|
263
|
-
'version': '0.9',
|
|
264
|
-
'description': "This plug-in provides a Sphinx 2.0 processor and a compiler (of a limited subset of Sphinx) into formula linkbase. ",
|
|
265
|
-
'license': 'Apache-2',
|
|
266
|
-
'author': authorLabel,
|
|
267
|
-
'copyright': copyrightLabel,
|
|
268
|
-
# classes of mount points (required)
|
|
269
|
-
'ModelObjectFactory.ElementSubstitutionClasses': sphinxModelObjectElementSubstitutionClasses,
|
|
270
|
-
'CntlrWinMain.Menu.File.Open': sphinxFilesOpenMenuEntender,
|
|
271
|
-
'CntlrWinMain.Menu.Tools': sphinxToLBMenuEntender,
|
|
272
|
-
'CntlrCmdLine.Options': sphinxToLBCommandLineOptionExtender,
|
|
273
|
-
'CntlrCmdLine.Utility.Run': sphinxToLBCommandLineUtilityRun,
|
|
274
|
-
'CntlrCmdLine.Xbrl.Loaded': sphinxCommandLineLoader,
|
|
275
|
-
'Validate.Finally': sphinxValidater,
|
|
276
|
-
'Testcases.Start': sphinxTestcasesStart,
|
|
277
|
-
'TestcaseVariation.Xbrl.Loaded': sphinxTestcaseVariationXbrlLoaded,
|
|
278
|
-
'ModelTestcaseVariation.ReadMeFirstUris': sphinxTestcaseVariationReadMeFirstUris,
|
|
279
|
-
'ModelTestcaseVariation.ExpectedResult': sphinxTestcaseVariationExpectedResult,
|
|
280
|
-
'ModelTestcaseVariation.ExpectedSeverity': sphinxTestcaseVariationExpectedSeverity,
|
|
281
|
-
'DialogRssWatch.FileChoices': sphinxDialogRssWatchFileChoices,
|
|
282
|
-
'DialogRssWatch.ValidateChoices': sphinxDialogRssWatchValidateChoices,
|
|
283
|
-
'RssWatch.HasWatchAction': sphinxRssWatchHasWatchAction,
|
|
284
|
-
'RssWatch.DoWatchAction': sphinxRssDoWatchAction
|
|
285
|
-
}
|