<s> '''<STR_LIT>''' <EOL> from arelle import ViewFile , XbrlConst <EOL> from collections import defaultdict <EOL> def viewConcepts ( modelXbrl , outFile , labelrole = None , lang = None ) : <EOL> modelXbrl . modelManager . showStatus ( _ ( "<STR_LIT>" ) ) <EOL> view = ViewConcepts ( modelXbrl , outFile , labelrole , lang ) <EOL> view . view ( modelXbrl . modelDocument ) <EOL> view . close ( ) <EOL> class ViewConcepts ( ViewFile . View ) : <EOL> def __init__ ( self , modelXbrl , outFile , labelrole , lang ) : <EOL> super ( ViewConcepts , self ) . __init__ ( modelXbrl , outFile , "<STR_LIT>" , lang ) <EOL> self . labelrole = labelrole <EOL> def view ( self , modelDocument ) : <EOL> hasTypedDomainRef = False <EOL> hasDifferentNillables = False <EOL> priorNillable = None <EOL> excludedNamespaces = XbrlConst . ixbrlAll . union ( <EOL> ( XbrlConst . xbrli , XbrlConst . link , XbrlConst . xlink , XbrlConst . xl , <EOL> XbrlConst . xbrldt , <EOL> XbrlConst . xhtml ) ) <EOL> lbls = defaultdict ( list ) <EOL> for concept in set ( self . modelXbrl . qnameConcepts . values ( ) ) : <EOL> lbls [ concept . label ( preferredLabel = self . labelrole , lang = self . lang ) ] . append ( concept . objectId ( ) ) <EOL> if concept . modelDocument . targetNamespace not in excludedNamespaces : <EOL> if not hasTypedDomainRef and concept . typedDomainRef : <EOL> hasTypedDomainRef = True <EOL> if priorNillable is None : <EOL> priorNillable = concept . nillable <EOL> elif not hasDifferentNillables and concept . nillable != priorNillable : <EOL> hasDifferentNillables = True <EOL> headings = [ "<STR_LIT>" , "<STR_LIT:Name>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] <EOL> if hasDifferentNillables : <EOL> headings . append ( "<STR_LIT>" ) <EOL> if hasTypedDomainRef : <EOL> headings . append ( "<STR_LIT>" ) <EOL> headings . append ( "<STR_LIT>" ) <EOL> headings . append ( "<STR_LIT>" ) <EOL> self . addRow ( headings , asHeader = True ) <EOL> srtLbls = sorted ( lbls ) <EOL> for label in srtLbls : <EOL> for objectId in lbls [ label ] : <EOL> concept = self . modelXbrl . modelObject ( objectId ) <EOL> if concept . modelDocument . targetNamespace not in ( <EOL> XbrlConst . xbrli , XbrlConst . link , XbrlConst . xlink , XbrlConst . xl , <EOL> XbrlConst . xbrldt ) : <EOL> cols = [ concept . label ( preferredLabel = self . labelrole , lang = self . lang , strip = True , linkroleHint = XbrlConst . defaultLinkRole ) , <EOL> concept . name , <EOL> concept . id , <EOL> concept . abstract , <EOL> concept . substitutionGroupQname , <EOL> concept . typeQname , <EOL> concept . periodType , <EOL> concept . balance ] <EOL> if hasDifferentNillables : <EOL> cols . append ( concept . nillable ) <EOL> if hasTypedDomainRef : <EOL> cols . append ( concept . typedDomainRef or '<STR_LIT>' ) <EOL> if concept . type is not None and concept . type . facets : <EOL> cols . append ( "<STR_LIT:U+0020>" . join ( "<STR_LIT>" . format ( <EOL> name , <EOL> sorted ( value ) if isinstance ( value , set ) else value <EOL> ) for name , value in sorted ( concept . type . facets . items ( ) ) ) ) <EOL> else : <EOL> cols . append ( "<STR_LIT>" ) <EOL> cols . append ( concept . label ( preferredLabel = XbrlConst . documentationLabel , fallbackToQname = False , lang = self . lang , strip = True , linkroleHint = XbrlConst . defaultLinkRole ) ) <EOL> self . addRow ( cols ) </s>
