<commit_before>#!/usr/bin/python
# -*- coding: utf-8 -*-

# thumbor imaging service
# https://github.com/thumbor/thumbor/wiki

# Licensed under the MIT license:
# http://www.opensource.org/licenses/mit-license
# Copyright (c) 2011 globo.com <EMAIL>

import sys
from os.path import abspath, join, dirname


##
# Images used for tests :
#   - valid image      : JPEG 620x465, 69.88 KB
#   - too small image  : JPEG 20x20, 822 B
#   - too weight image : JPEG 300x400, 85.32 KB
##
def get_abs_path(img):
    return abspath(join(dirname(__file__), img.encode(sys.getfilesystemencoding())))

valid_image_path = get_abs_path(u'alabama1_ap620é.jpg')
too_small_image_path = get_abs_path('crocodile.jpg')
too_heavy_image_path = get_abs_path('conselheira_tutelar.jpg')
default_image_path = get_abs_path('image.jpg')
alabama1_image_path = get_abs_path('alabama1_ap620%C3%A9.jpg')
space_image_path = get_abs_path('image space.jpg')
invalid_quantization_image_path = get_abs_path('invalid_quantization.jpg')
animated_image_path = get_abs_path('animated_image.gif')


def get_image(img):
    with open(img, 'r') as stream:
        body = stream.read()
    return body


def valid_image():
    return get_image(valid_image_path)
<commit_msg>listdir on error<commit_after>#!/usr/bin/python
# -*- coding: utf-8 -*-

# thumbor imaging service
# https://github.com/thumbor/thumbor/wiki

# Licensed under the MIT license:
# http://www.opensource.org/licenses/mit-license
# Copyright (c) 2011 globo.com <EMAIL>

import sys
from os import listdir
from os.path import abspath, join, dirname


##
# Images used for tests :
#   - valid image      : JPEG 620x465, 69.88 KB
#   - too small image  : JPEG 20x20, 822 B
#   - too weight image : JPEG 300x400, 85.32 KB
##
def get_abs_path(img):
    return abspath(join(dirname(__file__), img.encode(sys.getfilesystemencoding())))

valid_image_path = get_abs_path(u'alabama1_ap620é.jpg')
too_small_image_path = get_abs_path('crocodile.jpg')
too_heavy_image_path = get_abs_path('conselheira_tutelar.jpg')
default_image_path = get_abs_path('image.jpg')
alabama1_image_path = get_abs_path('alabama1_ap620%C3%A9.jpg')
space_image_path = get_abs_path('image space.jpg')
invalid_quantization_image_path = get_abs_path('invalid_quantization.jpg')
animated_image_path = get_abs_path('animated_image.gif')


def get_image(img):
    try:
        with open(img, 'r') as stream:
            body = stream.read()
        return body
    except IOError, e:
        print listdir(abspath(dirname(img)))
        raise e


def valid_image():
    return get_image(valid_image_path)

{'fraction_non_alphanumeric': 0.11972103835722588, 'fraction_numerical': 0.03332041844246416, 'mean_word_length': 4.674725274725275, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, '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': '2743628', 'n_tokens_mistral': 1004, 'n_tokens_neox': 935, 'n_words': 188}