Package usufy :: Module config_usufy
[hide private]
[frames] | no frames]

Source Code for Module usufy.config_usufy

  1  # -*- coding: cp1252 -*- 
  2  # 
  3  ################################################################################## 
  4  # 
  5  #       This file is part of usufy.py. 
  6  # 
  7  #       Usufy is free software: you can redistribute it and/or modify 
  8  #       it under the terms of the GNU General Public License as published by 
  9  #       the Free Software Foundation, either version 3 of the License, or 
 10  #       (at your option) any later version. 
 11  # 
 12  #       This program is distributed in the hope that it will be useful, 
 13  #       but WITHOUT ANY WARRANTY; without even the implied warranty of 
 14  #       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
 15  #       GNU General Public License for more details. 
 16  # 
 17  #       You should have received a copy of the GNU General Public License 
 18  #       along with this program.  If not, see <http://www.gnu.org/licenses/>. 
 19  # 
 20  ################################################################################## 
 21   
 22  # Importing Classes of <Platform> objects that will be used in the script. The files are stored in the wrappers folder. 
 23  from wrappers.badoo import Badoo 
 24  from wrappers.blip import Blip 
 25  from wrappers.dailymotion import Dailymotion 
 26  from wrappers.delicious import Delicious 
 27  from wrappers.douban import Douban 
 28  from wrappers.ebay import Ebay 
 29  from wrappers.facebook import Facebook 
 30  from wrappers.foursquare import Foursquare 
 31  from wrappers.googleplus import GooglePlus 
 32  from wrappers.github import Github 
 33  from wrappers.hi5 import Hi5 
 34  from wrappers.instagram import Instagram 
 35  from wrappers.karmacracy import Karmacracy 
 36  from wrappers.klout import Klout 
 37  from wrappers.myspace import Myspace 
 38  from wrappers.pastebin import Pastebin 
 39  from wrappers.pinterest import Pinterest 
 40  from wrappers.qq import QQ 
 41  from wrappers.scribd import Scribd 
 42  from wrappers.slideshare import Slideshare 
 43  from wrappers.tumblr import Tumblr 
 44  from wrappers.twitter import Twitter 
 45  from wrappers.vk import Vk 
 46  from wrappers.youtube import Youtube 
 47  # Add any additinal import here 
 48  #from wrappers.any_new_social_network import Any_New_Social_Network 
 49  # ... 
 50  # Please, notify the authors if you have written a new wrapper. 
 51   
52 -def getPlatforms(sites=["all"], tags=[]):
53 """ 54 Method that defines the list of <Platform> objects to be processed... Note that <Facebook> or <Twitter> objects inherit from <Platform>. 55 56 Return values: 57 Returns a list [] of <Platform> objects. 58 """ 59 listAll = [] 60 listAll.append(Badoo()) 61 listAll.append(Blip()) 62 listAll.append(Dailymotion()) 63 listAll.append(Douban()) 64 # Pending of solving Issue #03 65 #listAll.append(Delicious()) 66 listAll.append(Ebay()) 67 listAll.append(Facebook()) 68 listAll.append(Foursquare()) 69 listAll.append(GooglePlus()) 70 listAll.append(Github()) 71 listAll.append(Hi5()) 72 listAll.append(Instagram()) 73 listAll.append(Karmacracy()) 74 listAll.append(Klout()) 75 listAll.append(Myspace()) 76 listAll.append(Pastebin()) 77 listAll.append(Pinterest()) 78 listAll.append(QQ()) 79 listAll.append(Scribd()) 80 listAll.append(Slideshare()) 81 listAll.append(Tumblr()) 82 listAll.append(Twitter()) 83 listAll.append(Vk()) 84 listAll.append(Youtube()) 85 # append to the list variable whatever new <Platform> object that you want to add. 86 #listAll.append(Any_New_Social_Network()) 87 if "all" in sites: 88 return listAll 89 else: 90 listSelected = [] 91 for site in listAll: 92 93 if site.platformName.lower() in sites: 94 listSelected.append(site) 95 else: 96 for tag in tags: 97 if tag in site.tags: 98 listSelected.append(site) 99 if len(listSelected) > 0: 100 return listSelected 101 else: 102 return listAll
103 104
105 -def calculateScore(res):
106 """ 107 Calculating the score from a dictionary: 108 {'Twitter': 'twitter.com/nick', 'Facebook': 'facebook.com/nick', ...} 109 110 Values returned: 111 score: a float number. 112 """ 113 score = 0.0 114 # recovering all the possible platforms 115 platforms = getPlatforms() 116 117 for p in platforms: 118 for r in res.keys(): 119 if r == str(p): 120 score += p.score 121 if score >= 100.00: 122 score = 100.00 123 break 124 125 print "Score:\t" + str(score) 126 127 return score
128