def role(role_name, language_module, lineno, reporter):
 normname = role_name.lower()
 messages = []
 msg_text = []
 if (normname in _roles):
  return (_roles[normname], messages)
 if role_name:
  canonicalname = None
  try:
   canonicalname = language_module.roles[normname]
  except AttributeError as error:
   msg_text.append(('Problem retrieving role entry from language module %r: %s.' % (language_module, error)))
  except KeyError:
   msg_text.append(('No role entry for "%s" in module "%s".' % (role_name, language_module.__name__)))
 else:
  canonicalname = DEFAULT_INTERPRETED_ROLE
 if (not canonicalname):
  try:
   canonicalname = _fallback_language_module.roles[normname]
   msg_text.append(('Using English fallback for role "%s".' % role_name))
  except KeyError:
   msg_text.append(('Trying "%s" as canonical role name.' % role_name))
   canonicalname = normname
 if msg_text:
  message = reporter.info('\n'.join(msg_text), line=lineno)
  messages.append(message)
 if (canonicalname in _role_registry):
  role_fn = _role_registry[canonicalname]
  register_local_role(normname, role_fn)
  return (role_fn, messages)
 else:
  return (None, messages)

def role ( role_name , language_module , lineno , reporter ) : normname = role_name . lower ( ) messages = [ ] msg_text = [ ] if ( normname in _roles ) : return ( _roles [ normname ] , messages ) if role_name : canonicalname = None try : canonicalname = language_module . roles [ normname ] except AttributeError as error : msg_text . append ( ( 'Problem retrieving role entry from language module %r: %s.' % ( language_module , error ) ) ) except KeyError : msg_text . append ( ( 'No role entry for "%s" in module "%s".' % ( role_name , language_module . __name__ ) ) ) else : canonicalname = DEFAULT_INTERPRETED_ROLE if ( not canonicalname ) : try : canonicalname = _fallback_language_module . roles [ normname ] msg_text . append ( ( 'Using English fallback for role "%s".' % role_name ) ) except KeyError : msg_text . append ( ( 'Trying "%s" as canonical role name.' % role_name ) ) canonicalname = normname if msg_text : message = reporter . info ( '\n' . join ( msg_text ) , line = lineno ) messages . append ( message ) if ( canonicalname in _role_registry ) : role_fn = _role_registry [ canonicalname ] register_local_role ( normname , role_fn ) return ( role_fn , messages ) else : return ( None , messages )
locate and return a role function from its language-dependent name .