Generated documentation, of the gitHub source code API, is available at: API Documentation.
The Python API requires a Controller (subclass of Cntlr.py) to initiate modelManager operations. The controller must have two feedback methods, addToLog (for messages) and showStatus(for status messages if they are desired). CntlrCmdLine.py will be explained to demonstrate the minimum API:
modelManager = ModelManager.initialize(self)
Initializes the model manager, and provides the calling instance (self), needed for the callbacks to addToLog and showStatus.
filesource = FileSource.FileSource(“c:\test\abc.xsd”)
A filesource instance is a wrapper for files that may be ordinary files or zip/xfd/frm archive files. If the file is not an archive, the filesource just retains the file path, but if it is an archive, then contents of the archive (such as an instance document to read first) can be specified by the filesource.select(“instance.xml”) method.
Select calculation linkbase checks, inferring decimals, to be performed by validate operation.
Select calculation linkbase checks, inferring precision, to be performed by validate operation.
modelManager.validateDisclosureSystem = True
Used to inform the modelManager when Disclosure System rules validation (such as U.S. SEC Edgar or Japan FSA) is desired. Must be set before loading an entry point document. Edgar Filing Manual and Global Filing Manual are currently implemented.
Used to select which disclosure system rules to apply (e.g., U.S. SEC Edgar, Japan FSA). The parameter must match one of the disclosure system names in the file lib/disclosuresystems.xml. For example, the file entry names=”Japan FSA|jp-fsa|fsa” means that any of the these three name alternatives would specify the Japan FSA rule set.
Select Unit Type Registry validation is to be performed by the validate operation.
modelManager.load(filesource, “subsequent action”)
Asks the modelManager to load the entry point specified by the filesource. If successful, the prompt specified by the second argument will be displayed to the showStatus callback method.
Performs validation applicable to the entry point (including that specified by the validateSEC option, if entry file is an instance or DTS). Any errors and other messages are provided to the addToLog callback method.
Closes the last-opened entry point and releases resources.
To compare two DTSes and produce a versioning report, please replace modelManager.validate(), above, with these:
modelManager.load(diffFilesource, _(“views loading”))
The first .load represents the fromDTS, the second .load represents the toDTS. The file name provided by compareDTSes is that used to save the versioning report.
Note that two entries were loaded, so there should be two modelManager.close() calls, which act in LIFO manner to close the corresponding .load()’ed entry.
There are several excellent Python-based development environments. Many XBRL practitioners have spent their lives with Java; they can use Eclipse, configured for Python (pydev), which is compatible with Arelle.