#NEWLINE# @ internationalizeDocstring #NEWLINE# def list( self , irc , msg , args , optlist , glob ) : #NEWLINE# #INDENT# '[--capability=<capability>] [<glob>]\n\n        Returns the valid registered usernames matching <glob>.  If <glob> is\n        not given, returns all registered usernames.\n        ' #NEWLINE# predicates = [ ] #NEWLINE# for ( option , arg ) in optlist : #NEWLINE# #INDENT# if ( option == 'capability' ) : #NEWLINE# #INDENT# if ( arg in conf . supybot . capabilities . private ( ) ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# u = ircdb . users . getUser ( msg . prefix ) #NEWLINE# if ( not u . _checkCapability ( 'admin' ) ) : #NEWLINE# #INDENT# raise KeyError #NEWLINE# #UNINDENT# #UNINDENT# except KeyError : #NEWLINE# #INDENT# irc . error ( _ ( 'This is a private capability. Only admins can see who has it.' ) , Raise = True ) #NEWLINE# #UNINDENT# #UNINDENT# def p( u , cap = arg ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# return u . _checkCapability ( cap ) #NEWLINE# #UNINDENT# except KeyError : #NEWLINE# #INDENT# return False #NEWLINE# #UNINDENT# #UNINDENT# predicates . append ( p ) #NEWLINE# #UNINDENT# #UNINDENT# if glob : #NEWLINE# #INDENT# r = re . compile ( fnmatch . translate ( glob ) , re . I ) #NEWLINE# def p( u ) : #NEWLINE# #INDENT# return ( r . match ( u . name ) is not None ) #NEWLINE# #UNINDENT# predicates . append ( p ) #NEWLINE# #UNINDENT# users = [ ] #NEWLINE# for u in ircdb . users . values ( ) : #NEWLINE# #INDENT# for predicate in predicates : #NEWLINE# #INDENT# if ( not predicate ( u ) ) : #NEWLINE# #INDENT# break #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# users . append ( u . name ) #NEWLINE# #UNINDENT# #UNINDENT# if users : #NEWLINE# #INDENT# utils . sortBy ( str . lower , users ) #NEWLINE# private = self . registryValue ( 'listInPrivate' , msg . args [ 0 ] ) #NEWLINE# irc . reply ( format ( '%L' , users ) , private = private ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if predicates : #NEWLINE# #INDENT# irc . reply ( _ ( 'There are no matching registered users.' ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# irc . reply ( _ ( 'There are no registered users.' ) )