コード例 #1
0
 def getLocalFile(self, file, relpath, request):
     _report, _sep, _file = file.partition("/")
     if file == 'ixbrlviewer.js':
         return static_file(
             'ixbrlviewer.js',
             os.path.abspath(
                 os.path.join(os.path.dirname(__file__), "viewer", "dist")))
     elif _report.isnumeric():  # in reportsFolder folder
         # check if file is in the current or parent directory (may bve
         _fileDir = self.reportsFolders[int(_report)]
         _fileExists = False
         if os.path.exists(os.path.join(_fileDir, _file)):
             _fileExists = True
         elif "/" in _file and os.path.exists(
                 os.path.join(_fileDir, os.path.filepart(_file))):
             # xhtml in a subdirectory for output files may refer to an image file in parent directory
             _fileExists = True
             _file = os.path.filepart(_file)
         if not _fileExists:
             self.cntlr.addToLog("http://localhost:{}/{}".format(
                 self.port, file),
                                 messageCode="localViewer:fileNotFound",
                                 level=logging.DEBUG)
         return static_file(_file,
                            root=_fileDir,
                            headers=self.noCacheHeaders
                            )  # extra_headers modification to py-bottle
     return static_file(
         file, root="/")  # probably can't get here unless path is wrong
コード例 #2
0
ファイル: LocalViewer.py プロジェクト: Arelle/EdgarRenderer
 def getLocalFile(self, file, relpath, request):
     if file == 'favicon.ico':
         return static_file("arelle.ico", root=self.cntlr.imagesDir, mimetype='image/vnd.microsoft.icon')
     _report, _sep, _file = file.partition("/")
     if file == "---xbrl.zip" and "referer" in request.headers: # no report number, get from referer header
         refererPathParts = request.headers["referer"].split("/")
         if len(refererPathParts) >= 4 and refererPathParts[3].isnumeric():
             _report = refererPathParts[3]
             _file = file
     if (_file.startswith("ix.html") # although in ixviewer, it refers relatively to ixviewer/
         or _file.startswith("ix-dev.html")
         or _file.startswith("browser-error.html")
         or _file.startswith("css/")
         or (_file.startswith("images/") and os.path.exists(os.path.join(self.reportsFolders[0], 'ixviewer', _file))) 
         or _file.startswith("js/")):
         return static_file(_file, root=os.path.join(self.reportsFolders[0], 'ixviewer')) 
     if _file.startswith("/ixviewer"): # ops gateway
         return static_file(_file, root=self.reportsFolders[0][:-1]) 
     if _report == "include": # really in include subtree
         return static_file(_file, root=os.path.join(self.reportsFolders[0], 'include'))
     if _file.startswith("include/"): # really in ixviewer subtree (Workstation Images are in distribution include)
         return static_file(_file[8:], root=os.path.join(self.reportsFolders[0], 'include'))              
     if _file.startswith("images/") or  _file.startswith("Images/"): # really in ixviewer subtree (Workstation Images are in distribution include)
         return static_file(_file[7:], root=os.path.join(self.reportsFolders[0], 'include'))
     if _report == "images": # really in ixviewer subtree (Workstation Images are in distribution include)
         return static_file(_file, root=os.path.join(self.reportsFolders[0], 'include'))
     if _file.startswith("ixviewer/"): # really in ixviewer subtree
         return static_file(_file[9:], root=os.path.join(self.reportsFolders[0], 'ixviewer'))
     if _report.isnumeric(): # in reportsFolder folder
         # is it an EDGAR workstation query parameter
         if _file == "DisplayDocument.do" and "filename" in request.query:
             _file = request.query["filename"]
             self.cntlr.addToLog("  ?filename={}".format(_file), messageCode="localViewer:get",level=logging.DEBUG)
         # check if file is in the current or parent directory (may bve
         _fileDir = self.reportsFolders[int(_report)]
         _fileExists = False
         if os.path.exists(os.path.join(_fileDir, _file)):
             _fileExists = True
         elif os.path.exists(os.path.join(os.path.dirname(_fileDir), _file)):
             _fileDir = os.path.dirname(_fileDir)
             _fileExists = True
         elif file.endswith("---xbrl.zip"):
             # default zip produced for accession but local zip may have no accession number
             for f in os.listdir(_fileDir):
                 if f.endswith(".zip"):  
                     redirect("/{}/{}".format(_report,f))      
         if not _fileExists:
             self.cntlr.addToLog("http://localhost:{}/{}".format(self.port,file), messageCode="localViewer:fileNotFound",level=logging.DEBUG)
         return static_file(_file, root=_fileDir, headers=self.noCacheHeaders) # extra_headers modification to py-bottle
     return static_file(file, root="/") # probably can't get here unless path is wrong
