~osomon/moovida/upicek_release_scripts

« back to all changes in this revision

Viewing changes to elisa-plugins/elisa/plugins/poblesec/music_library.py

  • Committer: Olivier Tilloy
  • Date: 2008-10-06 11:21:47 UTC
  • mfrom: (771.1.2 upicek_hashlib)
  • Revision ID: olivier@fluendo.com-20081006112147-key4lrmtc0f95hd0
 Fallback to md5 when hashlib is not available (python < 2.5).

Show diffs side-by-side

added added

removed removed

Lines of Context:
42
42
 
43
43
from elisa.core.utils import defer
44
44
 
45
 
import os, hashlib
 
45
import os
 
46
 
 
47
try:
 
48
    from hashlib import md5
 
49
except ImportError:
 
50
    # hashlib is new in Python 2.5
 
51
    from md5 import md5
46
52
 
47
53
 
48
54
# TODO: factorize this code in the core of Elisa in a caching utilities module
49
55
def _thumbnail_file(thumbnail_uri):
50
56
    if not os.path.exists(PICTURES_CACHE):
51
57
        os.makedirs(PICTURES_CACHE, 0755)
52
 
    thumbnail = hashlib.md5(str(thumbnail_uri)).hexdigest() + '.jpg'
 
58
    thumbnail = md5(str(thumbnail_uri)).hexdigest() + '.jpg'
53
59
    return os.path.join(PICTURES_CACHE, thumbnail)
54
60
 
55
61