def add_libravatar(generator, metadata):
 missing = generator.settings.get('LIBRAVATAR_MISSING')
 size = generator.settings.get('LIBRAVATAR_SIZE')
 if ('email' not in metadata.keys()):
  try:
   metadata['email'] = generator.settings.get('AUTHOR_EMAIL')
  except:
   pass
 if metadata['email']:
  email = metadata['email'].lower().encode('ascii')
  md5 = hashlib.md5(email).hexdigest()
  url = ('http://cdn.libravatar.org/avatar/' + md5)
  if (missing or size):
   url = (url + '?')
   if missing:
    url = ((url + 'd=') + missing)
    if size:
     url = (url + '&')
   if size:
    url = ((url + 's=') + str(size))
  metadata['author_libravatar'] = url

def add_libravatar ( generator , metadata ) : missing = generator . settings . get ( 'LIBRAVATAR_MISSING' ) size = generator . settings . get ( 'LIBRAVATAR_SIZE' ) if ( 'email' not in metadata . keys ( ) ) : try : metadata [ 'email' ] = generator . settings . get ( 'AUTHOR_EMAIL' ) except : pass if metadata [ 'email' ] : email = metadata [ 'email' ] . lower ( ) . encode ( 'ascii' ) md5 = hashlib . md5 ( email ) . hexdigest ( ) url = ( 'http://cdn.libravatar.org/avatar/' + md5 ) if ( missing or size ) : url = ( url + '?' ) if missing : url = ( ( url + 'd=' ) + missing ) if size : url = ( url + '&' ) if size : url = ( ( url + 's=' ) + str ( size ) ) metadata [ 'author_libravatar' ] = url
article generator connector for the libravatar plugin .