コード例 #3
0
ファイル: CntlrWebMain.py プロジェクト: trb116/pythonanalyzer
def arelleIcon():
    """Request for icon for URL display (get */favicon.ico*).
    
    :returns: ico -- Icon file for browsers
    """
    return static_file("arelle.ico",
                       root=imagesDir,
                       mimetype='image/vnd.microsoft.icon')
コード例 #4
0
 def getlocalfile(file=None, relpath=None):
     cntlr.addToLog("http://localhost:{}/{}".format(port,file), messageCode="localViewer:get",level=logging.DEBUG)
     # print ("GET file={}".format(file))
     if not file and relpath:
         print("relpath=" + relpath)
     if file == 'favicon.ico':
         return static_file("arelle.ico", root=cntlr.imagesDir, mimetype='image/vnd.microsoft.icon')
     _report, _sep, _file = file.partition("/")
     if (_file.startswith("ix.html") # although in ixviewer, it refers relatively to ixviewer/
         or _file.startswith("css/")
         or (_file.startswith("images/") and os.path.exists(os.path.join(reportsFolders[0], 'ixviewer', _file))) 
         or _file.startswith("js/")):
         return static_file(_file, root=os.path.join(reportsFolders[0], 'ixviewer')) 
     if _report == "include": # really in include subtree
         # print(os.path.join(os.path.join(reportsFolders[0], 'include'), _file))
         return static_file(_file, root=os.path.join(reportsFolders[0], 'include'))              
     if _file.startswith("include/"): # really in ixviewer subtree
         # print(os.path.join(os.path.join(reportsFolders[0], 'ixviewer'),_file[9:]))
         return static_file(_file[8:], root=os.path.join(reportsFolders[0], 'include'))              
     if _file.startswith("ixviewer/"): # really in ixviewer subtree
         # print(os.path.join(os.path.join(reportsFolders[0], 'ixviewer'),_file[9:]))
         return static_file(_file[9:], root=os.path.join(reportsFolders[0], 'ixviewer'))              
     if _report.isnumeric(): # in reportsFolder folder
         # print (os.path.join(reportsFolders[int(_report)], _file))
         # is it an EDGAR workstation query parameter
         if _file == "DisplayDocument.do":
             try:
                 for i in range(100):
                     if "request" in sys._getframe(i).f_globals and hasattr(sys._getframe(i).f_globals["request"], "query"):
                         _file = sys._getframe(i).f_globals["request"].query["filename"]
                         cntlr.addToLog("  ?filename={}".format(_file), messageCode="localViewer:get",level=logging.DEBUG)
                         break
             except ValueError:
                 pass
         return static_file(_file, root=reportsFolders[int(_report)],
                            # extra_headers modification to py-bottle
                            more_headers={'Cache-Control': 'no-cache, no-store, must-revalidate',
                                          'Pragma': 'no-cache',
                                          'Expires': '0'})
     return static_file(file, root="/") # probably can't get here unless path is wrong
コード例 #5
0
ファイル: CntlrWebMain.py プロジェクト: andygreener/Arelle
def image(imgFile):
    """Request for an image file for URL display (get */images/<imgFile>*).
    
    :returns: image file -- Requested image file from images directory of application for browsers
    """
    return static_file(imgFile, root=imagesDir)
コード例 #6
0
ファイル: CntlrWebMain.py プロジェクト: andygreener/Arelle
def arelleIcon():
    """Request for icon for URL display (get */favicon.ico*).
    
    :returns: ico -- Icon file for browsers
    """
    return static_file("arelle.ico", root=imagesDir)
コード例 #7
0
ファイル: CntlrWebMain.py プロジェクト: jaolguin/Arelle
def image(imgFile):
    return static_file(imgFile, root=imagesDir)
コード例 #8
0
ファイル: CntlrWebMain.py プロジェクト: jaolguin/Arelle
def arelleIcon():
    return static_file("arelle.ico", root=imagesDir)
コード例 #9
0
ファイル: CntlrWebMain.py プロジェクト: JTYim/Arelle
def image(imgFile):
    """Request for an image file for URL display (get */images/<imgFile>*).
    
    :returns: image file -- Requested image file from images directory of application for browsers
    """
    return static_file(imgFile, root=imagesDir)
コード例 #10
0
ファイル: CntlrWebMain.py プロジェクト: JTYim/Arelle
def arelleIcon():
    """Request for icon for URL display (get */favicon.ico*).
    
    :returns: ico -- Icon file for browsers
    """
    return static_file("arelle.ico", root=imagesDir, mimetype='image/vnd.microsoft.icon')
コード例 #11
0
ファイル: CntlrWebMain.py プロジェクト: DaveInga/Arelle
def arelleIcon():
    """Request for icon for URL display (get */favicon.ico*).
    
    :returns: ico -- Icon file for browsers
    """
    return static_file("arelle.ico", root=imagesDir)