<commit_before>import os
import asyncio
import hashlib

from lxml import objectify
from boto.s3.connection import S3Connection

from waterbutler.core import streams
from waterbutler.core import provider
from waterbutler.core import exceptions

from waterbutler.s3 import settings
from waterbutler.s3.metadata import S3Revision
from waterbutler.s3.metadata import S3FileMetadata
from waterbutler.s3.metadata import S3FolderMetadata
from waterbutler.s3.metadata import S3FolderKeyMetadata
from waterbutler.s3.metadata import S3FileMetadataHeaders


class S3Provider(provider.BaseProvider):
    """Provider for the Amazon's S3
    """

    def __init__(self, auth, credentials, settings):
        """
        Note: Neither `S3Connection#__init__` nor `S3Connection#get_bucket`
        sends a request.
        :param dict auth: Not used
        :param dict credentials: Dict containing `access_key` and `secret_key`
        :param dict settings: Dict containing `bucket`
        """
        super().__init__(auth, credentials, settings)
        self.connection = S3Connection(credentials['access_key'], credentials['secret_key'])
        self.bucket = self.connection.get_bucket(settings['bucket'], validate=False)

    def can_intra_copy(self, dest_provider):
        return type(self) == type(dest_provider)

    def can_intra_move(self, dest_provider):
        return type(self) == type(dest_provider)

    @asyncio.coroutine
    def intra_copy(self, dest_provider, source_options, dest_options):
        """Copy key from one S3 bucket to another. The credentials specified in
        `dest_provider` must have read access to `source.bucket`.
        """
        dest_key = dest_provider.bucket.new_key(dest_options['path'])
        # ensure no left slash when joining paths
        source_path = '/' + os.path.join(self.settings['bucket'], source_options['path'].lstrip('/'))<commit_msg>Use Ordinary calling format by default<commit_after>import os
import asyncio
import hashlib

from lxml import objectify
from boto.s3.connection import S3Connection
from boto.s3.connection import OrdinaryCallingFormat

from waterbutler.core import streams
from waterbutler.core import provider
from waterbutler.core import exceptions

from waterbutler.s3 import settings
from waterbutler.s3.metadata import S3Revision
from waterbutler.s3.metadata import S3FileMetadata
from waterbutler.s3.metadata import S3FolderMetadata
from waterbutler.s3.metadata import S3FolderKeyMetadata
from waterbutler.s3.metadata import S3FileMetadataHeaders


class S3Provider(provider.BaseProvider):
    """Provider for the Amazon's S3
    """

    def __init__(self, auth, credentials, settings):
        """
        Note: Neither `S3Connection#__init__` nor `S3Connection#get_bucket`
        sends a request.
        :param dict auth: Not used
        :param dict credentials: Dict containing `access_key` and `secret_key`
        :param dict settings: Dict containing `bucket`
        """
        super().__init__(auth, credentials, settings)
        self.connection = S3Connection(credentials['access_key'],
                credentials['secret_key'], calling_format=OrdinaryCallingFormat())
        self.bucket = self.connection.get_bucket(settings['bucket'], validate=False)

    def can_intra_copy(self, dest_provider):
        return type(self) == type(dest_provider)

    def can_intra_move(self, dest_provider):
        return type(self) == type(dest_provider)

    @asyncio.coroutine
    def intra_copy(self, dest_provider, source_options, dest_options):
        """Copy key from one S3 bucket to another. The credentials specified in
        `dest_provider` must have read access to `source.bucket`.
        """
        dest_key = dest_provider.bucket.new_key(dest_options['path'])
        # ensure no left slash when joining paths
        source_path = '/' + os.path.join(self.settings['bucket'], source_options['path'].lstrip('/'))
{'fraction_non_alphanumeric': 0.08849104859335039, 'fraction_numerical': 0.009974424552429667, 'mean_word_length': 4.020539152759949, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '7629504', 'n_tokens_mistral': 1091, 'n_tokens_neox': 1076, 'n_words': 303}