annotate say_levels.py @ 229:a434b73bde51

added optional "action" argument to Participant.say_on_xmpp_to and muc.say_to Signed-off-by: Charly COSTE <changaco@changaco.net>
author Charly COSTE <changaco@changaco.net>
date Sun, 07 Mar 2010 22:12:25 +0100
parents 102f895347ff
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
180
102f895347ff added a required "importance" argument to Bot.error()
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
1 #!/usr/bin/env python
102f895347ff added a required "importance" argument to Bot.error()
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
2 # -*- coding: utf-8 -*-
102f895347ff added a required "importance" argument to Bot.error()
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
3
102f895347ff added a required "importance" argument to Bot.error()
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
4 # This program is free software: you can redistribute it and/or modify
102f895347ff added a required "importance" argument to Bot.error()
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
5 # it under the terms of the GNU General Public License as published by
102f895347ff added a required "importance" argument to Bot.error()
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
6 # the Free Software Foundation, either version 3 of the License, or
102f895347ff added a required "importance" argument to Bot.error()
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
7 # (at your option) any later version.
102f895347ff added a required "importance" argument to Bot.error()
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
8 #
102f895347ff added a required "importance" argument to Bot.error()
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
9 # This program is distributed in the hope that it will be useful,
102f895347ff added a required "importance" argument to Bot.error()
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
102f895347ff added a required "importance" argument to Bot.error()
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
102f895347ff added a required "importance" argument to Bot.error()
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
12 # GNU General Public License for more details.
102f895347ff added a required "importance" argument to Bot.error()
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
13 #
102f895347ff added a required "importance" argument to Bot.error()
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
14 # You should have received a copy of the GNU General Public License
102f895347ff added a required "importance" argument to Bot.error()
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
102f895347ff added a required "importance" argument to Bot.error()
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
16
102f895347ff added a required "importance" argument to Bot.error()
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
17
102f895347ff added a required "importance" argument to Bot.error()
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
18 from weighted_string import Weighted_string
102f895347ff added a required "importance" argument to Bot.error()
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
19
102f895347ff added a required "importance" argument to Bot.error()
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
20 debug = Weighted_string(0, 'debug')
102f895347ff added a required "importance" argument to Bot.error()
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
21 info = Weighted_string(1, 'info')
102f895347ff added a required "importance" argument to Bot.error()
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
22 notice = Weighted_string(2, 'notice')
102f895347ff added a required "importance" argument to Bot.error()
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
23 warning = Weighted_string(3, 'warning')
102f895347ff added a required "importance" argument to Bot.error()
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
24 error = Weighted_string(4, 'error')
102f895347ff added a required "importance" argument to Bot.error()
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
25 nothing = Weighted_string(5, 'nothing')
102f895347ff added a required "importance" argument to Bot.error()
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
26 levels = ['debug', 'info', 'notice', 'warning', 'error', 'nothing']
102f895347ff added a required "importance" argument to Bot.error()
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
27
102f895347ff added a required "importance" argument to Bot.error()
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
28 def get(level):
102f895347ff added a required "importance" argument to Bot.error()
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
29 if isinstance(level, int):
102f895347ff added a required "importance" argument to Bot.error()
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
30 return globals()[levels[level]]
102f895347ff added a required "importance" argument to Bot.error()
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
31 elif isinstance(level, basestring):
102f895347ff added a required "importance" argument to Bot.error()
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
32 try:
102f895347ff added a required "importance" argument to Bot.error()
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
33 return globals()[str(level)]
102f895347ff added a required "importance" argument to Bot.error()
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
34 except KeyError:
102f895347ff added a required "importance" argument to Bot.error()
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
35 raise ValueError, 'say_level must be one of these values: '+', '.join(levels)
102f895347ff added a required "importance" argument to Bot.error()
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
36 else:
102f895347ff added a required "importance" argument to Bot.error()
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
37 raise TypeError, 'say_level must be either an int or a string'