isinstance(a, foo) is faster that type(a) == foo
This commit is contained in:
parent
63bcfc3054
commit
4466a7f6b2
1 changed files with 2 additions and 2 deletions
|
@ -247,7 +247,7 @@ class Connection:
|
||||||
if vc.getTag('vCard').getNamespace() == common.xmpp.NS_VCARD:
|
if vc.getTag('vCard').getNamespace() == common.xmpp.NS_VCARD:
|
||||||
card = vc.getChildren()[0]
|
card = vc.getChildren()[0]
|
||||||
vcard = self.node_to_dict(card)
|
vcard = self.node_to_dict(card)
|
||||||
if vcard and vcard.has_key('PHOTO') and type(vcard['PHOTO']) == type({}) and \
|
if vcard and vcard.has_key('PHOTO') and isinstance(vcard['PHOTO'], dict) and \
|
||||||
vcard['PHOTO'].has_key('BINVAL'):
|
vcard['PHOTO'].has_key('BINVAL'):
|
||||||
photo = vcard['PHOTO']['BINVAL']
|
photo = vcard['PHOTO']['BINVAL']
|
||||||
avatar_sha = sha.sha(photo).hexdigest()
|
avatar_sha = sha.sha(photo).hexdigest()
|
||||||
|
@ -1941,7 +1941,7 @@ class Connection:
|
||||||
for i in vcard:
|
for i in vcard:
|
||||||
if i == 'jid':
|
if i == 'jid':
|
||||||
continue
|
continue
|
||||||
if type(vcard[i]) == type({}):
|
if isinstance(vcard[i], dict):
|
||||||
iq3 = iq2.addChild(i)
|
iq3 = iq2.addChild(i)
|
||||||
for j in vcard[i]:
|
for j in vcard[i]:
|
||||||
iq3.addChild(j).setData(vcard[i][j])
|
iq3.addChild(j).setData(vcard[i][j])
|
||||||
|
|
Loading…
Add table
Reference in a new issue