<commit_before># encoding: utf-8

import logging

requests_log = logging.getLogger("flickrapi")
requests_log.propagate = False

import flickrapi

from openledger import app
from openledger.licenses import license_match

log = logging.getLogger(__name__)

LICENSES = {
    "BY": 4,
    "BY-NC": 2,
    "BY-ND": 6,
    "BY-SA": 5,
    "BY-NC-ND": 3,
    "BY-NC-SA": 1,
    "PDM": 7,
    "CC0": 9,
}
LICENSE_VERSION = "2.0"

LICENSE_LOOKUP = {v: k for k, v in LICENSES.items()}

def auth():
    return flickrapi.FlickrAPI(app.config['FLICKR_KEY'],
                               app.config['FLICKR_SECRET'],
                               format='parsed-json')

def photos(search=None, licenses=["ALL"], page=1, per_page=20, **kwargs):
    flickr = auth()
    photos = flickr.photos.search(safe_search=1,  # safe-search on
                         content_type=1,  # Photos only, no screenshots
                         license=license_match(licenses, LICENSES),
                         text=search,
                         extras='url_l,url_m,url_s,owner_name,license',
                         sort='relevance',
                         page=page,
                         per_page=per_page)
    photos['photos']['total'] = int(photos['photos']['total'])  # seriously why is this a string
    photos['photos']['pages'] = int(photos['photos']['pages'])  # seriously why is this a string

    return photos<commit_msg>[#31] Don't store cache tokens on disk where we can't write to the os<commit_after># encoding: utf-8

import logging

requests_log = logging.getLogger("flickrapi")
requests_log.propagate = False

import flickrapi

from openledger import app
from openledger.licenses import license_match

log = logging.getLogger(__name__)

LICENSES = {
    "BY": 4,
    "BY-NC": 2,
    "BY-ND": 6,
    "BY-SA": 5,
    "BY-NC-ND": 3,
    "BY-NC-SA": 1,
    "PDM": 7,
    "CC0": 9,
}
LICENSE_VERSION = "2.0"

LICENSE_LOOKUP = {v: k for k, v in LICENSES.items()}

def auth():
    return flickrapi.FlickrAPI(app.config['FLICKR_KEY'],
                               app.config['FLICKR_SECRET'],
                               format='parsed-json',
                               store_token=False,
                               cache=True)

def photos(search=None, licenses=["ALL"], page=1, per_page=20, **kwargs):
    flickr = auth()
    photos = flickr.photos.search(safe_search=1,  # safe-search on
                         content_type=1,  # Photos only, no screenshots
                         license=license_match(licenses, LICENSES),
                         text=search,
                         extras='url_l,url_m,url_s,owner_name,license',
                         sort='relevance',
                         page=page,
                         per_page=per_page)
    photos['photos']['total'] = int(photos['photos']['total'])  # seriously why is this a string
    photos['photos']['pages'] = int(photos['photos']['pages'])  # seriously why is this a string

    return photos
{'fraction_non_alphanumeric': 0.13040563191418036, 'fraction_numerical': 0.012068387529332886, 'mean_word_length': 2.1213389121338913, 'pattern_counts': {'":': 16, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6944203', 'n_tokens_mistral': 962, 'n_tokens_neox': 913, 'n_words': 206}