#NEWLINE# def fileSave( self , event = None , view = None , fileType = None , filenameFromInstance = False , * ignore ) : #NEWLINE# #INDENT# if ( view is None ) : #NEWLINE# #INDENT# view = getattr ( self , 'currentView' , None ) #NEWLINE# #UNINDENT# if ( view is not None ) : #NEWLINE# #INDENT# filename = None #NEWLINE# modelXbrl = None #NEWLINE# try : #NEWLINE# #INDENT# modelXbrl = view . modelXbrl #NEWLINE# #UNINDENT# except AttributeError : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# if filenameFromInstance : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# modelXbrl = view . modelXbrl #NEWLINE# filename = modelXbrl . modelDocument . filepath #NEWLINE# if filename . endswith ( '.xsd' ) : #NEWLINE# #INDENT# filename = None #NEWLINE# #UNINDENT# #UNINDENT# except AttributeError : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# #UNINDENT# if isinstance ( view , ViewWinRenderedGrid . ViewRenderedGrid ) : #NEWLINE# #INDENT# initialdir = os . path . dirname ( err . modelDocument . uri ) #NEWLINE# if ( fileType in ( 'html' , 'xml' , None ) ) : #NEWLINE# #INDENT# if ( ( fileType == 'html' ) and ( filename is None ) ) : #NEWLINE# #INDENT# filename = self . uiFileDialog ( 'save' , title = _ ( 'arelle - Save HTML-rendered Table' ) , initialdir = initialdir , filetypes = [ ( _ ( 'HTML file .html' ) , '*.html' ) , ( _ ( 'HTML file .htm' ) , '*.htm' ) ] , defaultextension = '.html' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( ( fileType == 'xml' ) and ( filename is None ) ) : #NEWLINE# #INDENT# filename = self . uiFileDialog ( 'save' , title = _ ( 'arelle - Save Table Layout Model' ) , initialdir = initialdir , filetypes = [ ( _ ( 'Layout model file .xml' ) , '*.xml' ) ] , defaultextension = '.xml' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( filename is None ) : #NEWLINE# #INDENT# filename = self . uiFileDialog ( 'save' , title = _ ( 'arelle - Save XBRL Instance or HTML-rendered Table' ) , initialdir = initialdir , filetypes = [ ( _ ( 'XBRL instance .xbrl' ) , '*.xbrl' ) , ( _ ( 'XBRL instance .xml' ) , '*.xml' ) , ( _ ( 'HTML table .html' ) , '*.html' ) , ( _ ( 'HTML table .htm' ) , '*.htm' ) ] , defaultextension = '.html' ) #NEWLINE# #UNINDENT# if ( filename and ( filename . endswith ( '.xbrl' ) or filename . endswith ( '.xml' ) ) ) : #NEWLINE# #INDENT# view . saveInstance ( filename ) #NEWLINE# return True #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# if ( not filename ) : #NEWLINE# #INDENT# return False #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# ViewFileRenderedGrid . viewRenderedGrid ( modelXbrl , filename , lang = self . labelLang , sourceView = view ) #NEWLINE# #UNINDENT# except ( IOError , EnvironmentError ) as err : #NEWLINE# #INDENT# tkinter . messagebox . showwarning ( _ ( 'arelle - Error' ) , _ ( 'Failed to save {0}:\n{1}' ) . format ( filename , err ) , parent = self . parent ) #NEWLINE# #UNINDENT# return True #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( fileType == 'xbrl' ) : #NEWLINE# #INDENT# return self . uiFileDialog ( 'save' , title = _ ( 'arelle - Save Instance' ) , initialdir = initialdir , filetypes = [ ( _ ( 'XBRL instance .xbrl' ) , '*.xbrl' ) , ( _ ( 'XBRL instance .xml' ) , '*.xml' ) ] , defaultextension = '.xbrl' ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( isinstance ( view , ViewWinTests . ViewTests ) and ( modelXbrl . modelDocument . type in ( ModelDocument . Type . TESTCASESINDEX , ModelDocument . Type . TESTCASE ) ) ) : #NEWLINE# #INDENT# filename = self . uiFileDialog ( 'save' , title = _ ( 'arelle - Save Test Results' ) , initialdir = os . path . dirname ( self . modelManager . modelXbrl . modelDocument . uri ) , filetypes = [ ( _ ( 'CSV file' ) , '*.csv' ) ] , defaultextension = '.csv' ) #NEWLINE# if ( not filename ) : #NEWLINE# #INDENT# return False #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# ViewFileTests . viewTests ( self . modelManager . modelXbrl , filename ) #NEWLINE# #UNINDENT# except ( IOError , EnvironmentError ) as err : #NEWLINE# #INDENT# tkinter . messagebox . showwarning ( _ ( 'arelle - Error' ) , _ ( 'Failed to save {0}:\n{1}' ) . format ( filename , err ) , parent = self . parent ) #NEWLINE# #UNINDENT# return True #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if isinstance ( view , ViewWinTree . ViewTree ) : #NEWLINE# #INDENT# filename = self . uiFileDialog ( 'save' , title = _ ( 'arelle - Save {0}' ) . format ( view . tabTitle ) , initialdir = os . path . dirname ( self . modelManager . modelXbrl . modelDocument . uri ) , filetypes = [ ( _ ( 'CSV file' ) , '*.csv' ) , ( _ ( 'HTML file' ) , '*.html' ) , ( _ ( 'XML file' ) , '*.xml' ) , ( _ ( 'JSON file' ) , '*.json' ) ] , defaultextension = '.csv' ) #NEWLINE# if ( not filename ) : #NEWLINE# #INDENT# return False #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# if isinstance ( view , ViewWinRoleTypes . ViewRoleTypes ) : #NEWLINE# #INDENT# ViewFileRoleTypes . viewRoleTypes ( modelXbrl , filename , view . tabTitle , view . isArcrole , lang = view . lang ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if isinstance ( view , ViewWinConcepts . ViewConcepts ) : #NEWLINE# #INDENT# ViewFileConcepts . viewConcepts ( modelXbrl , filename , labelrole = view . labelrole , lang = view . lang ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if isinstance ( view , ViewWinFactList . ViewFactList ) : #NEWLINE# #INDENT# ViewFileFactList . viewFacts ( modelXbrl , filename , labelrole = view . labelrole , lang = view . lang ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# ViewFileRelationshipSet . viewRelationshipSet ( modelXbrl , filename , view . tabTitle , view . arcrole , labelrole = view . labelrole , lang = view . lang ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# except ( IOError , EnvironmentError ) as err : #NEWLINE# #INDENT# tkinter . messagebox . showwarning ( _ ( 'arelle - Error' ) , _ ( 'Failed to save {0}:\n{1}' ) . format ( filename , err ) , parent = self . parent ) #NEWLINE# #UNINDENT# return True #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( isinstance ( view , ViewWinXml . ViewXml ) and self . modelManager . modelXbrl . formulaOutputInstance ) : #NEWLINE# #INDENT# filename = self . uiFileDialog ( 'save' , title = _ ( 'arelle - Save Formula Result Instance Document' ) , initialdir = os . path . dirname ( self . modelManager . modelXbrl . modelDocument . uri ) , filetypes = [ ( _ ( 'XBRL output instance .xml' ) , '*.xml' ) , ( _ ( 'XBRL output instance .xbrl' ) , '*.xbrl' ) ] , defaultextension = '.xml' ) #NEWLINE# if ( not filename ) : #NEWLINE# #INDENT# return False #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# from arelle import XmlUtil #NEWLINE# with open ( filename , 'w' ) as fh : #NEWLINE# #INDENT# XmlUtil . writexml ( fh , self . modelManager . modelXbrl . formulaOutputInstance . modelDocument . xmlDocument , encoding = 'utf-8' ) #NEWLINE# #UNINDENT# self . addToLog ( _ ( '[info] Saved formula output instance to {0}' ) . format ( filename ) ) #NEWLINE# #UNINDENT# except ( IOError , EnvironmentError ) as err : #NEWLINE# #INDENT# tkinter . messagebox . showwarning ( _ ( 'arelle - Error' ) , _ ( 'Failed to save {0}:\n{1}' ) . format ( self . filename , err ) , parent = self . parent ) #NEWLINE# #UNINDENT# return True #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# tkinter . messagebox . showwarning ( _ ( 'arelle - Save what?' ) , _ ( 'Nothing has been selected that can be saved.  \nPlease select a view pane that can be saved.' ) , parent = self . parent ) #NEWLINE# '\n        if self.filename is None:\n            filename = self.uiFileDialog("save",\n                    title=_("arelle - Save File"),\n                    initialdir=".",\n                    filetypes=[(_("Xbrl file"), "*.x*")],\n                    defaultextension=".xbrl")\n            if not filename:\n                return False\n            self.filename = filename\n            if not self.filename.endswith(".xbrl"):\n                self.filename += ".xbrl"\n        try:\n            with open(self.filename, "wb") as fh:\n                pickle.dump(self.data, fh, pickle.HIGHEST_PROTOCOL)\n            self.dirty = False\n            self.uiShowStatus(_("Saved {0} items to {1}").format(\n                                len(self.data),\n                                self.filename), clearAfter=5000)\n            self.parent.title(_("arelle - {0}").format(\n                                os.path.basename(self.filename)))\n        except (EnvironmentError, pickle.PickleError) as err:\n            tkinter.messagebox.showwarning(_("arelle - Error"),\n                                _("Failed to save {0}:\n{1}").format(\n                                self.filename, err),\n                                parent=self.parent)\n        return True;\n        '