<commit_before>#!/usr/bin/env python

import itunes
import os
from PIL import Image
import requests
import sys
import uuid


class Search(object):
    def __init__(self, keyword):
        self.keyword = keyword

    @property
    def app(self):
        """Best matched app in the result"""
        results = itunes.search_app(self.keyword)
        return results[0]


class Icon(object):
    def __init__(self, artwork):
        self.artwork = artwork

    def download(self, path, size):
        url = self.artwork['60']
        temp_path = os.path.join('/tmp', str(uuid.uuid4()))
        download(temp_path, url)
        _size = size, size
        i = Image.open(temp_path)
        im = i.resize(_size, Image.ANTIALIAS)
        im.save(path, quality=100)


def download(path, url):
    r = requests.get(url, stream=True)
    if r.status_code == 200:
        with open(path, 'wb') as f:
            for chunk in r.iter_content():
                f.write(chunk)

<commit_msg>Added code to remove temp files<commit_after>#!/usr/bin/env python

import itunes
import os
from PIL import Image
import requests
import sys
import uuid


class Search(object):
    def __init__(self, keyword):
        self.keyword = keyword

    @property
    def app(self):
        """Best matched app in the result"""
        results = itunes.search_app(self.keyword)
        return results[0]


class Icon(object):
    def __init__(self, artwork):
        self.artwork = artwork

    def download(self, path, size):
        url = self.artwork['60']
        temp_path = os.path.join('/tmp', str(uuid.uuid4()))
        download(temp_path, url)
        _size = size, size
        i = Image.open(temp_path)
        im = i.resize(_size, Image.ANTIALIAS)
        im.save(path, quality=100)
        os.remove(temp_path)


def download(path, url):
    r = requests.get(url, stream=True)
    if r.status_code == 200:
        with open(path, 'wb') as f:
            for chunk in r.iter_content():
                f.write(chunk)


{'fraction_non_alphanumeric': 0.11667501251877817, 'fraction_numerical': 0.010015022533800702, 'mean_word_length': 2.4329896907216493, 'pattern_counts': {'":': 0, '<': 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': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6662560', 'n_tokens_mistral': 646, 'n_tokens_neox': 618, 'n_words': 172}