<commit_before>__version__ = '0.1.3'


try:
    from PIL import Image, ImageOps
except ImportError:
    Image = None
    ImageOps = None

from io import BytesIO
import os
import os.path as op
import re

from boto.s3.connection import S3Connection
from boto.exception import S3ResponseError
from boto.s3.key import Key
from werkzeug.datastructures import FileStorage

from wtforms import ValidationError

from flask.ext.admin.form.upload import FileUploadField, ImageUploadInput, \
    thumbgen_filename
from flask.ext.admin._compat import urljoin

from url_for_s3 import url_for_s3


class S3FileUploadField(FileUploadField):
    """
    Inherits from flask-admin FileUploadField, to allow file uploading
    to Amazon S3 (as well as the default local storage).
    """

    def __init__(self, label=None, validators=None, storage_type=None,
                 bucket_name=None, access_key_id=None,
                 access_key_secret=None, acl='public-read',
                 storage_type_field=None, bucket_name_field=None,
                 static_root_parent=None, **kwargs):
        super(S3FileUploadField, self).__init__(label, validators, **kwargs)

        if storage_type and (storage_type != 's3'):
            raise ValueError(
                'Storage type "%s" is invalid, the only supported storage type'<commit_msg>Using flask_admin instead of deprecated flask.ext.admin<commit_after>__version__ = '0.1.3'


try:
    from PIL import Image, ImageOps
except ImportError:
    Image = None
    ImageOps = None

from io import BytesIO
import os
import os.path as op
import re

from boto.s3.connection import S3Connection
from boto.exception import S3ResponseError
from boto.s3.key import Key
from werkzeug.datastructures import FileStorage

from wtforms import ValidationError
x
from flask_admin.form.upload import FileUploadField, ImageUploadInput, \
    thumbgen_filename
from flask_admin._compat import urljoin

from url_for_s3 import url_for_s3


class S3FileUploadField(FileUploadField):
    """
    Inherits from flask-admin FileUploadField, to allow file uploading
    to Amazon S3 (as well as the default local storage).
    """

    def __init__(self, label=None, validators=None, storage_type=None,
                 bucket_name=None, access_key_id=None,
                 access_key_secret=None, acl='public-read',
                 storage_type_field=None, bucket_name_field=None,
                 static_root_parent=None, **kwargs):
        super(S3FileUploadField, self).__init__(label, validators, **kwargs)

        if storage_type and (storage_type != 's3'):
            raise ValueError(
                'Storage type "%s" is invalid, the only supported storage type'
{'fraction_non_alphanumeric': 0.0714020081814801, 'fraction_numerical': 0.009669021941242098, 'mean_word_length': 3.4536423841059603, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4116797', 'n_tokens_mistral': 798, 'n_tokens_neox': 774, 'n_words': 233}