def has_metadata(trait, metadata, value=None, recursive=True):
 count = 0
 if (hasattr(trait, u'_metadata') and (metadata in list(trait._metadata.keys())) and ((trait._metadata[metadata] == value) or (value is None))):
  count += 1
 if recursive:
  if hasattr(trait, u'inner_traits'):
   for inner_trait in trait.inner_traits():
    count += has_metadata(inner_trait.trait_type, metadata, recursive)
  if (hasattr(trait, u'handlers') and (trait.handlers is not None)):
   for handler in trait.handlers:
    count += has_metadata(handler, metadata, recursive)
 return (count > 0)

def has_metadata ( trait , metadata , value = None , recursive = True ) : count = 0 if ( hasattr ( trait , u'_metadata' ) and ( metadata in list ( trait . _metadata . keys ( ) ) ) and ( ( trait . _metadata [ metadata ] == value ) or ( value is None ) ) ) : count += 1 if recursive : if hasattr ( trait , u'inner_traits' ) : for inner_trait in trait . inner_traits ( ) : count += has_metadata ( inner_trait . trait_type , metadata , recursive ) if ( hasattr ( trait , u'handlers' ) and ( trait . handlers is not None ) ) : for handler in trait . handlers : count += has_metadata ( handler , metadata , recursive ) return ( count > 0 )
checks if a given trait has a metadata .