u''' Created on Feb 19, 2011 Use this module to start Arelle in command line modes @author: Mark V Systems Limited (c) Copyright 2011 Mark V Systems Limited, All rights reserved. ''' import sys, os from arelle import CntlrCmdLine, CntlrComServer if u'--COMserver' in sys.argv: CntlrComServer.main() elif __name__.startswith(u'_mod_wsgi_') or os.getenv(u'wsgi.version'): application = CntlrCmdLine.wsgiApplication() elif __name__ == u'__main__': CntlrCmdLine.main()
''' Created on Feb 19, 2011 Use this module to start Arelle in command line modes @author: Mark V Systems Limited (c) Copyright 2011 Mark V Systems Limited, All rights reserved. ''' from arelle import CntlrCmdLine CntlrCmdLine.main()
envArgs = os.getenv("ARELLE_ARGS") manager = Manager() output = manager.dict() if envArgs: args = shlex.split(envArgs) else: args = sys.argv[1:] try: numthreads = int(args[args.index('--xule-numthreads') + 1]) except ValueError: numthreads = 1 gettext.install("arelle") # needed for options messages print("Initializing Server") cntlr = CntlrCmdLine.parseAndRun(args) cntlr.startLogging(logFileName='logToBuffer') # get generated options from controller options = getattr(cntlr, "xule_options", None) setattr(options, "webserver", options.xule_server) # Clear options to reduce size of cntlr object setattr(cntlr, "xule_options", None) setattr(options, "xule_server", None) # Clean up import gc gc.collect() # start web server if options is not None: '''
''' Created on Feb 19, 2011 Use this module to start Arelle in command line modes @author: Mark V Systems Limited (c) Copyright 2011 Mark V Systems Limited, All rights reserved. ''' import sys, os from arelle import CntlrCmdLine, CntlrComServer if '--COMserver' in sys.argv: CntlrComServer.main() elif __name__.startswith('_mod_wsgi_') or os.getenv('wsgi.version'): application = CntlrCmdLine.wsgiApplication() elif __name__ in ('__main__', 'arelleCmdLine__main__', 'arellecmdline__main__' ): #cx_Freeze 5 prepends module name to __main__ CntlrCmdLine.main()
''' Created on Feb 19, 2011 Use this module to start Arelle in command line modes @author: Mark V Systems Limited (c) Copyright 2011 Mark V Systems Limited, All rights reserved. ''' import sys from arelle import CntlrCmdLine, CntlrComServer if '--COMserver' in sys.argv: CntlrComServer.main() else: CntlrCmdLine.main()
def main(file, report_path): ignore_code_list = ['ix11.14.1.2:missingResources', 'ix11.12.1.2:missingReferences', 'arelle:ixdsTargetNotDefined', 'EFM.6.05.19', 'EFM.coverFacts', 'ix11.8.1.3:headerMissing', 'EFM.5.02.05.graphicFileError'] fdin, temp_in_path = tempfile.mkstemp('.htm') fdout, temp_out_path = tempfile.mkstemp('.xml') # temp_in_path = get_random_string(16) + '.htm' # temp_out_path = get_random_string(16) + '.xml' with open(file, 'r', encoding='utf-8') as fso: with open(temp_in_path, 'w') as outFso: data = fso.read() nsStr = 'xmlns:dei="http://xbrl.sec.gov/dei/2018-01-31" xmlns:rr="http://xbrl.sec.gov/rr/2018-01-31" ' \ 'xmlns:utr="http://www.xbrl.org/2009/utr" xmlns:link="http://www.xbrl.org/2003/linkbase" ' \ 'xmlns:xbrli="http://www.xbrl.org/2003/instance" ' \ 'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xlink="http://www.w3.org/1999/xlink" ' \ 'xmlns:xbrldi="http://xbrl.org/2006/xbrldi" xmlns:iso4217="http://www.xbrl.org/2003/iso4217" ' \ 'xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:num="http://www.xbrl.org/dtr/type/numeric" ' \ 'xmlns:nonnum="http://www.xbrl.org/dtr/type/non-numeric" ' \ 'xmlns:xbrldt="http://xbrl.org/2005/xbrldt" xmlns="http://www.w3.org/1999/xhtml" ' \ 'xmlns:ix="http://www.xbrl.org/2013/inlineXBRL" ' \ 'xmlns:ixt-sec="http://www.sec.gov/inlineXBRL/transformation/2015-08-31" ' \ 'xmlns:ixt="http://www.xbrl.org/inlineXBRL/transformation/2015-02-26" ' \ 'xmlns:pbf="http://www.pioneerinvestments.com/20200819" ' data = re.sub(r'^<html[^>]*>', '<html %s>' % nsStr, data) outFso.write(data) gettext.install("arelle") args = [ '-f', temp_in_path, '-v', '--efm', '--plugins', 'validate/EFM', '--disclosureSystem', 'efm-pragmatic-all-years', '--logFile', temp_out_path ] print('hello') CntlrCmdLine.parseAndRun(args) import logging logging.shutdown() print('bye') # print(temp_out_path) log_entries = [] with open(temp_out_path, 'r') as fso: data = fso.read() soup = bs4.BeautifulSoup(data, 'xml') for entry in soup.find_all('entry'): if entry["level"] != 'warning' and entry['level'] != 'error': continue if entry['code'] in ignore_code_list: continue msg = entry.message.text was_first = True for ref in entry.find_all('ref'): if 'sourceLine' in ref.attrs: logentry = Entry(msg, entry.attrs["code"], not was_first) for prop in ref.find_all('property'): logentry.ref_props[prop.attrs["name"]] = prop.attrs["value"] logentry.sourceLine = int(ref.attrs['sourceLine']) log_entries.append(logentry) was_first = False with open(temp_in_path, 'r') as fso: lines = fso.readlines() lineno = 1 entry_stack = [l for l in log_entries] for line in lines: line = line.strip() foundstack = None for idx, l in enumerate(entry_stack): if lineno == l.sourceLine - 1: l.prevLine = line elif lineno == l.sourceLine + 1: l.nextLine = line foundstack = idx break if lineno == l.sourceLine: l.sourceStr = line if foundstack is not None: del entry_stack[foundstack] lineno += 1 # for entry in log_entries: # print(entry) with open(report_path, 'w') as fso: fso.write(format_report_html(log_entries)) os.close(fdin) os.close(fdout) os.remove(temp_out_path) os.remove(temp_in_path)
import sys from arelle import CntlrCmdLine sys.argv = ['','-f', 'http://www.sec.gov/Archives/edgar/data/66740/000155837015002024/mmm-20150930.xml', '--disclosureSystem', 'efm-strict-all-years', '--store-to-XBRL-DB', 'rdfTurtleFile,None,None,None,/home/redward/Downloads/turtle_3m.rdf,None,rdfDB'] result = CntlrCmdLine.xbrlTurtleGraphModel('http://www.sec.gov/Archives/edgar/data/66740/000155837015002024/mmm-20150930.xml') x = 5