comparison src/plugins/plugin_xep_0020.py @ 993:301b342c697a

core: use of the new core.log module: /!\ this is a massive refactoring and was largely automated, it probably did bring some bugs /!\
author Goffi <goffi@goffi.org>
date Sat, 19 Apr 2014 19:19:19 +0200
parents 1fe00f0c9a91
children 069ad98b360d
comparison
equal deleted inserted replaced
992:f51a1895275c 993:301b342c697a
16 16
17 # You should have received a copy of the GNU Affero General Public License 17 # You should have received a copy of the GNU Affero General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. 18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 19
20 from sat.core.i18n import _ 20 from sat.core.i18n import _
21 from logging import debug, info, warning, error 21 from sat.core.log import getLogger
22 log = getLogger(__name__)
22 from twisted.words.protocols.jabber import client, jid 23 from twisted.words.protocols.jabber import client, jid
23 from twisted.words.xish import domish 24 from twisted.words.xish import domish
24 25
25 from zope.interface import implements 26 from zope.interface import implements
26 27
45 46
46 47
47 class XEP_0020(object): 48 class XEP_0020(object):
48 49
49 def __init__(self, host): 50 def __init__(self, host):
50 info(_("Plugin XEP_0020 initialization")) 51 log.info(_("Plugin XEP_0020 initialization"))
51 52
52 def getHandler(self, profile): 53 def getHandler(self, profile):
53 return XEP_0020_handler() 54 return XEP_0020_handler()
54 55
55 def getFeatureElt(self, elt): 56 def getFeatureElt(self, elt):
66 result = {} 67 result = {}
67 for field in form.fields: 68 for field in form.fields:
68 values = form.fields[field].values 69 values = form.fields[field].values
69 result[field] = values[0] if values else None 70 result[field] = values[0] if values else None
70 if len(values) > 1: 71 if len(values) > 1:
71 warning(_("More than one value choosed for %s, keeping the first one") % field) 72 log.warning(_("More than one value choosed for %s, keeping the first one") % field)
72 return result 73 return result
73 74
74 def negociate(self, feature_elt, form_type, negociable_values): 75 def negociate(self, feature_elt, form_type, negociable_values):
75 """Negociate the feature options 76 """Negociate the feature options
76 @param feature_elt: feature domish element 77 @param feature_elt: feature domish element