#NEWLINE# def label( self , modelFrom , role , lang , returnMultiple = False , returnText = True , linkroleHint = None ) : #NEWLINE# #INDENT# shorterLangInLabel = longerLangInLabel = None #NEWLINE# shorterLangLabels = longerLangLabels = None #NEWLINE# langLabels = [ ] #NEWLINE# wildRole = ( role == '*' ) #NEWLINE# labels = self . fromModelObject ( modelFrom ) #NEWLINE# if linkroleHint : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# testHintedLinkrole = self . _testHintedLabelLinkrole #NEWLINE# #UNINDENT# except AttributeError : #NEWLINE# #INDENT# self . _testHintedLabelLinkrole = testHintedLinkrole = ( len ( self . linkRoleUris ) > 1 ) #NEWLINE# #UNINDENT# if testHintedLinkrole : #NEWLINE# #INDENT# labelsHintedLink = [ ] #NEWLINE# labelsDefaultLink = [ ] #NEWLINE# labelsOtherLinks = [ ] #NEWLINE# for modelLabelRel in labels : #NEWLINE# #INDENT# label = modelLabelRel . toModelObject #NEWLINE# if ( wildRole or ( role == label . role ) ) : #NEWLINE# #INDENT# linkrole = modelLabelRel . linkrole #NEWLINE# if ( linkrole == linkroleHint ) : #NEWLINE# #INDENT# labelsHintedLink . append ( modelLabelRel ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( linkrole == XbrlConst . defaultLinkRole ) : #NEWLINE# #INDENT# labelsDefaultLink . append ( modelLabelRel ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# labelsOtherLinks . append ( modelLabelRel ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# labels = ( labelsHintedLink or labelsDefaultLink or labelsOtherLinks ) #NEWLINE# #UNINDENT# #UNINDENT# if ( len ( labels ) > 1 ) : #NEWLINE# #INDENT# labels . sort ( key = ( lambda rel : rel . priority ) , reverse = True ) #NEWLINE# #UNINDENT# for modelLabelRel in labels : #NEWLINE# #INDENT# label = modelLabelRel . toModelObject #NEWLINE# if ( wildRole or ( role == label . role ) ) : #NEWLINE# #INDENT# labelLang = label . xmlLang #NEWLINE# text = ( label . textValue if returnText else label ) #NEWLINE# if ( ( lang is None ) or ( len ( lang ) == 0 ) or ( lang == labelLang ) ) : #NEWLINE# #INDENT# langLabels . append ( text ) #NEWLINE# if ( not returnMultiple ) : #NEWLINE# #INDENT# break #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if labelLang . startswith ( lang ) : #NEWLINE# #INDENT# if ( ( not longerLangInLabel ) or ( len ( longerLangInLabel ) > len ( labelLang ) ) ) : #NEWLINE# #INDENT# longerLangInLabel = labelLang #NEWLINE# longerLangLabels = [ text ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# longerLangLabels . append ( text ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if lang . startswith ( labelLang ) : #NEWLINE# #INDENT# if ( ( not shorterLangInLabel ) or ( len ( shorterLangInLabel ) < len ( labelLang ) ) ) : #NEWLINE# #INDENT# shorterLangInLabel = labelLang #NEWLINE# shorterLangLabels = [ text ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# shorterLangLabels . append ( text ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# if langLabels : #NEWLINE# #INDENT# if returnMultiple : #NEWLINE# #INDENT# return langLabels #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return langLabels [ 0 ] #NEWLINE# #UNINDENT# #UNINDENT# if shorterLangLabels : #NEWLINE# #INDENT# if returnMultiple : #NEWLINE# #INDENT# return shorterLangLabels #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return shorterLangLabels [ 0 ] #NEWLINE# #UNINDENT# #UNINDENT# if longerLangLabels : #NEWLINE# #INDENT# if returnMultiple : #NEWLINE# #INDENT# return longerLangLabels #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return longerLangLabels [ 0 ] #NEWLINE# #UNINDENT# #UNINDENT# return None