<commit_before>from unsplash.client import Client


class Photo(Client):

    def __init__(self, **kwargs):
        super(Photo, self).__init__(**kwargs)
        self.ordering_values = ["latest", "oldest", "popular"]
        self.orientation_values = ["landscape", "portrait", "squarish"]

    def _all(self, url, page=1, per_page=10, order_by="latest"):
        if order_by not in self.ordering_values:
            raise Exception()
        params = {
            "page": page,
            "per_page": per_page,
            "order_by": order_by
        }
        response = self._get(url, params=params)
        return response.json()

    def all(self, page=1, per_page=10, order_by="latest"):
        return self._all("/photos", page=page, per_page=per_page, order_by=order_by)

    def curated(self, page=1, per_page=10, order_by="latest"):
        return self._all("/photos/curated", page=page, per_page=per_page, order_by=order_by)

    def get(self, photo_id, width=None, height=None, rect=None):
        url = "/photos/%s" % photo_id
        params = {
            "width": width,
            "height": height,
            "rect": rect
        }
        response = self._get(url, params=params)
        return response.json()

    def search(self, query, category=None, orientation=None, page=1, per_page=10):
        if orientation and orientation not in self.orientation_values:
            raise Exception()
        params = {
            "query": query,
            "category": category,
            "orientation": orientation,
            "page": page,
            "per_page": per_page
        }
        url = "/photos/search"
        response = self._get(url, params=params)
        return response.json()<commit_msg>random, stats and download functions added to photo<commit_after>from unsplash.client import Client


class Photo(Client):

    def __init__(self, **kwargs):
        super(Photo, self).__init__(**kwargs)
        self.ordering_values = ["latest", "oldest", "popular"]
        self.orientation_values = ["landscape", "portrait", "squarish"]

    def _all(self, url, page=1, per_page=10, order_by="latest"):
        if order_by not in self.ordering_values:
            raise Exception()
        params = {
            "page": page,
            "per_page": per_page,
            "order_by": order_by
        }
        response = self._get(url, params=params)
        return response.json()

    def all(self, page=1, per_page=10, order_by="latest"):
        return self._all("/photos", page=page, per_page=per_page, order_by=order_by)

    def curated(self, page=1, per_page=10, order_by="latest"):
        return self._all("/photos/curated", page=page, per_page=per_page, order_by=order_by)

    def get(self, photo_id, width=None, height=None, rect=None):
        url = "/photos/%s" % photo_id
        params = {
            "width": width,
            "height": height,
            "rect": rect
        }
        response = self._get(url, params=params)
        return response.json()

    def search(self, query, category=None, orientation=None, page=1, per_page=10):
        if orientation and orientation not in self.orientation_values:
            raise Exception()
        params = {
            "query": query,
            "category": category,
            "orientation": orientation,
            "page": page,
            "per_page": per_page
        }
        url = "/photos/search"
        response = self._get(url, params=params)
        return response.json()

    def random(self, count=1, **kwargs):
        kwargs.update({"count": count})
        orientation = kwargs.get("orientation", None)
        if orientation and orientation not in self.orientation_values:
            raise Exception()
        url = "/photos/random"
        response = self._get(url, params=kwargs)
        return response.json()

    def stats(self, photo_id):
        url = "/photos/%s/stats" % photo_id
        response = self._get(url)
        return response.json()

    def download(self, photo_id):
        url = "/photos/%s/download" % photo_id
        response = self._get(url)
        return response.json()
{'fraction_non_alphanumeric': 0.12717601547388782, 'fraction_numerical': 0.0060444874274661504, 'mean_word_length': 2.3743882544861337, 'pattern_counts': {'":': 23, '<': 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': 3, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3259783', 'n_tokens_mistral': 1241, 'n_tokens_neox': 1195, 'n_words': 289}