This interactive environment copies the free, open-source XULE plugin to a working Python environment with Arelle 2.2.0 (plus dependencies). Click the code cell below (gray background) to bring it in focus, then click the run button above to add and confirm XULE is ready. The asterisk to the left of the cell indicates the cell is queued/processing.
The commented sys.executable commands in the cell can be used to modify the installed version of Arelle. Remove the "#" at the head of one of the lines and re-run the cell. Remove the # from the corresponding Arelle command below to get information about Arelle.
import os, sys, site, platform
#!{sys.executable} -m pip -q install arelle-release==2.2.0 # Arelle version used by this Jupyter notebook
#!{sys.executable} -m pip -q install git+https://git@github.com/Arelle/arelle.git@master # Arelle development release
#!arelleCmdLine -a
# 1) locate Arelle's plugin directory (do not modify this location)
plugindir = site.getsitepackages()[0] + '/arelle/plugin/'
os.chdir(plugindir)
print('In this Python ' + platform.python_version() + ' environment, Arelle\'s plugin directory is: \n' + plugindir + '\nAn activation message appears below when the environment is ready.')
# 2) copy XULE from GitHub to plugin directory
!svn export --force --quiet https://github.com/xbrlus/xule/trunk/plugin/xule xule
# 3) confirm XULE (change -v to -h and re-run to see help contents for Arelle and XULE)
!arelleCmdLine --plugins 'xule' -v
The cell below is the contents of a XULE 'file' called sample.xule which starts on the line below %%writefile - a Jupyter-specific command that saves the cell's contents as a file when the cell is run.
Click the code cell below then use 'Run All Below' from Jupyter's Cell menu to save and run XULE with a single click (NB: after the cell is run once, toggling %%writefile to %load will display the contents of the sample.xule file in the cell).
%%writefile 'sample.xule'
/** add constants and namespaces below **/
/** modify rule below **/
output example
{@}
The cell below compiles the sample.xule file and runs the .zip against the instance document listed in the command (NB: run the first code cell in this notebook with the -h switch instead of -v to get configuration paramters for the command).
!arelleCmdLine -f "https://www.sec.gov/Archives/edgar/data/1753673/000121390022027184/f20f2021_scienjoyhold.htm" --plugins "xule | transforms/SEC" --xule-compile "sample.xule" --xule-run --xule-rule-set "sample.zip" --httpUserAgent "XULE-Arelle (xbrl.us; support@xbrl.us)" --logFormat="[%(messageCode)s] %(message)s"
Any [example] details listed above were found in the report ('example' is the default name of the output in the sample.xule file above). Modify and re-run the 1. Define and 2. Run cells, or change and re-run the report in the 2. Run cell to get different results.