def printECodeFlickr(code, printFlickrLink): if printFlickrLink: return ahref(flickrLink(code), ecoInfo.getEcoregion(code)) + ' ' + ahref( wwfLink(code), '(WWF full report)') + '<br>' else: return ahref(wwfLink(code), ecoInfo.getEcoregion(code)) + '<br>'
def flickrLink(eCode): eTag = ecoInfo.getEcoregion(eCode).replace(' ', '').replace('-', '').replace( '.', '').replace(',', '') prefix = 'http://www.flickr.com/search/groups/?m=pool&w=1334707%40N21&s=int&q=' link = prefix + eTag return link
def picklePhotoIds(photoIds): pickle.dump(photoIds, open(pickleFile, "wb")) def isEcoregion(tag): return normalizeEcoregion(tag) in normalizedEcoregions def ecoregionsInTags(tags): return filter(isEcoregion, tags) def getECodes(ecoregions): return [normalizedEcoregions[normalizeEcoregion(e)] for e in ecoregions] normalizedEcoregions = dict() for c in ecoInfo.getAllECodes(): ecoregion = ecoInfo.getEcoregion(c) normalizedEcoregions[normalizeEcoregion(ecoregion)] = c photoIds= getPhotosIdsFromApi() badPhotos = list() eCodes = set() count = 1 max = 10000 for photoId in photoIds: print "processing photo " + str(count) + " of " + str(len(photoIds)) count = count + 1 if (count >= max): break photoXml = getPhoto(photoId)
def isEcoregion(tag): return normalizeEcoregion(tag) in normalizedEcoregions def ecoregionsInTags(tags): return filter(isEcoregion, tags) def getECodes(ecoregions): return [normalizedEcoregions[normalizeEcoregion(e)] for e in ecoregions] normalizedEcoregions = dict() for c in ecoInfo.getAllECodes(): ecoregion = ecoInfo.getEcoregion(c) normalizedEcoregions[normalizeEcoregion(ecoregion)] = c photoIds = getPhotosIdsFromApi() badPhotos = list() eCodes = set() count = 1 max = 10000 for photoId in photoIds: print "processing photo " + str(count) + " of " + str(len(photoIds)) count = count + 1 if (count >= max): break photoXml = getPhoto(photoId)
def printECodeFlickr(code, printFlickrLink): if printFlickrLink: return ahref(flickrLink(code), ecoInfo.getEcoregion(code)) + ' ' + ahref(wwfLink(code), '(WWF full report)') + '<br>' else: return ahref(wwfLink(code), ecoInfo.getEcoregion(code)) + '<br>'
def flickrLink(eCode): eTag = ecoInfo.getEcoregion(eCode).replace(' ','').replace('-','').replace('.','').replace(',','') prefix = 'http://www.flickr.com/search/groups/?m=pool&w=1334707%40N21&s=int&q=' link = prefix + eTag return link
def getEcoregionWiki(x): ecoregion = ecoInfo.getEcoregion(x) if ecoregion == 'Chaco': return 'Chaco (WWF ecoregion)' else: return ecoregion