[sugar] [PATCH] services/presence/server_plugin: Use more conventional conditional import for md5
Simon McVittie
simon.mcvittie at collabora.co.uk
Thu May 24 07:47:10 EDT 2007
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
- ---
services/presence/server_plugin.py | 15 +++++++--------
1 files changed, 7 insertions(+), 8 deletions(-)
diff --git a/services/presence/server_plugin.py b/services/presence/server_plugin.py
index 8556792..486bec4 100644
- --- a/services/presence/server_plugin.py
+++ b/services/presence/server_plugin.py
@@ -24,6 +24,12 @@ from buddyiconcache import BuddyIconCache
import logging
import os
+try:
+ # Python >= 2.5
+ from hashlib import md5
+except ImportError:
+ from md5 import new as md5
+
import sys
import psutils
@@ -397,14 +403,7 @@ class ServerPlugin(gobject.GObject):
if not icon_data:
icon_data = self._owner.props.icon
- - m = None
- - if sys.version_info[:3] >= (2, 5, 0):
- - import hashlib
- - m = hashlib.md5()
- - else:
- - import md5
- - m = md5.new()
- -
+ m = md5()
m.update(icon_data)
hash = m.hexdigest()
- --
1.5.2-rc3.GIT
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: OpenPGP key: http://www.pseudorandom.co.uk/2003/contact/ or pgp.net
iD8DBQFGVXs+WSc8zVUw7HYRAoKkAKC8KYV2LnUnW4pLKT8pDwrUW0351QCdG3Xo
EpqPrqBFkbS2J6BkyCTQVZA=
=YxOQ
-----END PGP SIGNATURE-----
More information about the Sugar
mailing list